RepositoryManagerTest.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Repository;
  12. use Composer\TestCase;
  13. class RepositoryManagerTest extends TestCase
  14. {
  15. /**
  16. * @dataProvider creationCases
  17. */
  18. public function testRepoCreation($type, $config, $exception = null)
  19. {
  20. if ($exception) {
  21. $this->setExpectedException($exception);
  22. }
  23. $rm = new RepositoryManager(
  24. $this->getMock('Composer\IO\IOInterface'),
  25. $this->getMock('Composer\Config'),
  26. $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock()
  27. );
  28. $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
  29. $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
  30. $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
  31. $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
  32. $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
  33. $rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
  34. $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
  35. $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
  36. $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
  37. $rm->createRepository('composer', array('url' => 'http://example.org'));
  38. $rm->createRepository($type, $config);
  39. }
  40. public function creationCases()
  41. {
  42. return array(
  43. array('composer', array('url' => 'http://example.org')),
  44. array('vcs', array('url' => 'http://github.com/foo/bar')),
  45. array('git', array('url' => 'http://github.com/foo/bar')),
  46. array('git', array('url' => 'git@example.org:foo/bar.git')),
  47. array('svn', array('url' => 'svn://example.org/foo/bar')),
  48. array('pear', array('url' => 'http://pear.example.org/foo')),
  49. array('artifact', array('url' => '/path/to/zips')),
  50. array('package', array('package' => array())),
  51. array('invalid', array(), 'InvalidArgumentException'),
  52. );
  53. }
  54. }