Skip to content

Commit

Permalink
Replace deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
francoispluchino committed Feb 25, 2016
1 parent e75cf21 commit 6cbd416
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 43 deletions.
4 changes: 2 additions & 2 deletions Repository/FilterUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
namespace Fxp\Composer\AssetPlugin\Repository;

use Composer\Package\Link;
use Composer\Package\LinkConstraint\LinkConstraintInterface;
use Composer\Package\Package;
use Composer\Package\RootPackageInterface;
use Composer\Semver\Constraint\ConstraintInterface;
use Fxp\Composer\AssetPlugin\Package\Version\VersionParser;

/**
Expand All @@ -30,7 +30,7 @@ class FilterUtil
* @param string $normalizedVersion The normalized version
* @param VersionParser $versionParser The version parser
*
* @return LinkConstraintInterface The constraint
* @return ConstraintInterface The constraint
*/
public static function getVersionConstraint($normalizedVersion, VersionParser $versionParser)
{
Expand Down
5 changes: 3 additions & 2 deletions Tests/AssetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ public function testGetVcsDrivers()
), array_keys(Assets::getVcsDrivers()));
}

/**
* @expectedException \InvalidArgumentException
*/
public function testCreationOfInvalidType()
{
$this->setExpectedException('InvalidArgumentException');

Assets::createType(null);
}

Expand Down
4 changes: 3 additions & 1 deletion Tests/Converter/AbstractPackageConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ protected function tearDown()
$this->asset = array();
}

