8000 Merge pull request #25705 from pahan35/5.6-port-test-fixes · laravel/framework@0a83ce3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a83ce3

Browse files
Merge pull request #25705 from pahan35/5.6-port-test-fixes
[5.6] port Windows test fixes PR #25646 to 5.6 branch
2 parents e8bc9fb + e7ba421 commit 0a83ce3

File tree

6 files changed

+24
-20
lines changed

6 files changed

+24
-20
lines changed

tests/Console/Scheduling/EventTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ public function tearDown()
1515

1616
public function testBuildCommand()
1717
{
18-
$quote = (DIRECTORY_SEPARATOR == '\\') ? '"' : "'";
18+
$isWindows = DIRECTORY_SEPARATOR == '\\';
19+
$quote = ($isWindows) ? '"' : "'";
1920

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

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

25-
$quote = (DIRECTORY_SEPARATOR == '\\') ? '"' : "'";
26-
2726
$event = new Event(m::mock('Illuminate\Console\Scheduling\EventMutex'), 'php -i');
2827
$event->runInBackground();
2928

30-
$defaultOutput = (DIRECTORY_SEPARATOR == '\\') ? 'NUL' : '/dev/null';
31-
$this->assertSame("(php -i > {$quote}{$defaultOutput}{$quote} 2>&1 ; '".PHP_BINARY."' artisan schedule:finish \"framework/schedule-eeb46c93d45e928d62aaf684d727e213b7094822\") > {$quote}{$defaultOutput}{$quote} 2>&1 &", $event->buildCommand());
29+
$commandSeparator = ($isWindows ? '&' : ';');
30+
$scheduleId = '"framework'.DIRECTORY_SEPARATOR.'schedule-eeb46c93d45e928d62aaf684d727e213b7094822"';
31+
$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());
3232
}
3333

3434
public function testBuildCommandSendOutputTo()

tests/Database/DatabaseMigrationRefreshCommandTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public function testRefreshCommandCallsCommandsWithProperArguments()
3535
$console->shouldReceive('find')->with('migrate:reset')->andReturn($resetCommand);
3636
$console->shouldReceive('find')->with('migrate')->andReturn($migrateCommand);
3737

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

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

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

6365
$this->runCommand($command, ['--step' => 2]);

tests/Database/DatabaseMigrationResetCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function testResetCommandCallsMigratorWithProperArguments()
2323
$migrator->shouldReceive('paths')->once()->andReturn([]);
2424
$migrator->shouldReceive('setConnection')->once()->with(null);
2525
$migrator->shouldReceive('repositoryExists')->once()->andReturn(true);
26-
$migrator->shouldReceive('reset')->once()->with([__DIR__.'/migrations'], false);
26+
$migrator->shouldReceive('reset')->once()->with([__DIR__.DIRECTORY_SEPARATOR.'migrations'], false);
2727
$migrator->shouldReceive('getNotes')->andReturn([]);
2828

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

4444
$this->runCommand($command, ['--pretend' => true, '--database' => 'foo']);

tests/Database/DatabaseMigrationRollbackCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function testRollbackCommandCallsMigratorWithProperArguments()
2222
$command->setLaravel($app);
2323
$migrator->shouldReceive('paths')->once()->andReturn([]);
2424
$migrator->shouldReceive('setConnection')->once()->with(null);
25-
$migrator->shouldReceive('rollback')->once()->with([__DIR__.'/migrations'], ['pretend' => false, 'step' => 0]);
25+
$migrator->shouldReceive('rollback')->once()->with([__DIR__.DIRECTORY_SEPARATOR.'migrations'], ['pretend' => false, 'step' => 0]);
2626
$migrator->shouldReceive('getNotes')->andReturn([]);
2727

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

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

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

7070
$this->runCommand($command, ['--pretend' => true, '--database' => 'foo', '--step' => 2]);

tests/Filesystem/FilesystemAdapterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testPath()
6161
{
6262
$this->filesystem->write('file.txt', 'Hello World');
6363
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
64-
$this->assertEquals($this->tempDir.'/file.txt', $filesystemAdapter->path('file.txt'));
64+
$this->assertEquals($this->tempDir.DIRECTORY_SEPARATOR.'file.txt', $filesystemAdapter->path('file.txt'));
6565
}
6666

6767
public function testGet()
@@ -90,15 +90,15 @@ public function testPrepend()
9090
file_put_contents($this->tempDir.'/file.txt', 'World');
9191
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
9292
$filesystemAdapter->prepend('file.txt', 'Hello ');
93-
$this->assertStringEqualsFile($this->tempDir.'/file.txt', "Hello \nWorld");
93+
$this->assertStringEqualsFile($this->tempDir.'/file.txt', 'Hello '.PHP_EOL.'World');
9494
}
9595

9696
public function testAppend()
9797
{
9898
file_put_contents($this->tempDir.'/file.txt', 'Hello ');
9999
$filesystemAdapter = new FilesystemAdapter($this->filesystem);
100100
$filesystemAdapter->append('file.txt', 'Moon');
101-
$this->assertStringEqualsFile($this->tempDir.'/file.txt', "Hello \nMoon");
101+
$this->assertStringEqualsFile($this->tempDir.'/file.txt', 'Hello '.PHP_EOL.'Moon');
102102
}
103103

104104
public function testDelete()

tests/Filesystem/FilesystemTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public function testSetChmod()
4747
$files = new Filesystem;
4848
$files->chmod($this->tempDir.'/file.txt', 0755);
4949
$filePermission = substr(sprintf('%o', fileperms($this->tempDir.'/file.txt')), -4);
50-
$this->assertEquals('0755', $filePermission);
50+
$expectedPermissions = DIRECTORY_SEPARATOR == '\\' ? '0666' : '0755';
51+
$this->assertEquals($expectedPermissions, $filePermission);
5152
}
5253

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

5859
$files = new Filesystem;
59-
$filePermisson = $files->chmod($this->tempDir.'/file.txt');
60-
$this->assertEquals('0755', $filePermisson);
60+
$filePermission = $files->chmod($this->tempDir.'/file.txt');
61+
$expectedPermissions = DIRECTORY_SEPARATOR == '\\' ? '0666' : '0755';
62+
$this->assertEquals($expectedPermissions, $filePermission);
6163
}
6264

6365
public function testDeleteRemovesFiles()

0 commit comments

Comments
 (0)
0