Example #1
0
 /**
  * {@inheritdoc}
  */
 public function execute($request, $catchInteractive = false)
 {
     $action = null;
     try {
         $this->extensions->onPreExecute($request);
         if (false == ($action = $this->findActionSupported($request))) {
             throw RequestNotSupportedException::create($request);
         }
         $this->extensions->onExecute($request, $action);
         $action->execute($request);
         $this->extensions->onPostExecute($request, $action);
     } catch (InteractiveRequestInterface $interactiveRequest) {
         $interactiveRequest = $this->extensions->onInteractiveRequest($interactiveRequest, $request, $action) ?: $interactiveRequest;
         if ($catchInteractive) {
             return $interactiveRequest;
         }
         throw $interactiveRequest;
     } catch (\Exception $e) {
         $this->extensions->onException($e, $request, $action);
         throw $e;
     }
 }
 /**
  * @test
  */
 public function shouldCallOnExceptionForAllExtensionsInCollection()
 {
     $expectedException = new \Exception();
     $expectedRequest = new \stdClass();
     $expectedAction = $this->getMock('Payum\\Action\\ActionInterface');
     $extensionFirst = $this->createExtensionMock();
     $extensionFirst->expects($this->once())->method('onException')->with($this->identicalTo($expectedException), $this->identicalTo($expectedRequest), $this->identicalTo($expectedAction));
     $extensionSecond = $this->createExtensionMock();
     $extensionSecond->expects($this->once())->method('onException')->with($this->identicalTo($expectedException), $this->identicalTo($expectedRequest), $this->identicalTo($expectedAction));
     $collection = new ExtensionCollection();
     $collection->addExtension($extensionFirst);
     $collection->addExtension($extensionSecond);
     $result = $collection->onException($expectedException, $expectedRequest, $expectedAction);
     $this->assertNull($result);
 }