mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Added repository tests
This commit is contained in:
parent
bb81e3721a
commit
6c16153302
4 changed files with 77 additions and 4 deletions
62
tests/Composer/Test/Repository/PathRepositoryTest.php
Normal file
62
tests/Composer/Test/Repository/PathRepositoryTest.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Repository;
|
||||
|
||||
use Composer\Package\Loader\ArrayLoader;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\TestCase;
|
||||
use Composer\IO\NullIO;
|
||||
use Composer\Config;
|
||||
use Composer\Package\BasePackage;
|
||||
|
||||
class PathRepositoryTest extends TestCase
|
||||
{
|
||||
public function testLoadPackageFromFileSystemWithVersion()
|
||||
{
|
||||
$ioInterface = $this->getMockBuilder('Composer\IO\IOInterface')
|
||||
->getMock();
|
||||
|
||||
$config = new \Composer\Config();
|
||||
$loader = new ArrayLoader(new VersionParser());
|
||||
$versionGuesser = null;
|
||||
|
||||
$repositoryUrl = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'Fixtures', 'path', 'with-version'));
|
||||
$repository = new PathRepository(array('url' => $repositoryUrl), $ioInterface, $config, $loader);
|
||||
$repository->getPackages();
|
||||
|
||||
$this->assertEquals(1, $repository->count());
|
||||
$this->assertTrue($repository->hasPackage($this->getPackage('test/path', '0.0.2')));
|
||||
}
|
||||
|
||||
public function testLoadPackageFromFileSystemWithoutVersion()
|
||||
{
|
||||
$ioInterface = $this->getMockBuilder('Composer\IO\IOInterface')
|
||||
->getMock();
|
||||
|
||||
$config = new \Composer\Config();
|
||||
$loader = new ArrayLoader(new VersionParser());
|
||||
$versionGuesser = null;
|
||||
|
||||
$repositoryUrl = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'Fixtures', 'path', 'without-version'));
|
||||
$repository = new PathRepository(array('url' => $repositoryUrl), $ioInterface, $config, $loader);
|
||||
$packages = $repository->getPackages();
|
||||
|
||||
$this->assertEquals(1, $repository->count());
|
||||
|
||||
$package = $packages[0];
|
||||
$this->assertEquals('test/path', $package->getName());
|
||||
|
||||
$packageVersion = $package->getVersion();
|
||||
$this->assertTrue(!empty($packageVersion));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue