Skip to content

Commit a04d294

Browse files
Merge branch '2.8' into 3.3
* 2.8: Refactoring tests.
2 parents f57d7b0 + 950b9a0 commit a04d294

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

Tests/FilesystemTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testCopyCreatesNewFile()
2626
$this->filesystem->copy($sourceFilePath, $targetFilePath);
2727

2828
$this->assertFileExists($targetFilePath);
29-
$this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath));
29+
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
3030
}
3131

3232
/**
@@ -73,7 +73,7 @@ public function testCopyOverridesExistingFileIfModified()
7373
$this->filesystem->copy($sourceFilePath, $targetFilePath);
7474

7575
$this->assertFileExists($targetFilePath);
76-
$this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath));
76+
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
7777
}
7878

7979
public function testCopyDoesNotOverrideExistingFileByDefault()
@@ -92,7 +92,7 @@ public function testCopyDoesNotOverrideExistingFileByDefault()
9292
$this->filesystem->copy($sourceFilePath, $targetFilePath);
9393

9494
$this->assertFileExists($targetFilePath);
95-
$this->assertEquals('TARGET FILE', file_get_contents($targetFilePath));
95+
$this->assertStringEqualsFile($targetFilePath, 'TARGET FILE');
9696
}
9797

9898
public function testCopyOverridesExistingFileIfForced()
@@ -111,7 +111,7 @@ public function testCopyOverridesExistingFileIfForced()
111111
$this->filesystem->copy($sourceFilePath, $targetFilePath, true);
112112

113113
$this->assertFileExists($targetFilePath);
114-
$this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath));
114+
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
115115
}
116116

117117
/**
@@ -153,7 +153,7 @@ public function testCopyCreatesTargetDirectoryIfItDoesNotExist()
153153

154154
$this->assertTrue(is_dir($targetFileDirectory));
155155
$this->assertFileExists($targetFilePath);
156-
$this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath));
156+
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
157157
}
158158

159159
/**
@@ -169,7 +169,7 @@ public function testCopyForOriginUrlsAndExistingLocalFileDefaultsToCopy()
169169
$this->filesystem->copy($sourceFilePath, $targetFilePath, false);
170170

171171
$this->assertFileExists($targetFilePath);
172-
$this->assertEquals(file_get_contents($sourceFilePath), file_get_contents($targetFilePath));
172+
$this->assertFileEquals($sourceFilePath, $targetFilePath);
173173
}
174174

175175
public function testMkdirCreatesDirectoriesRecursively()
@@ -840,9 +840,9 @@ public function testRemoveSymlink()
840840

841841
$this->filesystem->remove($link);
842842

843-
$this->assertTrue(!is_link($link));
844-
$this->assertTrue(!is_file($link));
845-
$this->assertTrue(!is_dir($link));
843+
$this->assertFalse(is_link($link));
844+
$this->assertFalse(is_file($link));
845+
$this->assertFalse(is_dir($link));
846846
}
847847

848848
public function testSymlinkIsOverwrittenIfPointsToDifferentTarget()
@@ -1457,7 +1457,7 @@ public function testDumpFile()
14571457

14581458
$this->filesystem->dumpFile($filename, 'bar');
14591459
$this->assertFileExists($filename);
1460-
$this->assertSame('bar', file_get_contents($filename));
1460+
$this->assertStringEqualsFile($filename, 'bar');
14611461

14621462
// skip mode check on Windows
14631463
if ('\\' !== DIRECTORY_SEPARATOR) {
@@ -1474,7 +1474,7 @@ public function testDumpFileOverwritesAnExistingFile()
14741474
$this->filesystem->dumpFile($filename, 'bar');
14751475

14761476
$this->assertFileExists($filename);
1477-
$this->assertSame('bar', file_get_contents($filename));
1477+
$this->assertStringEqualsFile($filename, 'bar');
14781478
}
14791479

14801480
public function testDumpFileWithFileScheme()
@@ -1489,7 +1489,7 @@ public function testDumpFileWithFileScheme()
14891489
$this->filesystem->dumpFile($filename, 'bar');
14901490

14911491
$this->assertFileExists($filename);
1492-
$this->assertSame('bar', file_get_contents($filename));
1492+
$this->assertStringEqualsFile($filename, 'bar');
14931493
}
14941494

14951495
public function testDumpFileWithZlibScheme()
@@ -1501,7 +1501,7 @@ public function testDumpFileWithZlibScheme()
15011501

15021502
// Zlib stat uses file:// wrapper so remove scheme
15031503
$this->assertFileExists(str_replace($scheme, '', $filename));
1504-
$this->assertSame('bar', file_get_contents($filename));
1504+
$this->assertStringEqualsFile($filename, 'bar');
15051505
}
15061506

15071507
public function testAppendToFile()
@@ -1518,7 +1518,7 @@ public function testAppendToFile()
15181518
$this->filesystem->appendToFile($filename, 'bar');
15191519

15201520
$this->assertFileExists($filename);
1521-
$this->assertSame('foobar', file_get_contents($filename));
1521+
$this->assertStringEqualsFile($filename, 'bar');
15221522

15231523
// skip mode check on Windows
15241524
if ('\\' !== DIRECTORY_SEPARATOR) {
@@ -1540,7 +1540,7 @@ public function testAppendToFileWithScheme()
15401540
$this->filesystem->appendToFile($filename, 'bar');
15411541

15421542
$this->assertFileExists($filename);
1543-
$this->assertSame('foobar', file_get_contents($filename));
1543+
$this->assertStringEqualsFile($filename, 'foobar');
15441544
}
15451545

15461546
public function testAppendToFileWithZlibScheme()
@@ -1550,12 +1550,12 @@ public function testAppendToFileWithZlibScheme()
15501550
$this->filesystem->dumpFile($filename, 'foo');
15511551

15521552
// Zlib stat uses file:// wrapper so remove it
1553-
$this->assertSame('foo', file_get_contents(str_replace($scheme, '', $filename)));
1553+
$this->assertStringEqualsFile(str_replace($scheme, '', $filename), 'foo');
15541554

15551555
$this->filesystem->appendToFile($filename, 'bar');
15561556

15571557
$this->assertFileExists($filename);
1558-
$this->assertSame('foobar', file_get_contents($filename));
1558+
$this->assertStringEqualsFile($filename, 'foobar');
15591559
}
15601560

15611561
public function testAppendToFileCreateTheFileIfNotExists()
@@ -1576,7 +1576,7 @@ public function testAppendToFileCreateTheFileIfNotExists()
15761576
}
15771577

15781578
$this->assertFileExists($filename);
1579-
$this->assertSame('bar', file_get_contents($filename));
1579+
$this->assertStringEqualsFile($filename, 'bar');
15801580
}
15811581

15821582
public function testDumpKeepsExistingPermissionsWhenOverwritingAnExistingFile()

0 commit comments

Comments
 (0)