LoaderFactoryTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace Fgm\ComposerCheck\Tests;
  3. use Fgm\ComposerCheck\LoaderFactory;
  4. /**
  5. * Class LoaderFactoryTest.
  6. *
  7. * @coversDefaultClass \Fgm\ComposerCheck\LoaderFactory
  8. */
  9. class LoaderFactoryTest extends \PHPUnit_Framework_TestCase {
  10. const NS = 'Fgm\\ComposerCheck\\';
  11. /**
  12. */
  13. public function testHappyConstructor() {
  14. // This is a Composer project, so it should be installed to run its tests.
  15. $dir = __DIR__ . '/../..';
  16. $factory = new LoaderFactory($dir);
  17. $this->assertInstanceOf(self::NS . 'LoaderFactory', $factory);
  18. }
  19. /**
  20. * @expectedException \InvalidArgumentException
  21. */
  22. public function testSadConstructorMissing() {
  23. $dir = __DIR__;
  24. new LoaderFactory($dir);
  25. }
  26. /**
  27. * @expectedException \InvalidArgumentException
  28. */
  29. public function testSadConstructorInvalid() {
  30. $dir = '/dev/null/nowhere';
  31. new LoaderFactory($dir);
  32. }
  33. public function testHappyCreateLoader() {
  34. $dir = __DIR__ . '/../..';
  35. $factory = new LoaderFactory($dir);
  36. $loader = $factory->createLoader('requirements');
  37. $this->assertInstanceOf(self::NS . 'RequirementsLoader', $loader);
  38. $loader = $factory->createLoader('lock');
  39. $this->assertInstanceOf(self::NS . 'LockLoader', $loader);
  40. }
  41. /**
  42. * @expectedException \InvalidArgumentException
  43. */
  44. public function testSadCreateLoader() {
  45. $dir = __DIR__ . '/../..';
  46. $factory = new LoaderFactory($dir);
  47. $factory->createLoader('invalid');
  48. }
  49. }