BasePackageTest.php 1.2 KB

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