memory-package-test-refactor: refactored the memory package test to be a bit more DRY and "hopefully" re-usable in anticipation of more package types being adding in the future.
parent
c863c31881
commit
b70bb1a9bc
|
@ -90,7 +90,7 @@ class MemoryPackage extends BasePackage
|
|||
*/
|
||||
public function setInstallationSource($type)
|
||||
{
|
||||
$this-> installationSource = $type;
|
||||
$this->installationSource = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,7 +166,7 @@ class MemoryPackage extends BasePackage
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $sha1checksum
|
||||
*/
|
||||
public function setDistSha1Checksum($sha1checksum)
|
||||
{
|
||||
|
@ -274,7 +274,7 @@ class MemoryPackage extends BasePackage
|
|||
/**
|
||||
* Set the provided virtual packages
|
||||
*
|
||||
* @param array $conflicts A set of package links
|
||||
* @param array $provides A set of package links
|
||||
*/
|
||||
public function setProvides(array $provides)
|
||||
{
|
||||
|
@ -292,7 +292,7 @@ class MemoryPackage extends BasePackage
|
|||
/**
|
||||
* Set the packages this one replaces
|
||||
*
|
||||
* @param array $conflicts A set of package links
|
||||
* @param array $replaces A set of package links
|
||||
*/
|
||||
public function setReplaces(array $replaces)
|
||||
{
|
||||
|
@ -310,7 +310,7 @@ class MemoryPackage extends BasePackage
|
|||
/**
|
||||
* Set the recommended packages
|
||||
*
|
||||
* @param array $conflicts A set of package links
|
||||
* @param array $recommends A set of package links
|
||||
*/
|
||||
public function setRecommends(array $recommends)
|
||||
{
|
||||
|
@ -328,7 +328,7 @@ class MemoryPackage extends BasePackage
|
|||
/**
|
||||
* Set the suggested packages
|
||||
*
|
||||
* @param array $conflicts A set of package links
|
||||
* @param array $suggests A set of package links
|
||||
*/
|
||||
public function setSuggests(array $suggests)
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
* Wil Moore III <wil.moore@wilmoore.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -16,13 +17,60 @@ use Composer\Package\MemoryPackage;
|
|||
|
||||
class MemoryPackageTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testMemoryPackage()
|
||||
|
||||
/**
|
||||
* Memory package naming, versioning, and marshalling semantics provider
|
||||
*
|
||||
* demonstrates several versioning schemes
|
||||
*
|
||||
* @todo if all package types share the same semantics, we could use a data provider
|
||||
* to test them all in a single suite
|
||||
*/
|
||||
public function provider_memory_package_semantics()
|
||||
{
|
||||
$package = new MemoryPackage('foo', '1-beta');
|
||||
$provider[] = array('foo', '1-beta', 'foo-1-beta');
|
||||
$provider[] = array('node', '0.5.6', 'node-0.5.6');
|
||||
$provider[] = array('li3', '0.10', 'li3-0.10');
|
||||
$provider[] = array('mongodb_odm', '1.0.0BETA3', 'mongodb_odm-1.0.0BETA3');
|
||||
$provider[] = array('DoctrineCommon', '2.2.0-DEV', 'doctrinecommon-2.2.0-DEV');
|
||||
|
||||
$this->assertEquals('foo', $package->getName());
|
||||
$this->assertEquals('1-beta', $package->getVersion());
|
||||
|
||||
$this->assertEquals('foo-1-beta', (string) $package);
|
||||
return $provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests memory package naming semantics
|
||||
*
|
||||
* @test
|
||||
* @dataProvider provider_memory_package_semantics
|
||||
*/
|
||||
public function Memory_Package_Has_Expected_Naming_Semantics($name, $version, $marshalled)
|
||||
{
|
||||
$package = new MemoryPackage($name, $version);
|
||||
$this->assertEquals(strtolower($name), $package->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests memory package versioning semantics
|
||||
*
|
||||
* @test
|
||||
* @dataProvider provider_memory_package_semantics
|
||||
*/
|
||||
public function Memory_Package_Has_Expected_Versioning_Semantics($name, $version, $marshalled)
|
||||
{
|
||||
$package = new MemoryPackage($name, $version);
|
||||
$this->assertEquals($version, $package->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests memory package marshalling/serialization semantics
|
||||
*
|
||||
* @test
|
||||
* @dataProvider provider_memory_package_semantics
|
||||
*/
|
||||
public function Memory_Package_Has_Expected_Marshalling_Semantics($name, $version, $marshalled)
|
||||
{
|
||||
$package = new MemoryPackage($name, $version);
|
||||
$this->assertEquals($marshalled, (string) $package);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue