function testOldConnectionIsRestored() { $this->assertFalse($this->conn instanceof lmbAutoTransactionConnection); $filter = new lmbAutoDbTransactionFilter(); $chain = new MockFilterChain(); $chain->expectOnce('next'); $filter->run($chain); $this->assertIdentical($this->conn, $this->toolkit->getDefaultDbConnection()); }
function testRunOk() { $controller = new MockController(); $controller->expectOnce('performAction'); $this->toolkit->setDispatchedController($controller); $filter = new lmbActionPerformingFilter(); $fc = new MockFilterChain(); $fc->expectOnce('next'); $filter->run($fc); }
function testRunOk() { $this->uow->expectOnce('reset'); $this->uow->expectOnce('commit'); $filter = new UOWFilter(); $fc = new MockFilterChain($this); $fc->expectOnce('next'); $filter->run($fc, $request, $response); $fc->tally(); }
function testDoNotRenderViewIfResponseNotEmpty() { $response = new MockHttpResponse(); $response->expectOnce('isEmpty'); $response->setReturnValue('isEmpty', false); $this->toolkit->setResponse($response); $view = new MockView(); $this->toolkit->setView($view); $filter = new lmbViewRenderingFilter(); $view->expectNever('render'); $response->expectNever('write'); $chain = new MockFilterChain(); $chain->expectOnce('next'); $filter->run($chain); }
function testRunOk() { $command = new CommandStub(); $service =& new MockService($this); $service->expectOnce('getCurrentAction'); $service->setReturnValue('getCurrentAction', $action = 'whatever'); $service->expectOnce('getActionCommand', array($action)); $service->setReturnReference('getActionCommand', $command); $this->toolkit->setService($service); $filter = new CommandProcessingFilter(); $fc = new MockFilterChain($this); $fc->expectOnce('next'); $filter->run($fc, $request, $response); $this->assertTrue($command->performed); $fc->tally(); $service->tally(); }
function testRunAccessDenied() { RegisterTestingIni('403.service.ini', ' default_action = display [display] props'); $toolkit =& Limb::toolkit(); $request =& $toolkit->getRequest(); $uri =& $request->getUri(); $uri->setPath($path = 'whatever'); $service = new Service($service_name = 'TestService'); $service->setCurrentAction($action = 'some_action'); $this->authorizer->expectOnce('canDo', array($action, $path, $service_name)); $this->authorizer->setReturnValue('canDo', false); $filter = new SimpleACLAccessFilter(); $fc = new MockFilterChain($this); $fc->expectOnce('next'); $toolkit->setService($service); $filter->run($fc, $request, $response); $new_service =& $toolkit->getService(); $this->assertEqual($new_service->getName(), '403'); $this->assertEqual($new_service->getCurrentAction(), 'display'); $fc->tally(); }