BasePackageTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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\Package;
  12. class BasePackageTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testSetSameRepository()
  15. {
  16. $package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo'));
  17. $repository = $this->getMock('Composer\Repository\RepositoryInterface');
  18. $package->setRepository($repository);
  19. try {
  20. $package->setRepository($repository);
  21. } catch (\Exception $e) {
  22. $this->fail('Set against the same repository is allowed.');
  23. }
  24. }
  25. /**
  26. * @expectedException LogicException
  27. */
  28. public function testSetAnotherRepository()
  29. {
  30. $package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo'));
  31. $package->setRepository($this->getMock('Composer\Repository\RepositoryInterface'));
  32. $package->setRepository($this->getMock('Composer\Repository\RepositoryInterface'));
  33. }
  34. }