/**
* @expectedException \InvalidArgumentException
*/
public function testConversionWithInvalidKey()
{
$this->setExpectedException('InvalidArgumentException');
$this->converter = new InvalidPackageConverter($this->type);

$this->converter->convert(array(
Expand Down
30 changes: 18 additions & 12 deletions Tests/FxpAssetPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ public function getDataForAssetVcsRepositories()
);
}

/**
* @expectedException \UnexpectedValueException
*/
public function testAssetRepositoryWithValueIsNotArray()
{
$this->setExpectedException('UnexpectedValueException');

$this->package->expects($this->any())
->method('getExtra')
->will($this->returnValue(array('asset-repositories' => array(
Expand All @@ -166,10 +167,11 @@ public function testAssetRepositoryWithValueIsNotArray()
$this->plugin->activate($this->composer, $this->io);
}

/**
* @expectedException \UnexpectedValueException
*/
public function testAssetRepositoryWithInvalidType()
{
$this->setExpectedException('UnexpectedValueException');

$this->package->expects($this->any())
->method('getExtra')
->will($this->returnValue(array('asset-repositories' => array(
Expand All @@ -179,10 +181,11 @@ public function testAssetRepositoryWithInvalidType()
$this->plugin->activate($this->composer, $this->io);
}

/**
* @expectedException \UnexpectedValueException
*/
public function testAssetRepositoryWithInvalidTypeFormat()
{
$this->setExpectedException('UnexpectedValueException');

$this->package->expects($this->any())
->method('getExtra')
->will($this->returnValue(array('asset-repositories' => array(
Expand All @@ -192,10 +195,11 @@ public function testAssetRepositoryWithInvalidTypeFormat()
$this->plugin->activate($this->composer, $this->io);
}

/**
* @expectedException \UnexpectedValueException
*/
public function testAssetRepositoryWithInvalidUrl()
{
$this->setExpectedException('UnexpectedValueException');

$this->package->expects($this->any())
->method('getExtra')
->will($this->returnValue(array('asset-repositories' => array(
Expand Down Expand Up @@ -236,10 +240,11 @@ public function testAssetRepositoryWithAlreadyExistRepositoryName()
$this->assertInstanceOf('Fxp\Composer\AssetPlugin\Repository\AssetVcsRepository', $repos[2]);
}

/**
* @expectedException \UnexpectedValueException
*/
public function testAssetPackageWithoutPackage()
{
$this->setExpectedException('UnexpectedValueException');

$this->package->expects($this->any())
->method('getExtra')
->will($this->returnValue(array('asset-repositories' => array(
Expand All @@ -249,10 +254,11 @@ public function testAssetPackageWithoutPackage()
$this->plugin->activate($this->composer, $this->io);
}

/**
* @expectedException \UnexpectedValueException
*/
public function testAssetPackageWithInvalidPackage()
{
$this->setExpectedException('UnexpectedValueException');

$this->package->expects($this->any())
->method('getExtra')
->will($this->returnValue(array('asset-repositories' => array(
Expand Down
5 changes: 3 additions & 2 deletions Tests/Installer/BowerInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ public function testUpdate(array $ignoreFiles)
$this->ensureDirectoryExistsAndClear($packageDir);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testUninstall()
{
/* @var RootPackageInterface $rootPackage */
Expand Down Expand Up @@ -363,8 +366,6 @@ public function testUninstall()
/* @var PackageInterface $package */
$library->uninstall($repository, $package);

$this->setExpectedException('InvalidArgumentException');

$library->uninstall($repository, $package);
}

Expand Down
24 changes: 16 additions & 8 deletions Tests/Package/Loader/LazyAssetPackageLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,29 +154,35 @@ protected function tearDown()
$this->lazyLoader = null;
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "assetType" property must be defined
*/
public function testMissingAssetType()
{
$this->setExpectedException('InvalidArgumentException', 'The "assetType" property must be defined');

$loader = $this->createLazyLoader('TYPE');
$loader->load($this->lazyPackage);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "loader" property must be defined
*/
public function testMissingLoader()
{
$this->setExpectedException('InvalidArgumentException', 'The "loader" property must be defined');

/* @var AssetTypeInterface $assetType */
$assetType = $this->assetType;
$loader = $this->createLazyLoader('TYPE');
$loader->setAssetType($assetType);
$loader->load($this->lazyPackage);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "driver" property must be defined
*/
public function testMissingDriver()
{
$this->setExpectedException('InvalidArgumentException', 'The "driver" property must be defined');

/* @var AssetTypeInterface $assetType */
$assetType = $this->assetType;
/* @var LoaderInterface $cLoader */
Expand All @@ -189,10 +195,12 @@ public function testMissingDriver()
$loader->load($lazyPackage);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "io" property must be defined
*/
public function testMissingIo()
{
$this->setExpectedException('InvalidArgumentException', 'The "io" property must be defined');

/* @var AssetTypeInterface $assetType */
$assetType = $this->assetType;
/* @var LoaderInterface $cLoader */
Expand Down
5 changes: 3 additions & 2 deletions Tests/Repository/AbstractAssetsRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,11 @@ public function testFindPackageMustBeAlwaysEmpty()
$this->assertCount(0, $this->registry->findPackages('foobar', '0'));
}

/**
* @expectedException \LogicException
*/
public function testGetPackagesNotBeUsed()
{
$this->setExpectedException('LogicException');

$this->registry->getPackages();
}

Expand Down
9 changes: 5 additions & 4 deletions Tests/Repository/AssetVcsRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,23 @@ public function getMockDrivers()

/**
* @dataProvider getMockDrivers
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage No driver found to handle Asset VCS repository
*/
public function testNotDriverFound($type, $url, $class)
{
$this->setExpectedException('InvalidArgumentException', 'No driver found to handle Asset VCS repository '.$url);

$this->init(false, $type, $url, $class);
$this->repository->getPackages();
}

/**
* @dataProvider getMockDrivers
*
* @expectedException \Composer\Repository\InvalidRepositoryException
*/
public function testWithoutValidPackage($type, $url, $class)
{
$this->setExpectedException('Composer\Repository\InvalidRepositoryException');

$this->init(true, $type, $url, $class);
$this->repository->getPackages();
}
Expand Down
6 changes: 4 additions & 2 deletions Tests/Repository/NpmRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ public function testWatProvidesWithoutRepositoryUrl()
$this->assertCount(1, $this->rm->getRepositories());
}

/**
* @expectedException \Fxp\Composer\AssetPlugin\Exception\InvalidCreateRepositoryException
* @expectedExceptionMessage "repository.url" parameter of "foobar"
*/
public function testWatProvidesWithoutRepositoryUrlAndWithoutVersions()
{
$this->setExpectedException('Fxp\Composer\AssetPlugin\Exception\InvalidCreateRepositoryException', '"repository.url" parameter of "foobar"');

$name = $this->getType().'-asset/foobar';
$rfs = $this->replaceRegistryRfsByMock();
$rfs->expects($this->any())
Expand Down
12 changes: 6 additions & 6 deletions Tests/Repository/Vcs/GitHubDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,11 @@ public function testGetComposerInformationWithEmptyContent($type, $filename)

/**
* @dataProvider getAssetTypes
*
* @expectedException \RuntimeException
*/
public function testGetComposerInformationWithRuntimeException($type, $filename)
{
$this->setExpectedException('RuntimeException');

$repoUrl = 'http://github.com/composer-test/repo-name';
$repoApiUrl = 'https://api.github.com/repos/composer-test/repo-name';
$identifier = 'v0.0.0';
Expand Down Expand Up @@ -594,11 +594,11 @@ public function testGetComposerInformationWithRuntimeException($type, $filename)

/**
* @dataProvider getAssetTypes
*
* @expectedException \RuntimeException
*/
public function testGetComposerInformationWithTransportException($type, $filename)
{
$this->setExpectedException('RuntimeException');

$repoUrl = 'http://github.com/composer-test/repo-name';
$repoApiUrl = 'https://api.github.com/repos/composer-test/repo-name';
$identifier = 'v0.0.0';
Expand Down Expand Up @@ -710,11 +710,11 @@ public function testRedirectUrlRepository($type, $filename)

/**
* @dataProvider getAssetTypes
*
* @expectedException \RuntimeException
*/
public function testRedirectUrlWithNonexistentRepository($type, $filename)
{
$this->setExpectedException('RuntimeException');

$repoUrl = 'http://github.com/composer-test/repo-name';
$repoApiUrl = 'https://api.github.com/repos/composer-test/repo-name';
$identifier = 'v0.0.0';
Expand Down
4 changes: 2 additions & 2 deletions Tests/Repository/Vcs/SvnDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ public function testPublicRepositoryWithFilesystemCache($type, $filename, $ident

/**
* @dataProvider getAssetTypes
*
* @expectedException \Composer\Downloader\TransportException
*/
public function testPublicRepositoryWithInvalidUrl($type, $filename, $identifier)
{
$this->setExpectedException('Composer\Downloader\TransportException');

$repoUrl = 'svn://example.tld/composer-test/repo-name/trunk';
$io = $this->getMock('Composer\IO\IOInterface');

Expand Down

0 comments on commit 6cbd416

Please sign in to comment.