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'); } }