public function testEngineCannotValidate()
 {
     /**
      * reset the engines
      */
     Xinc_Engine_Repository::tearDown();
     $workingdir = getcwd();
     $configFile = Xinc_Config_File::load($workingdir . '/test/resources/testEngineCannotValidate.xml');
     $parser = new Xinc_Config_Parser($configFile);
     $engines = $parser->getEngines();
     $this->assertTrue(count($engines) == 1, 'We should have one engine');
     $engineParser = new Xinc_Engine_Parser();
     try {
         $engineParser->parse($engines);
         $this->assertTrue(true, 'Should not throw an exception');
         $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), 'cannot load engine') !== false, 'We should have a log message about the engine not being able to load');
     } catch (Exception $e) {
         $this->assertTrue(false, 'Should not catch an exception but caught: ' . get_class($e));
     }
     try {
         $engine = Xinc_Engine_Repository::getInstance()->getEngine('SunriseCannotValidate');
         $this->assertTrue(false, 'Should throw an exception');
     } catch (Xinc_Engine_Exception_NotFound $e) {
         $this->assertTrue(true, 'Right Exception caught');
     } catch (Exception $pe) {
         $this->assertTrue(false, 'Should catch a NotFound exception but caught: ' . get_class($e));
     }
 }
Esempio n. 2
0
 public function testEngineRegistered()
 {
     /**
      * reset the engines
      */
     Xinc_Engine_Repository::tearDown();
     $workingdir = getcwd();
     $configFile = Xinc_Config_File::load($workingdir . '/test/resources/testSystem.xml');
     $parser = new Xinc_Config_Parser($configFile);
     $engines = $parser->getEngines();
     $this->assertTrue(count($engines) == 1, 'We should have one engine');
     $engineParser = new Xinc_Engine_Parser();
     try {
         $engineParser->parse($engines);
         $this->assertTrue(true, 'Should not throw an exception');
     } catch (Exception $e) {
         $this->assertTrue(false, 'Should not catch an exception but caught: ' . get_class($e));
     }
     $engines = Xinc_Engine_Repository::getInstance()->getEngines();
     /**
      * Engines are registered by their name and classname
      * therefore we expect 2 engines
      */
     $this->assertEquals($engines->count(), 2, 'There should be a registered engine');
     $engine = Xinc_Engine_Repository::getInstance()->getEngine(Xinc_Engine_Sunrise::NAME);
     $this->assertTrue($engine instanceof Xinc_Engine_Sunrise, 'Engine should be a Xinc_engine_Sunrise');
 }