From b4a2124dc2a31c7885a08254243dd974a1bcefd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pluchino?= Date: Thu, 8 Aug 2019 20:47:17 +0200 Subject: [PATCH] Replace call static methods for phpunit --- Tests/Asset/AbstractAssetManagerTest.php | 64 +++++++++---------- Tests/Asset/AssetPackageTest.php | 26 ++++---- Tests/Config/ConfigTest.php | 26 ++++---- Tests/Event/AbstractSolveEventTest.php | 4 +- Tests/Event/GetAssetsEventTest.php | 10 +-- Tests/Event/PostSolveEventTest.php | 2 +- Tests/Fallback/AssetFallbackTest.php | 16 ++--- Tests/Fallback/ComposerFallbackTest.php | 26 ++++---- .../Fixtures/Util/ProcessExecutorMockTest.php | 48 +++++++------- Tests/FoxyTest.php | 18 +++--- Tests/Json/JsonFileTest.php | 22 +++---- Tests/Json/JsonFormatterTest.php | 6 +- Tests/Solver/SolverTest.php | 36 +++++------ Tests/Util/AssetUtilTest.php | 54 ++++++++-------- Tests/Util/ComposerUtilTest.php | 2 +- Tests/Util/ConsoleUtilTest.php | 16 ++--- Tests/Util/PackageUtilTest.php | 14 ++-- 17 files changed, 195 insertions(+), 195 deletions(-) diff --git a/Tests/Asset/AbstractAssetManagerTest.php b/Tests/Asset/AbstractAssetManagerTest.php index aed934e..cce4a47 100644 --- a/Tests/Asset/AbstractAssetManagerTest.php +++ b/Tests/Asset/AbstractAssetManagerTest.php @@ -109,38 +109,38 @@ protected function tearDown() public function testGetName() { - $this->assertSame($this->getValidName(), $this->manager->getName()); + static::assertSame($this->getValidName(), $this->manager->getName()); } public function testGetLockPackageName() { - $this->assertSame($this->getValidLockPackageName(), $this->manager->getLockPackageName()); + static::assertSame($this->getValidLockPackageName(), $this->manager->getLockPackageName()); } public function testGetPackageName() { - $this->assertSame('package.json', $this->manager->getPackageName()); + static::assertSame('package.json', $this->manager->getPackageName()); } public function testHasLockFile() { - $this->assertFalse($this->manager->hasLockFile()); + static::assertFalse($this->manager->hasLockFile()); } public function testIsInstalled() { - $this->assertFalse($this->manager->isInstalled()); + static::assertFalse($this->manager->isInstalled()); } public function testIsUpdatable() { - $this->assertFalse($this->manager->isUpdatable()); + static::assertFalse($this->manager->isUpdatable()); } public function testSetUpdatable() { $res = $this->manager->setUpdatable(false); - $this->assertInstanceOf('Foxy\Asset\AssetManagerInterface', $res); + static::assertInstanceOf('Foxy\Asset\AssetManagerInterface', $res); } /** @@ -178,7 +178,7 @@ public function testValidateWithInstalledManagerAndWithValidVersion() $this->executor->addExpectedValues(0, '42.0.0'); $this->manager->validate(); - $this->assertSame('>=41.0', $this->config->get('manager-version')); + static::assertSame('>=41.0', $this->config->get('manager-version')); } public function testValidateWithInstalledManagerAndWithoutValidationVersion() @@ -186,7 +186,7 @@ public function testValidateWithInstalledManagerAndWithoutValidationVersion() $this->executor->addExpectedValues(0, '42.0.0'); $this->manager->validate(); - $this->assertNull($this->config->get('manager-version')); + static::assertNull($this->config->get('manager-version')); } public function testAddDependenciesForInstallCommand() @@ -203,18 +203,18 @@ public function testAddDependenciesForInstallCommand() ); /** @var \PHPUnit_Framework_MockObject_MockObject|RootPackageInterface $rootPackage */ $rootPackage = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock(); - $rootPackage->expects($this->any()) + $rootPackage->expects(static::any()) ->method('getLicense') ->willReturn(array()) ; - $this->assertFalse($this->manager->isInstalled()); - $this->assertFalse($this->manager->isUpdatable()); + static::assertFalse($this->manager->isInstalled()); + static::assertFalse($this->manager->isUpdatable()); $assetPackage = $this->manager->addDependencies($rootPackage, $allDependencies); - $this->assertInstanceOf('Foxy\Asset\AssetPackageInterface', $assetPackage); + static::assertInstanceOf('Foxy\Asset\AssetPackageInterface', $assetPackage); - $this->assertEquals($expectedPackage, $assetPackage->getPackage()); + static::assertEquals($expectedPackage, $assetPackage->getPackage()); } public function testAddDependenciesForUpdateCommand() @@ -240,26 +240,26 @@ public function testAddDependenciesForUpdateCommand() $jsonFile = new JsonFile($this->cwd.'/package.json'); /** @var \PHPUnit_Framework_MockObject_MockObject|RootPackageInterface $rootPackage */ $rootPackage = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock(); - $rootPackage->expects($this->any()) + $rootPackage->expects(static::any()) ->method('getLicense') ->willReturn(array()) ; $nodeModulePath = $this->cwd.ltrim(AbstractAssetManager::NODE_MODULES_PATH, '.'); $jsonFile->write($package); - $this->assertFileExists($jsonFile->getPath()); + static::assertFileExists($jsonFile->getPath()); $this->sfs->mkdir($nodeModulePath); - $this->assertFileExists($nodeModulePath); + static::assertFileExists($nodeModulePath); $lockFilePath = $this->cwd.\DIRECTORY_SEPARATOR.$this->manager->getLockPackageName(); file_put_contents($lockFilePath, '{}'); - $this->assertFileExists($lockFilePath); - $this->assertTrue($this->manager->isInstalled()); - $this->assertTrue($this->manager->isUpdatable()); + static::assertFileExists($lockFilePath); + static::assertTrue($this->manager->isInstalled()); + static::assertTrue($this->manager->isUpdatable()); $assetPackage = $this->manager->addDependencies($rootPackage, $allDependencies); - $this->assertInstanceOf('Foxy\Asset\AssetPackageInterface', $assetPackage); + static::assertInstanceOf('Foxy\Asset\AssetPackageInterface', $assetPackage); - $this->assertEquals($expectedPackage, $assetPackage->getPackage()); + static::assertEquals($expectedPackage, $assetPackage->getPackage()); } public function testRunWithDisableOption() @@ -268,7 +268,7 @@ public function testRunWithDisableOption() 'run-asset-manager' => false, )); - $this->assertSame(0, $this->getManager()->run()); + static::assertSame(0, $this->getManager()->run()); } public function getRunData() @@ -304,29 +304,29 @@ public function testRunForInstallCommand($expectedRes, $action) file_put_contents($this->cwd.\DIRECTORY_SEPARATOR.$this->manager->getPackageName(), '{}'); $nodeModulePath = $this->cwd.ltrim(AbstractAssetManager::NODE_MODULES_PATH, '.'); $this->sfs->mkdir($nodeModulePath); - $this->assertFileExists($nodeModulePath); + static::assertFileExists($nodeModulePath); $lockFilePath = $this->cwd.\DIRECTORY_SEPARATOR.$this->manager->getLockPackageName(); file_put_contents($lockFilePath, '{}'); - $this->assertFileExists($lockFilePath); - $this->assertTrue($this->manager->isInstalled()); - $this->assertTrue($this->manager->isUpdatable()); + static::assertFileExists($lockFilePath); + static::assertTrue($this->manager->isInstalled()); + static::assertTrue($this->manager->isUpdatable()); } if (0 === $expectedRes) { - $this->fallback->expects($this->never()) + $this->fallback->expects(static::never()) ->method('restore') ; } else { - $this->fallback->expects($this->once()) + $this->fallback->expects(static::once()) ->method('restore') ; } $this->executor->addExpectedValues($expectedRes, 'ASSET MANAGER OUTPUT'); - $this->assertSame($expectedRes, $this->getManager()->run()); - $this->assertSame($expectedCommand, $this->executor->getLastCommand()); - $this->assertSame('ASSET MANAGER OUTPUT', $this->executor->getLastOutput()); + static::assertSame($expectedRes, $this->getManager()->run()); + static::assertSame($expectedCommand, $this->executor->getLastCommand()); + static::assertSame('ASSET MANAGER OUTPUT', $this->executor->getLastOutput()); } /** diff --git a/Tests/Asset/AssetPackageTest.php b/Tests/Asset/AssetPackageTest.php index 27e9041..328267b 100644 --- a/Tests/Asset/AssetPackageTest.php +++ b/Tests/Asset/AssetPackageTest.php @@ -57,7 +57,7 @@ protected function setUp() ->getMock() ; - $this->rootPackage->expects($this->any()) + $this->rootPackage->expects(static::any()) ->method('getLicense') ->willReturn(array()) ; @@ -86,7 +86,7 @@ public function testGetPackageWithExistingFile() $assetPackage = new AssetPackage($this->rootPackage, $this->jsonFile); - $this->assertSame($package, $assetPackage->getPackage()); + static::assertSame($package, $assetPackage->getPackage()); } public function testWrite() @@ -95,12 +95,12 @@ public function testWrite() 'name' => '@foo/bar', ); - $this->jsonFile->expects($this->once()) + $this->jsonFile->expects(static::once()) ->method('exists') ->willReturn(false) ; - $this->jsonFile->expects($this->once()) + $this->jsonFile->expects(static::once()) ->method('write') ->with($package) ; @@ -159,14 +159,14 @@ public function testInjectionOfRequiredKeys(array $expected, array $package, $li $this->addPackageFile($package); $this->rootPackage = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock(); - $this->rootPackage->expects($this->any()) + $this->rootPackage->expects(static::any()) ->method('getLicense') ->willReturn(array($license)) ; $assetPackage = new AssetPackage($this->rootPackage, $this->jsonFile); - $this->assertEquals($expected, $assetPackage->getPackage()); + static::assertEquals($expected, $assetPackage->getPackage()); } public function testGetInstalledDependencies() @@ -186,7 +186,7 @@ public function testGetInstalledDependencies() $assetPackage = new AssetPackage($this->rootPackage, $this->jsonFile); - $this->assertEquals($expected, $assetPackage->getInstalledDependencies()); + static::assertEquals($expected, $assetPackage->getInstalledDependencies()); } public function testAddNewDependencies() @@ -221,8 +221,8 @@ public function testAddNewDependencies() $assetPackage = new AssetPackage($this->rootPackage, $this->jsonFile); $existing = $assetPackage->addNewDependencies($dependencies); - $this->assertSame($expected, $assetPackage->getPackage()); - $this->assertSame($expectedExisting, $existing); + static::assertSame($expected, $assetPackage->getPackage()); + static::assertSame($expectedExisting, $existing); } public function testRemoveUnusedDependencies() @@ -249,7 +249,7 @@ public function testRemoveUnusedDependencies() $assetPackage = new AssetPackage($this->rootPackage, $this->jsonFile); $assetPackage->removeUnusedDependencies($dependencies); - $this->assertEquals($expected, $assetPackage->getPackage()); + static::assertEquals($expected, $assetPackage->getPackage()); } /** @@ -263,17 +263,17 @@ protected function addPackageFile(array $package, $contentString = null) $filename = $this->cwd.'/package.json'; $contentString = null !== $contentString ? $contentString : json_encode($package); - $this->jsonFile->expects($this->any()) + $this->jsonFile->expects(static::any()) ->method('exists') ->willReturn(true) ; - $this->jsonFile->expects($this->any()) + $this->jsonFile->expects(static::any()) ->method('getPath') ->willReturn($filename) ; - $this->jsonFile->expects($this->any()) + $this->jsonFile->expects(static::any()) ->method('read') ->willReturn($package) ; diff --git a/Tests/Config/ConfigTest.php b/Tests/Config/ConfigTest.php index 8f632e9..945dd11 100644 --- a/Tests/Config/ConfigTest.php +++ b/Tests/Config/ConfigTest.php @@ -53,12 +53,12 @@ protected function setUp() $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $this->package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock(); - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getPackage') ->willReturn($this->package) ; - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getConfig') ->willReturn($this->composerConfig) ; @@ -104,19 +104,19 @@ public function testGetConfig($key, $expected, $default = null, $env = null, arr } $globalPath = realpath(__DIR__.'/../Fixtures/package/global'); - $this->composerConfig->expects($this->any()) + $this->composerConfig->expects(static::any()) ->method('has') ->with('home') ->willReturn(true) ; - $this->composerConfig->expects($this->any()) + $this->composerConfig->expects(static::any()) ->method('get') ->with('home') ->willReturn($globalPath) ; - $this->package->expects($this->any()) + $this->package->expects(static::any()) ->method('getConfig') ->willReturn(array( 'foxy' => array( @@ -136,16 +136,16 @@ public function testGetConfig($key, $expected, $default = null, $env = null, arr ; if (0 === strpos($key, 'global-')) { - $this->io->expects($this->atLeast(2)) + $this->io->expects(static::atLeast(2)) ->method('isDebug') ->willReturn(true) ; - $this->io->expects($this->at(1)) + $this->io->expects(static::at(1)) ->method('writeError') ->with(sprintf('Loading Foxy config in file %s/composer.json', $globalPath)) ; - $this->io->expects($this->at(3)) + $this->io->expects(static::at(3)) ->method('writeError') ->with(sprintf('Loading Foxy config in file %s/config.json', $globalPath)) ; @@ -158,12 +158,12 @@ public function testGetConfig($key, $expected, $default = null, $env = null, arr if (null !== $env) { $envKey = substr($env, 0, strpos($env, '=')); putenv($envKey); - $this->assertFalse(getenv($envKey)); + static::assertFalse(getenv($envKey)); } - $this->assertSame($expected, $value); + static::assertSame($expected, $value); // test cache - $this->assertSame($expected, $config->get($key, $default)); + static::assertSame($expected, $config->get($key, $default)); } public function getDataForGetArrayConfig() @@ -187,7 +187,7 @@ public function testGetArrayConfig($key, array $expected, array $default, array { $config = ConfigBuilder::build($this->composer, $defaults, $this->io); - $this->assertSame($expected, $config->getArray($key, $default)); + static::assertSame($expected, $config->getArray($key, $default)); } /** @@ -207,7 +207,7 @@ public function testGetEnvConfigWithInvalidJson() } putenv('FOXY__ENV_JSON'); - $this->assertFalse(getenv('FOXY__ENV_JSON')); + static::assertFalse(getenv('FOXY__ENV_JSON')); if (null === $ex) { throw new \Exception('The expected exception was not thrown'); diff --git a/Tests/Event/AbstractSolveEventTest.php b/Tests/Event/AbstractSolveEventTest.php index 88ae8de..437bc86 100644 --- a/Tests/Event/AbstractSolveEventTest.php +++ b/Tests/Event/AbstractSolveEventTest.php @@ -55,12 +55,12 @@ abstract public function getEvent(); public function testGetAssetDir() { $event = $this->getEvent(); - $this->assertSame($this->assetDir, $event->getAssetDir()); + static::assertSame($this->assetDir, $event->getAssetDir()); } public function testGetPackages() { $event = $this->getEvent(); - $this->assertSame($this->packages, $event->getPackages()); + static::assertSame($this->packages, $event->getPackages()); } } diff --git a/Tests/Event/GetAssetsEventTest.php b/Tests/Event/GetAssetsEventTest.php index fd007a4..4e83645 100644 --- a/Tests/Event/GetAssetsEventTest.php +++ b/Tests/Event/GetAssetsEventTest.php @@ -42,7 +42,7 @@ public function getEvent() public function testHasAsset() { $event = $this->getEvent(); - $this->assertTrue($event->hasAsset('@composer-asset/foo--bar')); + static::assertTrue($event->hasAsset('@composer-asset/foo--bar')); } public function testAddAsset() @@ -51,15 +51,15 @@ public function testAddAsset() $assetPackagePath = 'file:./vendor/foxy/composer-asset/bar/foo'; $event = $this->getEvent(); - $this->assertFalse($event->hasAsset($assetPackageName)); + static::assertFalse($event->hasAsset($assetPackageName)); $event->addAsset($assetPackageName, $assetPackagePath); - $this->assertTrue($event->hasAsset($assetPackageName)); + static::assertTrue($event->hasAsset($assetPackageName)); } public function testGetAssets() { $event = $this->getEvent(); - $this->assertSame($this->assets, $event->getAssets()); + static::assertSame($this->assets, $event->getAssets()); $expectedAssets = array( '@composer-asset/foo--bar' => 'file:./vendor/foxy/composer-asset/foo/bar', @@ -67,6 +67,6 @@ public function testGetAssets() ); $event->addAsset('@composer-asset/bar--foo', 'file:./vendor/foxy/composer-asset/bar/foo'); - $this->assertSame($expectedAssets, $event->getAssets()); + static::assertSame($expectedAssets, $event->getAssets()); } } diff --git a/Tests/Event/PostSolveEventTest.php b/Tests/Event/PostSolveEventTest.php index de7e5b8..3373e29 100644 --- a/Tests/Event/PostSolveEventTest.php +++ b/Tests/Event/PostSolveEventTest.php @@ -35,6 +35,6 @@ public function getEvent() public function testGetRunResult() { $event = $this->getEvent(); - $this->assertSame(42, $event->getRunResult()); + static::assertSame(42, $event->getRunResult()); } } diff --git a/Tests/Fallback/AssetFallbackTest.php b/Tests/Fallback/AssetFallbackTest.php index 8c506ff..d24a8dc 100644 --- a/Tests/Fallback/AssetFallbackTest.php +++ b/Tests/Fallback/AssetFallbackTest.php @@ -112,7 +112,7 @@ public function testSave($withPackageFile) file_put_contents($this->cwd.'/package.json', '{}'); } - $this->assertInstanceOf('Foxy\Fallback\AssetFallback', $this->assetFallback->save()); + static::assertInstanceOf('Foxy\Fallback\AssetFallback', $this->assetFallback->save()); } public function testRestoreWithDisableOption() @@ -122,11 +122,11 @@ public function testRestoreWithDisableOption() )); $assetFallback = new AssetFallback($this->io, $config, 'package.json', $this->fs); - $this->io->expects($this->never()) + $this->io->expects(static::never()) ->method('write') ; - $this->fs->expects($this->never()) + $this->fs->expects(static::never()) ->method('remove') ; @@ -155,11 +155,11 @@ public function testRestore($withPackageFile) file_put_contents($path, $content); } - $this->io->expects($this->once()) + $this->io->expects(static::once()) ->method('write') ; - $this->fs->expects($this->once()) + $this->fs->expects(static::once()) ->method('remove') ->with('package.json') ; @@ -168,10 +168,10 @@ public function testRestore($withPackageFile) $this->assetFallback->restore(); if ($withPackageFile) { - $this->assertFileExists($path); - $this->assertSame($content, file_get_contents($path)); + static::assertFileExists($path); + static::assertSame($content, file_get_contents($path)); } else { - $this->assertFileNotExists($path); + static::assertFileNotExists($path); } } } diff --git a/Tests/Fallback/ComposerFallbackTest.php b/Tests/Fallback/ComposerFallbackTest.php index ee4942c..33ad60e 100644 --- a/Tests/Fallback/ComposerFallbackTest.php +++ b/Tests/Fallback/ComposerFallbackTest.php @@ -135,13 +135,13 @@ public function getSaveData() public function testSave($withLockFile) { $rm = $this->getMockBuilder('Composer\Repository\RepositoryManager')->disableOriginalConstructor()->getMock(); - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getRepositoryManager') ->willReturn($rm) ; $im = $this->getMockBuilder('Composer\Installer\InstallationManager')->disableOriginalConstructor()->getMock(); - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getInstallationManager') ->willReturn($im) ; @@ -152,7 +152,7 @@ public function testSave($withLockFile) file_put_contents($this->cwd.'/composer.lock', json_encode(array('content-hash' => 'HASH_VALUE'))); } - $this->assertInstanceOf('Foxy\Fallback\ComposerFallback', $this->composerFallback->save()); + static::assertInstanceOf('Foxy\Fallback\ComposerFallback', $this->composerFallback->save()); } public function testRestoreWithDisableOption() @@ -162,7 +162,7 @@ public function testRestoreWithDisableOption() )); $composerFallback = new ComposerFallback($this->composer, $this->io, $config, $this->input); - $this->io->expects($this->never()) + $this->io->expects(static::never()) ->method('write') ; @@ -203,34 +203,34 @@ public function testRestore(array $packages) ))); $rm = $this->getMockBuilder('Composer\Repository\RepositoryManager')->disableOriginalConstructor()->getMock(); - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getRepositoryManager') ->willReturn($rm) ; $im = $this->getMockBuilder('Composer\Installer\InstallationManager')->disableOriginalConstructor()->getMock(); - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getInstallationManager') ->willReturn($im) ; - $this->io->expects($this->once()) + $this->io->expects(static::once()) ->method('write') ; $locker = new Locker($this->io, new JsonFile($lockFile, null, $this->io), $rm, $im, file_get_contents($composerFile)); - $this->composer->expects($this->atLeastOnce()) + $this->composer->expects(static::atLeastOnce()) ->method('getLocker') ->willReturn($locker) ; $config = $this->getMockBuilder('Composer\Config')->disableOriginalConstructor()->setMethods(array('get'))->getMock(); - $this->composer->expects($this->atLeastOnce()) + $this->composer->expects(static::atLeastOnce()) ->method('getConfig') ->willReturn($config) ; - $config->expects($this->atLeastOnce()) + $config->expects(static::atLeastOnce()) ->method('get') ->willReturnCallback(function ($key, $default = null) use ($vendorDir) { return 'vendor-dir' === $key ? $vendorDir : $default; @@ -238,16 +238,16 @@ public function testRestore(array $packages) ; if (0 === \count($packages)) { - $this->fs->expects($this->once()) + $this->fs->expects(static::once()) ->method('remove') ->with($vendorDir) ; } else { - $this->fs->expects($this->never()) + $this->fs->expects(static::never()) ->method('remove') ; - $this->installer->expects($this->once()) + $this->installer->expects(static::once()) ->method('run') ; } diff --git a/Tests/Fixtures/Util/ProcessExecutorMockTest.php b/Tests/Fixtures/Util/ProcessExecutorMockTest.php index 9c2cd60..c00cd35 100644 --- a/Tests/Fixtures/Util/ProcessExecutorMockTest.php +++ b/Tests/Fixtures/Util/ProcessExecutorMockTest.php @@ -28,19 +28,19 @@ public function testExecuteWithoutExpectedValues() $executor->execute('run', $output); - $this->assertSame('run', $executor->getExecutedCommand(0)); - $this->assertNull($executor->getExecutedReturnedCode(0)); - $this->assertNull($executor->getExecutedOutput(0)); + static::assertSame('run', $executor->getExecutedCommand(0)); + static::assertNull($executor->getExecutedReturnedCode(0)); + static::assertNull($executor->getExecutedOutput(0)); - $this->assertNull($executor->getExecutedCommand(1)); - $this->assertNull($executor->getExecutedReturnedCode(1)); - $this->assertNull($executor->getExecutedOutput(1)); + static::assertNull($executor->getExecutedCommand(1)); + static::assertNull($executor->getExecutedReturnedCode(1)); + static::assertNull($executor->getExecutedOutput(1)); - $this->assertSame('run', $executor->getLastCommand()); - $this->assertNull($executor->getLastReturnedCode()); - $this->assertNull($executor->getLastOutput()); + static::assertSame('run', $executor->getLastCommand()); + static::assertNull($executor->getLastReturnedCode()); + static::assertNull($executor->getLastOutput()); - $this->assertNull($output); + static::assertNull($output); } public function testExecuteWithExpectedValues() @@ -53,23 +53,23 @@ public function testExecuteWithExpectedValues() $executor->execute('run', $output); $executor->execute('run2', $output2); - $this->assertSame('run', $executor->getExecutedCommand(0)); - $this->assertSame(0, $executor->getExecutedReturnedCode(0)); - $this->assertSame('TEST', $executor->getExecutedOutput(0)); + static::assertSame('run', $executor->getExecutedCommand(0)); + static::assertSame(0, $executor->getExecutedReturnedCode(0)); + static::assertSame('TEST', $executor->getExecutedOutput(0)); - $this->assertSame('run2', $executor->getExecutedCommand(1)); - $this->assertSame(42, $executor->getExecutedReturnedCode(1)); - $this->assertSame('TEST 2', $executor->getExecutedOutput(1)); + static::assertSame('run2', $executor->getExecutedCommand(1)); + static::assertSame(42, $executor->getExecutedReturnedCode(1)); + static::assertSame('TEST 2', $executor->getExecutedOutput(1)); - $this->assertNull($executor->getExecutedCommand(2)); - $this->assertNull($executor->getExecutedReturnedCode(2)); - $this->assertNull($executor->getExecutedOutput(2)); + static::assertNull($executor->getExecutedCommand(2)); + static::assertNull($executor->getExecutedReturnedCode(2)); + static::assertNull($executor->getExecutedOutput(2)); - $this->assertSame('run2', $executor->getLastCommand()); - $this->assertSame(42, $executor->getLastReturnedCode()); - $this->assertSame('TEST 2', $executor->getLastOutput()); + static::assertSame('run2', $executor->getLastCommand()); + static::assertSame(42, $executor->getLastReturnedCode()); + static::assertSame('TEST 2', $executor->getLastOutput()); - $this->assertSame('TEST', $output); - $this->assertSame('TEST 2', $output2); + static::assertSame('TEST', $output); + static::assertSame('TEST 2', $output2); } } diff --git a/Tests/FoxyTest.php b/Tests/FoxyTest.php index e6c8d6e..6bd1914 100644 --- a/Tests/FoxyTest.php +++ b/Tests/FoxyTest.php @@ -55,24 +55,24 @@ protected function setUp() $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $this->package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock(); - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getPackage') ->willReturn($this->package) ; - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getConfig') ->willReturn($this->composerConfig) ; $rm = $this->getMockBuilder('Composer\Repository\RepositoryManager')->disableOriginalConstructor()->getMock(); - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getRepositoryManager') ->willReturn($rm) ; $im = $this->getMockBuilder('Composer\Installer\InstallationManager')->disableOriginalConstructor()->getMock(); - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getInstallationManager') ->willReturn($im) ; @@ -80,7 +80,7 @@ protected function setUp() public function testGetSubscribedEvents() { - $this->assertCount(3, Foxy::getSubscribedEvents()); + static::assertCount(3, Foxy::getSubscribedEvents()); } public function testActivate() @@ -88,7 +88,7 @@ public function testActivate() $foxy = new Foxy(); $foxy->activate($this->composer, $this->io); $foxy->init(); - $this->assertTrue(true); + static::assertTrue(true); } /** @@ -97,7 +97,7 @@ public function testActivate() */ public function testActivateWithInvalidManager() { - $this->package->expects($this->any()) + $this->package->expects(static::any()) ->method('getConfig') ->willReturn(array( 'foxy' => array( @@ -129,11 +129,11 @@ public function testSolveAssets($eventName, $expectedUpdatable) $event = new Event($eventName, $this->composer, $this->io); /** @var \PHPUnit_Framework_MockObject_MockObject|SolverInterface $solver */ $solver = $this->getMockBuilder('Foxy\Solver\SolverInterface')->getMock(); - $solver->expects($this->once()) + $solver->expects(static::once()) ->method('setUpdatable') ->with($expectedUpdatable) ; - $solver->expects($this->once()) + $solver->expects(static::once()) ->method('solve') ->with($this->composer, $this->io) ; diff --git a/Tests/Json/JsonFileTest.php b/Tests/Json/JsonFileTest.php index 70f4704..848f4e2 100644 --- a/Tests/Json/JsonFileTest.php +++ b/Tests/Json/JsonFileTest.php @@ -65,7 +65,7 @@ public function testGetArrayKeysWithoutFile() $filename = './package.json'; $jsonFile = new JsonFile($filename); - $this->assertSame(array(), $jsonFile->getArrayKeys()); + static::assertSame(array(), $jsonFile->getArrayKeys()); } public function testGetArrayKeysWithExistingFile() @@ -84,11 +84,11 @@ public function testGetArrayKeysWithExistingFile() $filename = './package.json'; file_put_contents($filename, $content); - $this->assertFileExists($filename); + static::assertFileExists($filename); $jsonFile = new JsonFile($filename); - $this->assertSame($expected, $jsonFile->getArrayKeys()); + static::assertSame($expected, $jsonFile->getArrayKeys()); } public function testGetIndentWithoutFile() @@ -96,7 +96,7 @@ public function testGetIndentWithoutFile() $filename = './package.json'; $jsonFile = new JsonFile($filename); - $this->assertSame(4, $jsonFile->getIndent()); + static::assertSame(4, $jsonFile->getIndent()); } public function testGetIndentWithExistingFile() @@ -109,11 +109,11 @@ public function testGetIndentWithExistingFile() $filename = './package.json'; file_put_contents($filename, $content); - $this->assertFileExists($filename); + static::assertFileExists($filename); $jsonFile = new JsonFile($filename); - $this->assertSame(2, $jsonFile->getIndent()); + static::assertSame(2, $jsonFile->getIndent()); } public function testWriteWithoutFile() @@ -133,10 +133,10 @@ public function testWriteWithoutFile() $jsonFile = new JsonFile($filename); $jsonFile->write($data); - $this->assertFileExists($filename); + static::assertFileExists($filename); $content = file_get_contents($filename); - $this->assertSame($expected, $content); + static::assertSame($expected, $content); } public function testWriteWithExistingFile() @@ -161,16 +161,16 @@ public function testWriteWithExistingFile() $filename = './package.json'; file_put_contents($filename, $content); - $this->assertFileExists($filename); + static::assertFileExists($filename); $jsonFile = new JsonFile($filename); $data = (array) $jsonFile->read(); $data['private'] = true; $jsonFile->write($data); - $this->assertFileExists($filename); + static::assertFileExists($filename); $content = file_get_contents($filename); - $this->assertSame($expected, $content); + static::assertSame($expected, $content); } } diff --git a/Tests/Json/JsonFormatterTest.php b/Tests/Json/JsonFormatterTest.php index a7334a8..c93b95d 100644 --- a/Tests/Json/JsonFormatterTest.php +++ b/Tests/Json/JsonFormatterTest.php @@ -35,7 +35,7 @@ public function testGetArrayKeys() 'contributors', ); - $this->assertSame($expected, JsonFormatter::getArrayKeys($content)); + static::assertSame($expected, JsonFormatter::getArrayKeys($content)); } public function testGetIndent() @@ -47,7 +47,7 @@ public function testGetIndent() } JSON; - $this->assertSame(2, JsonFormatter::getIndent($content)); + static::assertSame(2, JsonFormatter::getIndent($content)); } public function testFormat() @@ -72,6 +72,6 @@ public function testFormat() ); $content = json_encode($data); - $this->assertSame($expected, JsonFormatter::format($content, array('contributors'), 2)); + static::assertSame($expected, JsonFormatter::format($content, array('contributors'), 2)); } } diff --git a/Tests/Solver/SolverTest.php b/Tests/Solver/SolverTest.php index c35cfff..385ef60 100644 --- a/Tests/Solver/SolverTest.php +++ b/Tests/Solver/SolverTest.php @@ -133,33 +133,33 @@ protected function setUp() $rm = new RepositoryManager($this->io, $this->composerConfig); $rm->setLocalRepository($this->localRepo); - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getRepositoryManager') ->willReturn($rm) ; - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getInstallationManager') ->willReturn($this->im) ; - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getPackage') ->willReturn($this->package) ; - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getConfig') ->willReturn($this->composerConfig) ; - $this->composer->expects($this->any()) + $this->composer->expects(static::any()) ->method('getEventDispatcher') ->willReturn(new EventDispatcher($this->composer, $this->io)) ; $sfs = $this->sfs; - $this->fs->expects($this->any()) + $this->fs->expects(static::any()) ->method('findShortestPath') ->willReturnCallback(function ($from, $to) use ($sfs) { return rtrim($sfs->makePathRelative($to, $from), '/'); @@ -193,7 +193,7 @@ protected function tearDown() public function testSetUpdatable() { - $this->manager->expects($this->once()) + $this->manager->expects(static::once()) ->method('setUpdatable') ->with(false) ; @@ -208,7 +208,7 @@ public function testSolveWithDisableOption() )); $solver = new Solver($this->manager, $config, $this->fs); - $this->manager->expects($this->never()) + $this->manager->expects(static::never()) ->method('run') ; @@ -232,17 +232,17 @@ public function testSolve($resRunManager) { /** @var PackageInterface|\PHPUnit_Framework_MockObject_MockObject $requirePackage */ $requirePackage = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); - $requirePackage->expects($this->any()) + $requirePackage->expects(static::any()) ->method('getName') ->willReturn('foo/bar') ; - $requirePackage->expects($this->any()) + $requirePackage->expects(static::any()) ->method('getRequires') ->willReturn(array( new Link('root/package', 'foxy/foxy'), )) ; - $requirePackage->expects($this->any()) + $requirePackage->expects(static::any()) ->method('getDevRequires') ->willReturn(array()) ; @@ -253,31 +253,31 @@ public function testSolve($resRunManager) $requirePackagePath = $this->cwd.'/vendor/foo/bar'; - $this->im->expects($this->once()) + $this->im->expects(static::once()) ->method('getInstallPath') ->willReturn($requirePackagePath) ; - $this->manager->expects($this->exactly(2)) + $this->manager->expects(static::exactly(2)) ->method('getPackageName') ->willReturn('package.json') ; - $this->manager->expects($this->once()) + $this->manager->expects(static::once()) ->method('addDependencies') ; - $this->manager->expects($this->once()) + $this->manager->expects(static::once()) ->method('run') ->willReturn($resRunManager) ; if (0 === $resRunManager) { - $this->composerFallback->expects($this->never()) + $this->composerFallback->expects(static::never()) ->method('restore') ; } else { - $this->composerFallback->expects($this->once()) + $this->composerFallback->expects(static::once()) ->method('restore') ; @@ -299,7 +299,7 @@ public function testSolve($resRunManager) */ protected function addInstalledPackages(array $packages = array()) { - $this->localRepo->expects($this->any()) + $this->localRepo->expects(static::any()) ->method('getCanonicalPackages') ->willReturn($packages) ; diff --git a/Tests/Util/AssetUtilTest.php b/Tests/Util/AssetUtilTest.php index 6d8d81b..c334f4d 100644 --- a/Tests/Util/AssetUtilTest.php +++ b/Tests/Util/AssetUtilTest.php @@ -59,12 +59,12 @@ public function testGetName() { /** @var PackageInterface|\PHPUnit_Framework_MockObject_MockObject $package */ $package = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); - $package->expects($this->once()) + $package->expects(static::once()) ->method('getName') ->willReturn('foo/bar') ; - $this->assertSame('@composer-asset/foo--bar', AssetUtil::getName($package)); + static::assertSame('@composer-asset/foo--bar', AssetUtil::getName($package)); } public function testGetPathWithoutRequiredFoxy() @@ -75,7 +75,7 @@ public function testGetPathWithoutRequiredFoxy() ->setMethods(array('getInstallPath')) ->getMock() ; - $installationManager->expects($this->never()) + $installationManager->expects(static::never()) ->method('getInstallPath') ; @@ -87,18 +87,18 @@ public function testGetPathWithoutRequiredFoxy() /** @var PackageInterface|\PHPUnit_Framework_MockObject_MockObject $package */ $package = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); - $package->expects($this->once()) + $package->expects(static::once()) ->method('getRequires') ->willReturn(array()) ; - $package->expects($this->once()) + $package->expects(static::once()) ->method('getDevRequires') ->willReturn(array()) ; $res = AssetUtil::getPath($installationManager, $assetManager, $package); - $this->assertNull($res); + static::assertNull($res); } public function getRequiresData() @@ -126,7 +126,7 @@ public function testGetPathWithRequiredFoxy(array $requires, array $devRequires, ->setMethods(array('getInstallPath')) ->getMock() ; - $installationManager->expects($this->once()) + $installationManager->expects(static::once()) ->method('getInstallPath') ->willReturn($this->cwd) ; @@ -139,17 +139,17 @@ public function testGetPathWithRequiredFoxy(array $requires, array $devRequires, /** @var PackageInterface|\PHPUnit_Framework_MockObject_MockObject $package */ $package = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); - $package->expects($this->once()) + $package->expects(static::once()) ->method('getRequires') ->willReturn($requires) ; if (0 === \count($devRequires)) { - $package->expects($this->never()) + $package->expects(static::never()) ->method('getDevRequires') ; } else { - $package->expects($this->once()) + $package->expects(static::once()) ->method('getDevRequires') ->willReturn($devRequires) ; @@ -165,7 +165,7 @@ public function testGetPathWithRequiredFoxy(array $requires, array $devRequires, $res = AssetUtil::getPath($installationManager, $assetManager, $package); - $this->assertSame($expectedFilename, $res); + static::assertSame($expectedFilename, $res); } public function getExtraData() @@ -194,7 +194,7 @@ public function testGetPathWithExtraActivation($withExtra, $fileExists = false) ; if ($withExtra && $fileExists) { - $installationManager->expects($this->once()) + $installationManager->expects(static::once()) ->method('getInstallPath') ->willReturn($this->cwd) ; @@ -208,17 +208,17 @@ public function testGetPathWithExtraActivation($withExtra, $fileExists = false) /** @var PackageInterface|\PHPUnit_Framework_MockObject_MockObject $package */ $package = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); - $package->expects($this->any()) + $package->expects(static::any()) ->method('getRequires') ->willReturn(array()) ; - $package->expects($this->any()) + $package->expects(static::any()) ->method('getDevRequires') ->willReturn(array()) ; - $package->expects($this->atLeastOnce()) + $package->expects(static::atLeastOnce()) ->method('getExtra') ->willReturn(array( 'foxy' => $withExtra, @@ -235,19 +235,19 @@ public function testGetPathWithExtraActivation($withExtra, $fileExists = false) $res = AssetUtil::getPath($installationManager, $assetManager, $package); - $this->assertSame($expectedFilename, $res); + static::assertSame($expectedFilename, $res); } public function testHasNoPluginDependency() { - $this->assertFalse(AssetUtil::hasPluginDependency(array( + static::assertFalse(AssetUtil::hasPluginDependency(array( new Link('root/package', 'foo/bar'), ))); } public function testHasPluginDependency() { - $this->assertTrue(AssetUtil::hasPluginDependency(array( + static::assertTrue(AssetUtil::hasPluginDependency(array( new Link('root/package', 'foo/bar'), new Link('root/package', 'foxy/foxy'), new Link('root/package', 'bar/foo'), @@ -287,13 +287,13 @@ public function testIsProjectActivation($packageName, $expected) /** @var PackageInterface|\PHPUnit_Framework_MockObject_MockObject $package */ $package = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); - $package->expects($this->once()) + $package->expects(static::once()) ->method('getName') ->willReturn($packageName) ; $res = AssetUtil::isProjectActivation($package, $enablePackages); - $this->assertSame($expected, $res); + static::assertSame($expected, $res); } public function getIsProjectActivationWithWildcardData() @@ -326,13 +326,13 @@ public function testIsProjectActivationWithWildcardPattern($packageName, $expect /** @var PackageInterface|\PHPUnit_Framework_MockObject_MockObject $package */ $package = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); - $package->expects($this->once()) + $package->expects(static::once()) ->method('getName') ->willReturn($packageName) ; $res = AssetUtil::isProjectActivation($package, $enablePackages); - $this->assertSame($expected, $res); + static::assertSame($expected, $res); } public function getFormatPackageData() @@ -372,10 +372,10 @@ public function testFormatPackage($packageVersion, $assetVersion, $expectedAsset if (null !== $assetVersion) { $assetPackage['version'] = $assetVersion; - $package->expects($this->never()) + $package->expects(static::never()) ->method('getPrettyVersion') ; - $package->expects($this->never()) + $package->expects(static::never()) ->method('getExtra') ; } else { @@ -385,11 +385,11 @@ public function testFormatPackage($packageVersion, $assetVersion, $expectedAsset $extra['branch-alias'][$packageVersion] = $branchAlias; } - $package->expects($this->once()) + $package->expects(static::once()) ->method('getPrettyVersion') ->willReturn($packageVersion) ; - $package->expects($this->once()) + $package->expects(static::once()) ->method('getExtra') ->willReturn($extra) ; @@ -402,6 +402,6 @@ public function testFormatPackage($packageVersion, $assetVersion, $expectedAsset $res = AssetUtil::formatPackage($package, $packageName, $assetPackage); - $this->assertEquals($expected, $res); + static::assertEquals($expected, $res); } } diff --git a/Tests/Util/ComposerUtilTest.php b/Tests/Util/ComposerUtilTest.php index 0b4ef41..6ef4efb 100644 --- a/Tests/Util/ComposerUtilTest.php +++ b/Tests/Util/ComposerUtilTest.php @@ -44,7 +44,7 @@ public function getValidateVersionData() public function testValidateVersion($composerVersion, $requiredVersion, $valid) { if ($valid) { - $this->assertTrue(true, 'Composer\'s version is valid'); + static::assertTrue(true, 'Composer\'s version is valid'); } else { $this->expectException('Foxy\Exception\RuntimeException'); $this->expectExceptionMessageRegExp('/Foxy requires the Composer\'s minimum version "([\d\.]+)", current version is "([\d\.]+)"/'); diff --git a/Tests/Util/ConsoleUtilTest.php b/Tests/Util/ConsoleUtilTest.php index 2e93d92..579145a 100644 --- a/Tests/Util/ConsoleUtilTest.php +++ b/Tests/Util/ConsoleUtilTest.php @@ -36,7 +36,7 @@ public function testGetInput() $helperSet = new HelperSet(); $io = new ConsoleIO($input, $output, $helperSet); - $this->assertSame($input, ConsoleUtil::getInput($io)); + static::assertSame($input, ConsoleUtil::getInput($io)); } public function testGetInputWithoutValidInput() @@ -44,7 +44,7 @@ public function testGetInputWithoutValidInput() /** @var IOInterface $io */ $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); - $this->assertInstanceOf('Symfony\Component\Console\Input\ArgvInput', ConsoleUtil::getInput($io)); + static::assertInstanceOf('Symfony\Component\Console\Input\ArgvInput', ConsoleUtil::getInput($io)); } public function getPreferredInstallOptionsData() @@ -73,32 +73,32 @@ public function testGetPreferredInstallOptions($expectedPreferSource, $expectedP /** @var InputInterface|\PHPUnit_Framework_MockObject_MockObject $input */ $input = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); - $config->expects($this->once()) + $config->expects(static::once()) ->method('get') ->with('preferred-install') ->willReturn($preferedInstall) ; if ($inputPrefer) { - $input->expects($this->at(0)) + $input->expects(static::at(0)) ->method('getOption') ->with('prefer-source') ->willReturn(false) ; - $input->expects($this->at(1)) + $input->expects(static::at(1)) ->method('getOption') ->with('prefer-dist') ->willReturn(true) ; - $input->expects($this->at(2)) + $input->expects(static::at(2)) ->method('getOption') ->with('prefer-source') ->willReturn(false) ; - $input->expects($this->at(3)) + $input->expects(static::at(3)) ->method('getOption') ->with('prefer-dist') ->willReturn(true) @@ -107,6 +107,6 @@ public function testGetPreferredInstallOptions($expectedPreferSource, $expectedP $res = ConsoleUtil::getPreferredInstallOptions($config, $input); - $this->assertEquals(array($expectedPreferSource, $expectedPreferDist), $res); + static::assertEquals(array($expectedPreferSource, $expectedPreferDist), $res); } } diff --git a/Tests/Util/PackageUtilTest.php b/Tests/Util/PackageUtilTest.php index c72ca2b..4cbf5c1 100644 --- a/Tests/Util/PackageUtilTest.php +++ b/Tests/Util/PackageUtilTest.php @@ -55,15 +55,15 @@ public function testLoadLockPackages() $lockDataLoaded = PackageUtil::loadLockPackages($lockData); - $this->assertArrayHasKey('packages', $lockDataLoaded); - $this->assertArrayHasKey('packages-dev', $lockDataLoaded); - $this->assertEquals($lockDataLoaded['packages'], $expectedPackages); - $this->assertEquals($lockDataLoaded['packages-dev'], $expectedDevPackages); + static::assertArrayHasKey('packages', $lockDataLoaded); + static::assertArrayHasKey('packages-dev', $lockDataLoaded); + static::assertEquals($lockDataLoaded['packages'], $expectedPackages); + static::assertEquals($lockDataLoaded['packages-dev'], $expectedDevPackages); } public function testLoadLockPackagesWithoutPackages() { - $this->assertSame(array(), PackageUtil::loadLockPackages(array())); + static::assertSame(array(), PackageUtil::loadLockPackages(array())); } public function testConvertLockAlias() @@ -101,7 +101,7 @@ public function testConvertLockAlias() $convertedAliases = PackageUtil::convertLockAlias($lockData); - $this->assertArrayHasKey('aliases', $convertedAliases); - $this->assertEquals($convertedAliases['aliases'], $expectedAliases); + static::assertArrayHasKey('aliases', $convertedAliases); + static::assertEquals($convertedAliases['aliases'], $expectedAliases); } }