Skip to content

Commit

Permalink
Merge pull request #25705 from pahan35/5.6-port-test-fixes
Browse files Browse the repository at this point in the history
[5.6] port Windows test fixes PR #25646 to 5.6 branch
  • Loading branch information
GrahamCampbell committed Sep 19, 2018
2 parents e8bc9fb + e7ba421 commit 0a83ce3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
12 changes: 6 additions & 6 deletions tests/Console/Scheduling/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ public function tearDown()

public function testBuildCommand()
{
$quote = (DIRECTORY_SEPARATOR == '\\') ? '"' : "'";
$isWindows = DIRECTORY_SEPARATOR == '\\';
$quote = ($isWindows) ? '"' : "'";

$event = new Event(m::mock('Illuminate\Console\Scheduling\EventMutex'), 'php -i');

$defaultOutput = (DIRECTORY_SEPARATOR == '\\') ? 'NUL' : '/dev/null';
$defaultOutput = ($isWindows) ? 'NUL' : '/dev/null';
$this->assertSame("php -i > {$quote}{$defaultOutput}{$quote} 2>&1", $event->buildCommand());

$quote = (DIRECTORY_SEPARATOR == '\\') ? '"' : "'";

$event = new Event(m::mock('Illuminate\Console\Scheduling\EventMutex'), 'php -i');
$event->runInBackground();

$defaultOutput = (DIRECTORY_SEPARATOR == '\\') ? 'NUL' : '/dev/null';
$this->assertSame("(php -i > {$quote}{$defaultOutput}{$quote} 2>&1 ; '".PHP_BINARY."' artisan schedule:finish \"framework/schedule-eeb46c93d45e928d62aaf684d727e213b7094822\") > {$quote}{$defaultOutput}{$quote} 2>&1 &", $event->buildCommand());
$commandSeparator = ($isWindows ? '&' : ';');
$scheduleId = '"framework'.DIRECTORY_SEPARATOR.'schedule-eeb46c93d45e928d62aaf684d727e213b7094822"';
$this->assertSame("(php -i > {$quote}{$defaultOutput}{$quote} 2>&1 {$commandSeparator} {$quote}".PHP_BINARY."{$quote} artisan schedule:finish {$scheduleId}) > {$quote}{$defaultOutput}{$quote} 2>&1 &", $event->buildCommand());
}

public function testBuildCommandSendOutputTo()
Expand Down
6 changes: 4 additions & 2 deletions tests/Database/DatabaseMigrationRefreshCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public function testRefreshCommandCallsCommandsWithProperArguments()
$console->shouldReceive('find')->with('migrate:reset')->andReturn($resetCommand);
$console->shouldReceive('find')->with('migrate')->andReturn($migrateCommand);

$resetCommand->shouldReceive('run')->with(new InputMatcher("--database --path --realpath --force 'migrate:reset'"), m::any());
$quote = DIRECTORY_SEPARATOR == '\\' ? '"' : "'";
$resetCommand->shouldReceive('run')->with(new InputMatcher("--database --path --realpath --force {$quote}migrate:reset{$quote}"), m::any());
$migrateCommand->shouldReceive('run')->with(new InputMatcher('--database --path --realpath --force migrate'), m::any());

$this->runCommand($command);
Expand All @@ -57,7 +58,8 @@ public function testRefreshCommandCallsCommandsWithStep()
$console->shouldReceive('find')->with('migrate:rollback')->andReturn($rollbackCommand);
$console->shouldReceive('find')->with('migrate')->andReturn($migrateCommand);

$rollbackCommand->shouldReceive('run')->with(new InputMatcher("--database --path --realpath --step=2 --force 'migrate:rollback'"), m::any());
$quote = DIRECTORY_SEPARATOR == '\\' ? '"' : "'";
$rollbackCommand->shouldReceive('run')->with(new InputMatcher("--database --path --realpath --step=2 --force {$quote}migrate:rollback{$quote}"), m::any());
$migrateCommand->shouldReceive('run')->with(new InputMatcher('--database --path --realpath --force migrate'), m::any());

$this->runCommand($command, ['--step' => 2]);
Expand Down
4 changes: 2 additions & 2 deletions tests/Database/DatabaseMigrationResetCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testResetCommandCallsMigratorWithProperArguments()
$migrator->shouldReceive('paths')->once()->andReturn([]);
$migrator->shouldReceive('setConnection')->once()->with(null);
$migrator->shouldReceive('repositoryExists')->once()->andReturn(true);
$migrator->shouldReceive('reset')->once()->with([__DIR__.'/migrations'], false);
$migrator->shouldReceive('reset')->once()->with([__DIR__.DIRECTORY_SEPARATOR.'migrations'], false);
$migrator->shouldReceive('getNotes')->andReturn([]);

$this->runCommand($command);
Expand All @@ -38,7 +38,7 @@ public function testResetCommandCanBePretended()
$migrator->shouldReceive('paths')->once()->andReturn([]);
$migrator->shouldReceive('setConnection')->once()->with('foo');
$migrator->shouldReceive('repositoryExists')->once()->andReturn(true);
$migrator->shouldReceive('reset')->once()->with([__DIR__.'/migrations'], true);
$migrator->shouldReceive('reset')->once()->with([__DIR__.DIRECTORY_SEPARATOR.'migrations'], true);
$migrator->shouldReceive('getNotes')->andReturn([]);

$this->runCommand($command, ['--pretend' => true, '--database' => 'foo']);
Expand Down
8 changes: 4 additions & 4 deletions tests/Database/DatabaseMigrationRollbackCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testRollbackCommandCallsMigratorWithProperArguments()
$command->setLaravel($app);
$migrator->shouldReceive('paths')->once()->andReturn([]);
$migrator->shouldReceive('setConnection')->once()->with(null);
$migrator->shouldReceive('rollback')->once()->with([__DIR__.'/migrations'], ['pretend' => false, 'step' => 0]);
$migrator->shouldReceive('rollback')->once()->with([__DIR__.DIRECTORY_SEPARATOR.'migrations'], ['pretend' => false, 'step' => 0]);
$migrator->shouldReceive('getNotes')->andReturn([]);

$this->runCommand($command);
Expand All @@ -36,7 +36,7 @@ public function testRollbackCommandCallsMigratorWithStepOption()
$command->setLaravel($app);
$migrator->shouldReceive('paths')->once()->andReturn([]);
$migrator->shouldReceive('setConnection')->once()->with(null);
$migrator->shouldReceive('rollback')->once()->with([__DIR__.'/migrations'], ['pretend' => false, 'step' => 2]);
$migrator->shouldReceive('rollback')->once()->with([__DIR__.DIRECTORY_SEPARATOR.'migrations'], ['pretend' => false, 'step' => 2]);
$migrator->shouldReceive('getNotes')->andReturn([]);

$this->runCommand($command, ['--step' => 2]);
Expand All @@ -50,7 +50,7 @@ public function testRollbackCommandCanBePretended()
$command->setLaravel($app);
$migrator->shouldReceive('paths')->once()->andReturn([]);
$migrator->shouldReceive('setConnection')->once()->with('foo');
$migrator->shouldReceive('rollback')->once()->with([__DIR__.'/migrations'], true);
$migrator->shouldReceive('rollback')->once()->with([__DIR__.DIRECTORY_SEPARATOR.'migrations'], true);
$migrator->shouldReceive('getNotes')->andReturn([]);

$this->runCommand($command, ['--pretend' => true, '--database' => 'foo']);
Expand All @@ -64,7 +64,7 @@ public function testRollbackCommandCanBePretendedWithStepOption()
$command->setLaravel($app);
$migrator->shouldReceive('paths')->once()->andReturn([]);
$migrator->shouldReceive('setConnection')->once()->with('foo');
$migrator->shouldReceive('rollback')->once()->with([__DIR__.'/migrations'], ['pretend' => true, 'step' => 2]);
$migrator->shouldReceive('rollback')->once()->with([__DIR__.DIRECTORY_SEPARATOR.'migrations'], ['pretend' => true, 'step' => 2]);
$migrator->shouldReceive('getNotes')->andReturn([]);

$this->runCommand($command, ['--pretend' => true, '--database' => 'foo', '--step' => 2]);
Expand Down
6 changes: 3 additions & 3 deletions tests/Filesystem/FilesystemAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testPath()
{
$this->filesystem->write('file.txt', 'Hello World');
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$this->assertEquals($this->tempDir.'/file.txt', $filesystemAdapter->path('file.txt'));
$this->assertEquals($this->tempDir.DIRECTORY_SEPARATOR.'file.txt', $filesystemAdapter->path('file.txt'));
}

public function testGet()
Expand Down Expand Up @@ -90,15 +90,15 @@ public function testPrepend()
file_put_contents($this->tempDir.'/file.txt', 'World');
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$filesystemAdapter->prepend('file.txt', 'Hello ');
$this->assertStringEqualsFile($this->tempDir.'/file.txt', "Hello \nWorld");
$this->assertStringEqualsFile($this->tempDir.'/file.txt', 'Hello '.PHP_EOL.'World');
}

public function testAppend()
{
file_put_contents($this->tempDir.'/file.txt', 'Hello ');
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
$filesystemAdapter->append('file.txt', 'Moon');
$this->assertStringEqualsFile($this->tempDir.'/file.txt', "Hello \nMoon");
$this->assertStringEqualsFile($this->tempDir.'/file.txt', 'Hello '.PHP_EOL.'Moon');
}

public function testDelete()
Expand Down
8 changes: 5 additions & 3 deletions tests/Filesystem/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public function testSetChmod()
$files = new Filesystem;
$files->chmod($this->tempDir.'/file.txt', 0755);
$filePermission = substr(sprintf('%o', fileperms($this->tempDir.'/file.txt')), -4);
$this->assertEquals('0755', $filePermission);
$expectedPermissions = DIRECTORY_SEPARATOR == '\\' ? '0666' : '0755';
$this->assertEquals($expectedPermissions, $filePermission);
}

public function testGetChmod()
Expand All @@ -56,8 +57,9 @@ public function testGetChmod()
chmod($this->tempDir.'/file.txt', 0755);

$files = new Filesystem;
$filePermisson = $files->chmod($this->tempDir.'/file.txt');
$this->assertEquals('0755', $filePermisson);
$filePermission = $files->chmod($this->tempDir.'/file.txt');
$expectedPermissions = DIRECTORY_SEPARATOR == '\\' ? '0666' : '0755';
$this->assertEquals($expectedPermissions, $filePermission);
}

public function testDeleteRemovesFiles()
Expand Down

0 comments on commit 0a83ce3

Please sign in to comment.