Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added some tests.
  • Loading branch information
fractalzombie committed Dec 31, 2018
commit a15cf16dda3bdf11834ee5457b5ff15fdbfd740d
2 changes: 1 addition & 1 deletion src/Commands/HttpServerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ protected function registerAccessLog()
});

$this->laravel->singleton(AccessOutput::class, function () {
return new AccessOutput(new ConsoleOutput());
return new AccessOutput(new ConsoleOutput);
});

$this->laravel->singleton(AccessLog::class, function (Container $container) {
Expand Down
2 changes: 0 additions & 2 deletions src/HotReload/FSEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

/**
* Class FSEvent
*
* @codeCoverageIgnore
*/
class FSEvent
{
Expand Down
2 changes: 0 additions & 2 deletions src/HotReload/FSEventParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

/**
* Class FSEventParser
*
* @codeCoverageIgnore
*/
class FSEventParser
{
Expand Down
22 changes: 22 additions & 0 deletions tests/HotReload/FSEventParserTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace SwooleTW\Http\Tests\HotReload;

use Carbon\Carbon;
use SwooleTW\Http\HotReload\FSEvent;
use SwooleTW\Http\HotReload\FSEventParser;
use SwooleTW\Http\Tests\TestCase;

/**
* Class FSEventParserTest
*/
class FSEventParserTest extends TestCase
{
public function testItCanCreateObjectAfterParse()
{
$buffer = 'Mon Dec 31 01:18:34 2018 /Some/Path/To/File/File.php Renamed OwnerModified IsFile';
$event = FSEventParser::toEvent($buffer);

$this->assertInstanceOf(FSEvent::class, $event);
}
}
28 changes: 28 additions & 0 deletions tests/HotReload/FSEventTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace SwooleTW\Http\Tests\HotReload;

use Illuminate\Support\Carbon;
use SwooleTW\Http\HotReload\FSEvent;
use SwooleTW\Http\Tests\TestCase;

/**
* Class FSEventTest
*/
class FSEventTest extends TestCase
{
public function testObjectIsCorrect()
{
$date = Carbon::parse('Mon Dec 31 01:18:34 2018');
$path = '/Some/Path/To/File/File.php';
$events = explode(' ', 'Renamed OwnerModified IsFile');
$events = array_sort(array_intersect(FSEvent::getPossibleTypes(), $events));
$event = new FSEvent($date, $path, $events);

$this->assertTrue(array_diff($event->getTypes(), [FSEvent::Renamed, FSEvent::OwnerModified]) === []);
$this->assertTrue((new Carbon('Mon Dec 31 01:18:34 2018'))->eq($event->getWhen()));
$this->assertEquals('/Some/Path/To/File/File.php', $event->getPath());
$this->assertTrue($event->isType(FSEvent::Renamed));
$this->assertTrue($event->isType(FSEvent::OwnerModified));
}
}