/** * Call method, performs the call and sends the result to the dispatcher * * @param String $method * @param Array $params * @return Mixed */ public function __call($method, array $params = array()) { $before = new BeforeMethodEvent($this->alias, $method, $this->warden->getParams()); $this->dispatch->dispatch(WardenEvents::BEFORE_METHOD, $before); $returnValue = call_user_func_array([$this->service, $method], $params); $after = new AfterMethodEvent($this->alias, $method, $returnValue, $this->warden->getParams()); $this->dispatch->dispatch(WardenEvents::AFTER_METHOD, $after); return $returnValue; }
/** * Test that the governor class triggers exceptions * * @return void */ public function test_governor_triggers_exceptions() { $this->setExpectedException('Warden\\Exceptions\\LimitExceededException'); $warden = new Warden(); $warden->addGovernor(new TestGovernor()); $warden->start(); $d = $warden->getGovernor('testGov'); $d->getAValue(); $warden->stop(); }
/** * Test that it throws an exception when we hit the query limit * * @return void */ public function test_it_throws_exception_on_query_limit() { $this->setExpectedException('Warden\\Exceptions\\LimitExceededException'); $this->warden->start(); // Le wild query in a loop appears for ($i = 0; $i < 10; $i++) { $result = $this->em->getRepository('Warden\\Tests\\Collector\\Doctrine\\Entities\\Test')->findBy([], [], null, null); } $this->warden->stop(); }
/** * Handler for the After method governor event * * @param \Warden\Events\AfterMethodEvent $event * @return void */ public function onAfterMethod(AfterMethodEvent $event) { $governor = $this->warden->getGovernorHandler($event->alias); $governor->afterMethodFire($event); }