Skip to content

Commit

Permalink
[Tests] Improved quality of tests
Browse files Browse the repository at this point in the history
Co-Authored-By: Paweł Niedzielski <Steveb-p@users.noreply.github.com>
  • Loading branch information
alongosz and Steveb-p committed Dec 22, 2022
1 parent ec2feae commit 4a3690f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ final class LocalSiteAccessAwareFilesystemAdapterTest extends TestCase
public static function setUpBeforeClass(): void
{
self::$fileSystem = new Filesystem(new LocalFilesystemAdapter(self::FLYSYSTEM_TEST_DIR));
self::$fileSystem->deleteDirectory('.');
self::$fileSystem->createDirectory('.');
}

Expand Down Expand Up @@ -112,7 +113,7 @@ public function testWriteStream($sourceRelativeFilePath): void
*/
public function testFileSize(string $relativeFilePath): void
{
self::assertEquals(
self::assertSame(
filesize($this->buildAbsolutePath($relativeFilePath)),
$this->adapter->fileSize($relativeFilePath)->fileSize()
);
Expand All @@ -135,7 +136,7 @@ public function testFileExists(string $relativeFilePath): void
*/
public function testLastModified(string $relativeFilePath): void
{
self::assertEquals(
self::assertSame(
filemtime($this->buildAbsolutePath($relativeFilePath)),
$this->adapter->lastModified($relativeFilePath)->lastModified()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,24 @@ abstract class BaseSiteAccessAwarePathPrefixerTest extends TestCase
{
abstract protected function getPrefixer(): PathPrefixerInterface;

/**
* @return iterable<string, array{string, string}>
*/
abstract public function getDataForTestPrefixPath(): iterable;

/**
* @return iterable<string, array{string, string}>
*/
abstract public function getDataForTestPrefixDirectoryPath(): iterable;

/**
* @return iterable<string, array{string, string}>
*/
abstract public function getDataForTestStripPrefixPath(): iterable;

/**
* @return iterable<string, array{string, string}>
*/
public function getDataForTestStripDirectoryPrefix(): iterable
{
// treat file names as directories
Expand All @@ -33,7 +45,7 @@ public function getDataForTestStripDirectoryPrefix(): iterable
/**
* @dataProvider getDataForTestPrefixPath
*/
public function testPrefixPath(string $expectedPrefixedPath, string $path): void
final public function testPrefixPath(string $expectedPrefixedPath, string $path): void
{
self::assertSame(
$expectedPrefixedPath,
Expand All @@ -44,7 +56,7 @@ public function testPrefixPath(string $expectedPrefixedPath, string $path): void
/**
* @dataProvider getDataForTestPrefixDirectoryPath
*/
public function testPrefixDirectoryPath(string $expectedPrefixedPath, string $path): void
final public function testPrefixDirectoryPath(string $expectedPrefixedPath, string $path): void
{
self::assertSame(
$expectedPrefixedPath,
Expand All @@ -55,7 +67,7 @@ public function testPrefixDirectoryPath(string $expectedPrefixedPath, string $pa
/**
* @dataProvider getDataForTestStripPrefixPath
*/
public function testStripPrefix(string $expectedStrippedPath, string $path): void
final public function testStripPrefix(string $expectedStrippedPath, string $path): void
{
self::assertSame(
$expectedStrippedPath,
Expand All @@ -66,7 +78,7 @@ public function testStripPrefix(string $expectedStrippedPath, string $path): voi
/**
* @dataProvider getDataForTestStripDirectoryPrefix
*/
public function testStripDirectoryPrefix(string $expectedStrippedPath, string $path): void
final public function testStripDirectoryPrefix(string $expectedStrippedPath, string $path): void
{
self::assertSame(
$expectedStrippedPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ abstract public function getDataForTestInverseForFile(): iterable;

abstract public function getDataForTestInverseForDirectory(): iterable;

protected function setUp(): void
final protected function setUp(): void
{
$this->innerVisibilityConverterMock = $this->createMock(FlysystemVisibilityConverter::class);
$this->innerVisibilityConverterMock
Expand All @@ -56,7 +56,7 @@ protected function setUp(): void
/**
* @dataProvider getDataForTestForFile
*/
public function testForFile(string $visibility, int $expectedVisibilityFlags): void
final public function testForFile(string $visibility, int $expectedVisibilityFlags): void
{
self::assertSame(
$expectedVisibilityFlags,
Expand All @@ -67,7 +67,7 @@ public function testForFile(string $visibility, int $expectedVisibilityFlags): v
/**
* @dataProvider getDataForTestForDirectory
*/
public function testForDirectory(string $visibility, int $expectedVisibilityFlags): void
final public function testForDirectory(string $visibility, int $expectedVisibilityFlags): void
{
self::assertSame(
$expectedVisibilityFlags,
Expand All @@ -78,7 +78,7 @@ public function testForDirectory(string $visibility, int $expectedVisibilityFlag
/**
* @dataProvider getDataForTestInverseForFile
*/
public function testInverseForFile(int $fileVisibilityFlags, string $expectedVisibility): void
final public function testInverseForFile(int $fileVisibilityFlags, string $expectedVisibility): void
{
self::assertSame(
$expectedVisibility,
Expand All @@ -89,7 +89,7 @@ public function testInverseForFile(int $fileVisibilityFlags, string $expectedVis
/**
* @dataProvider getDataForTestInverseForDirectory
*/
public function testInverseForDirectory(
final public function testInverseForDirectory(
int $directoryVisibilityFlags,
string $expectedVisibility
): void {
Expand All @@ -99,7 +99,7 @@ public function testInverseForDirectory(
);
}

public function testDefaultForDirectories(): void
final public function testDefaultForDirectories(): void
{
$this->innerVisibilityConverterMock
->expects(self::once())
Expand Down

0 comments on commit 4a3690f

Please sign in to comment.