setExpectedException('ReflectionException'); $class = new ReflectionClass('Asra_Export_Registrar'); $instance = $class->newInstance(); clone $instance; } public function testClear() { Asra_Export_Registrar::clear(); $this->assertEquals(0, count(Asra_Export_Registrar::getFormats())); } public function testGetClassName() { $name = Asra_Export_Registrar::getClassName('json'); $this->assertEquals('Asra_Export_Format_Json', $name); } public function testGetClassNameNotFound() { $this->setExpectedException('Asra_Export_Exception'); $name = Asra_Export_Registrar::getClassName('test'); $this->assertEquals('Asra_Export_Format_Json', $name); } public function testGetClassPath() { $path = Asra_Export_Registrar::getClassPath('json'); $this->assertNotNull($path); } public function testGetClassPathNotFound() { $this->setExpectedException('Asra_Export_Exception'); $path = Asra_Export_Registrar::getClassPath('test'); } public function testHasFormat() { $bool = Asra_Export_Registrar::hasFormat('json'); $this->assertTrue($bool); } public function testHasFormatFalse() { $bool = Asra_Export_Registrar::hasFormat('test'); $this->assertFalse($bool); } public function testRegister() { Asra_Export_Registrar::register('format', 'New_Class_Name', FILES); $this->assertTrue(Asra_Export_Registrar::hasFormat('format')); $this->assertEquals('New_Class_Name', Asra_Export_Registrar::getClassName('format') ); $this->assertEquals(FILES, Asra_Export_Registrar::getClassPath('format')); } public function testRegisterAsString() { Asra_Export_Registrar::registerAsString("json|xml"); $this->assertArrayHasKey('json', Asra_Export_Registrar::getFormats()); $this->assertArrayNotHasKey('serial', Asra_Export_Registrar::getFormats()); $this->assertEquals('Asra_Export_Format_Json', Asra_Export_Registrar::getClassName('json')); try { $className = Asra_Export_Registrar::getClassName('serial'); } catch (Asra_Export_Exception $exception) { return; } $this->fail('Serial should\'ve been unset'); } public function testUnregister() { Asra_Export_Registrar::unregister('json'); $this->assertFalse(Asra_Export_Registrar::hasFormat('json')); } }