示例#1
0
 /**
  * @covers ::addTestModule
  */
 public function testAddingTestModule()
 {
     $framework = new Framework();
     $application = new TestApplication();
     $framework->configureApplication($application);
     $module = $this->getMockBuilder('Splot\\Framework\\Modules\\AbstractModule')->setMethods(array('getName', 'configure', 'run', 'setContainer'))->getMock();
     $module->expects($this->any())->method('getName')->will($this->returnValue('TestModule'));
     // make sure that container is injected to the module
     $module->expects($this->once())->method('setContainer')->with($this->callback(function ($container) use($application) {
         return $container === $application->getContainer();
     }));
     // make sure that module is allowed to be configured
     $module->expects($this->once())->method('configure');
     // make sure that module is allowed to be run
     $module->expects($this->once())->method('run');
     $application->addTestModule($module, array('test_setting' => 'proper value', 'another_setting' => true));
     $this->assertTrue($application->hasModule('TestModule'));
     $this->assertSame($module, $application->getModule('TestModule'));
     // make sure that config is set in the container and that config contains passed options
     $container = $application->getContainer();
     $this->assertTrue($container->has('config.TestModule'));
     $config = $container->get('config.TestModule');
     $this->assertInstanceOf('Splot\\Framework\\Config\\Config', $config);
     $this->assertEquals('proper value', $config->get('test_setting'));
     $this->assertEquals(true, $config->get('another_setting'));
 }
示例#2
0
 /**
  * @covers ::runCommand
  * @covers ::doRunApplication
  */
 public function testRunTest()
 {
     $application = $this->getMockBuilder('Splot\\Framework\\Application\\AbstractApplication')->setMethods(array('loadModules', 'getModules', 'run'))->getMock();
     $modules = array('one' => $this->provideModule('ModuleOne', array(), true), 'two' => $this->provideModule('ModuleTwo', array(), true), 'three' => $this->provideModule('ModuleThree', array(), true));
     foreach ($modules as $module) {
         $module->expects($this->once())->method('run');
     }
     $application->expects($this->atLeastOnce())->method('getModules')->will($this->returnValue($modules));
     $framework = new Framework();
     $framework->configureApplication($application);
     $framework->runTest($application);
     $this->assertEquals(Framework::MODE_TEST, $application->getContainer()->getParameter('mode'));
 }