FactoryTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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\Test;
  12. use Composer\Factory;
  13. class FactoryTest extends \PHPUnit_Framework_TestCase
  14. {
  15. /**
  16. * @dataProvider dataAddPackagistRepository
  17. */
  18. public function testAddPackagistRepository($expected, $config)
  19. {
  20. $factory = new Factory();
  21. $ref = new \ReflectionMethod($factory, 'addPackagistRepository');
  22. $ref->setAccessible(true);
  23. $this->assertEquals($expected, $ref->invoke($factory, $config));
  24. }
  25. public function dataAddPackagistRepository()
  26. {
  27. $f = function() {
  28. $repositories = func_get_args();
  29. return array('repositories' => $repositories);
  30. };
  31. $data = array();
  32. $data[] = array(
  33. $f(array('type' => 'composer', 'url' => 'http://packagist.org')),
  34. $f()
  35. );
  36. $data[] = array(
  37. $f(array('packagist' => false)),
  38. $f(array('packagist' => false))
  39. );
  40. $data[] = array(
  41. $f(
  42. array('type' => 'vcs', 'url' => 'git://github.com/composer/composer.git'),
  43. array('type' => 'composer', 'url' => 'http://packagist.org'),
  44. array('type' => 'pear', 'url' => 'http://pear.composer.org')
  45. ),
  46. $f(
  47. array('type' => 'vcs', 'url' => 'git://github.com/composer/composer.git'),
  48. array('packagist' => true),
  49. array('type' => 'pear', 'url' => 'http://pear.composer.org')
  50. )
  51. );
  52. return $data;
  53. }
  54. }