/** * Test that you can add and remove service mocks. * * @return void * @author Dan Cox */ public function test_basicAddingRemoving() { $mock = new ServiceMockery('database'); $mock->add(); $library = new ServiceMockeryLibrary(); $this->assertEquals('database', $library->find('database')); $this->assertEquals('database', $mock->getLibrary()->find('database')); $mock->remove(); $this->assertEquals(NULL, $library->find('database')); $this->assertEquals(NULL, $mock->getLibrary()->find('database')); }
/** * Tear down test class * * @return void * @author Dan Cox */ public function tearDown() { \Mockery::close(); // Clear the mocks $library = new ServiceMockeryLibrary(); $library->clear(); $extensions = new \Wasp\DI\ExtensionRegister(); $extensions->clearExtensions(); DICompilerPassRegister::clear(); }
/** * Test adding the twig configuration * * @return void * @author Dan Cox */ public function test_templatingWithTwigConfig() { $profile = new Profile(new Filesystem()); $profile->setSettings(['templates' => array('twig' => array('debug' => true))]); $this->app->profile = $profile; $env = new Environment(); $env->load($this->app); $env->getDI()->addCompilerPass(new \Wasp\DI\Pass\MockeryPass()); $t = new ServiceMockery('twigengine'); $t->add(); $temp = new ServiceMockery('template'); $temp->add(); $env->createDI(); $twig = $env->getDI()->get('twigengine'); $template = $env->getDI()->get('template'); $twig->shouldReceive('create')->once()->with(array('debug' => true)); $template->shouldReceive('setDirectory')->andReturn($template); $template->shouldReceive('getDirectory')->andReturn(__DIR__); $template->shouldReceive('addEngine')->andReturn($template); $template->shouldReceive('start'); $env->startTemplating(dirname(__DIR__) . '/Templating/Templates/'); // Clean Up $library = new ServiceMockeryLibrary(); $library->clear(); }