12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace Fgm\ComposerCheck\Tests;
- use Fgm\ComposerCheck\LoaderFactory;
- /**
- * Class LoaderFactoryTest.
- *
- * @coversDefaultClass \Fgm\ComposerCheck\LoaderFactory
- */
- class LoaderFactoryTest extends \PHPUnit_Framework_TestCase {
- const NS = 'Fgm\\ComposerCheck\\';
- /**
- * Test the normal construction case.
- *
- * @covers ::__construct()
- * @covers ::validateDirectory()
- */
- public function testHappyConstructor() {
- // This is a Composer project, so it should be installed to run its tests.
- $dir = __DIR__ . '/../..';
- $factory = new LoaderFactory($dir);
- $this->assertInstanceOf(self::NS . 'LoaderFactory', $factory);
- }
- /**
- * Tests constructing on an existing directory with missing composer files.
- *
- * @covers ::__construct()
- * @covers ::validateDirectory()
- *
- * @expectedException \InvalidArgumentException
- */
- public function testSadConstructorMissing() {
- $dir = __DIR__;
- new LoaderFactory($dir);
- }
- /**
- * Tests constructing on a missing directory.
- *
- * @covers ::__construct()
- * @covers ::validateDirectory()
- *
- * @expectedException \InvalidArgumentException
- */
- public function testSadConstructorInvalid() {
- $dir = '/dev/null/nowhere';
- new LoaderFactory($dir);
- }
- /**
- * Testes a successful load for requirements and lock.
- *
- * @covers ::createLoader()
- */
- public function testHappyCreateLoader() {
- $dir = __DIR__ . '/../..';
- $factory = new LoaderFactory($dir);
- $loader = $factory->createLoader('requirements');
- $this->assertInstanceOf(self::NS . 'RequirementsLoader', $loader);
- $loader = $factory->createLoader('lock');
- $this->assertInstanceOf(self::NS . 'LockLoader', $loader);
- }
- /**
- * Tests an attempt to load an invalid type of composer file.
- *
- * @covers ::createLoader()
- *
- * @expectedException \InvalidArgumentException
- */
- public function testSadCreateLoader() {
- $dir = __DIR__ . '/../..';
- $factory = new LoaderFactory($dir);
- $factory->createLoader('invalid');
- }
- }
|