Skip to content

Commit

Permalink
Replace call static methods for phpunit
Browse files Browse the repository at this point in the history
  • Loading branch information
francoispluchino committed Aug 8, 2019
1 parent 4f87e23 commit b4a2124
Show file tree
Hide file tree
Showing 17 changed files with 195 additions and 195 deletions.
64 changes: 32 additions & 32 deletions Tests/Asset/AbstractAssetManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -178,15 +178,15 @@ 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()
{
$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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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());
}

/**
Expand Down
26 changes: 13 additions & 13 deletions Tests/Asset/AssetPackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function setUp()
->getMock()
;

$this->rootPackage->expects($this->any())
$this->rootPackage->expects(static::any())
->method('getLicense')
->willReturn(array())
;
Expand Down Expand Up @@ -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()
Expand All @@ -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)
;
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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());
}

/**
Expand All @@ -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)
;
Expand Down
26 changes: 13 additions & 13 deletions Tests/Config/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
;
Expand Down Expand Up @@ -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(
Expand All @@ -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))
;
Expand All @@ -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()
Expand All @@ -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));
}

/**
Expand All @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions Tests/Event/AbstractSolveEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Loading

0 comments on commit b4a2124

Please sign in to comment.