Skip to content

Commit

Permalink
Merge pull request Ocramius#136 from michalbundyra/hotfix/phpunit-deps
Browse files Browse the repository at this point in the history
PHPUnit update - use better assertion names, remove deprecations
  • Loading branch information
Ocramius authored Apr 7, 2020
2 parents 4216798 + ff66745 commit ed4df24
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 43 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"composer-plugin-api": "^1.1.0 || ^2.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0.1",
"phpunit/phpunit": "^9.1.1",
"infection/infection": "^0.15.3",
"composer/composer": "^1.9.3 || ^2.0@dev",
"ext-zip": "^1.15.0",
Expand Down
142 changes: 114 additions & 28 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions test/PackageVersionsTest/E2EInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class E2EInstallerTest extends TestCase

private string $tempArtifact;

public function setUp() : void
protected function setUp() : void
{
$this->tempGlobalComposerHome = sys_get_temp_dir() . '/' . uniqid('InstallerTest', true) . '/global';
$this->tempLocalComposerHome = sys_get_temp_dir() . '/' . uniqid('InstallerTest', true) . '/local';
Expand All @@ -61,7 +61,7 @@ public function setUp() : void
putenv('COMPOSER_HOME=' . $this->tempGlobalComposerHome);
}

public function tearDown() : void
protected function tearDown() : void
{
$this->rmDir($this->tempGlobalComposerHome);
$this->rmDir($this->tempLocalComposerHome);
Expand Down Expand Up @@ -108,7 +108,7 @@ public function testGloballyInstalledPluginDoesNotGenerateVersionsForLocalProjec
);

$this->execComposerInDir('update', $this->tempLocalComposerHome);
$this->assertFileNotExists(
self::assertFileDoesNotExist(
$this->tempLocalComposerHome . '/vendor/ocramius/package-versions/src/PackageVersions/Versions.php'
);
}
Expand Down Expand Up @@ -137,13 +137,13 @@ public function testRemovingPluginDoesNotAttemptToGenerateVersions() : void
);

$this->execComposerInDir('update', $this->tempLocalComposerHome);
$this->assertFileExists(
self::assertFileExists(
$this->tempLocalComposerHome . '/vendor/ocramius/package-versions/src/PackageVersions/Versions.php'
);

$this->execComposerInDir('remove ocramius/package-versions', $this->tempLocalComposerHome);

$this->assertFileNotExists(
self::assertFileDoesNotExist(
$this->tempLocalComposerHome . '/vendor/ocramius/package-versions/src/PackageVersions/Versions.php'
);
}
Expand Down Expand Up @@ -173,13 +173,13 @@ public function testRemovingPluginWithNoDevDoesNotAttemptToGenerateVersions() :
);

$this->execComposerInDir('update', $this->tempLocalComposerHome);
$this->assertFileExists(
self::assertFileExists(
$this->tempLocalComposerHome . '/vendor/ocramius/package-versions/src/PackageVersions/Versions.php'
);

$this->execComposerInDir('install --no-dev', $this->tempLocalComposerHome);

$this->assertFileNotExists(
self::assertFileDoesNotExist(
$this->tempLocalComposerHome . '/vendor/ocramius/package-versions/src/PackageVersions/Versions.php'
);
}
Expand Down Expand Up @@ -208,12 +208,12 @@ public function testInstallingPluginWithNoScriptsLeadsToUsableVersionsClass() :
);

$this->execComposerInDir('install --no-scripts', $this->tempLocalComposerHome);
$this->assertFileExists(
self::assertFileExists(
$this->tempLocalComposerHome . '/vendor/ocramius/package-versions/src/PackageVersions/Versions.php'
);

$this->writePackageVersionUsingFile($this->tempLocalComposerHome);
$this->assertPackageVersionsIsUsable($this->tempLocalComposerHome);
self::assertPackageVersionsIsUsable($this->tempLocalComposerHome);
}

private function createPackageVersionsArtifact() : void
Expand Down Expand Up @@ -306,7 +306,7 @@ private function assertPackageVersionsIsUsable(string $directory) : void

self::assertSame(0, $exitCode);
self::assertCount(1, $output);
self::assertRegExp('/^1\\..*\\@[a-f0-9]*$/', $output[0]);
self::assertMatchesRegularExpression('/^1\\..*\\@[a-f0-9]*$/', $output[0]);
}

/**
Expand All @@ -317,7 +317,7 @@ private function execComposerInDir(string $command, string $dir) : array
$currentDir = getcwd();
chdir($dir);
exec(__DIR__ . '/../../vendor/bin/composer ' . $command . ' 2> /dev/null', $output, $exitCode);
$this->assertEquals(0, $exitCode);
self::assertEquals(0, $exitCode);
chdir($currentDir);

return $output;
Expand Down
6 changes: 3 additions & 3 deletions test/PackageVersionsTest/InstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ public function testVersionsAreNotDumpedIfPackageVersionsNotExplicitlyRequired()
$this->io
));

self::assertFileNotExists($expectedPath . '/Versions.php');
self::assertFileDoesNotExist($expectedPath . '/Versions.php');

$this->rmDir($vendorDir);
}
Expand Down Expand Up @@ -705,8 +705,8 @@ public function testVersionsAreNotDumpedIfPackageIsScheduledForRemoval() : void
$this->io
));

self::assertFileNotExists($expectedPath . '/Versions.php');
self::assertFileNotExists($expectedPath . '/Versions.php');
self::assertFileDoesNotExist($expectedPath . '/Versions.php');
self::assertFileDoesNotExist($expectedPath . '/Versions.php');
}

public function testGeneratedVersionFileAccessRights() : void
Expand Down

0 comments on commit ed4df24

Please sign in to comment.