Exemple #1
0
 /**
  * @test
  */
 public function shouldPopulateContextWithPreviousOnesOnSubExecutes()
 {
     $gateway = new Gateway();
     $firstRequest = new \stdClass();
     $secondRequest = new \stdClass();
     $firstAction = new RequireOtherRequestAction();
     $firstAction->setSupportedRequest($firstRequest);
     $firstAction->setRequiredRequest($secondRequest);
     $gateway->addAction($firstAction);
     $actionMock = $this->createActionMock();
     $actionMock->expects($this->any())->method('supports')->willReturnCallback(function ($request) use($secondRequest) {
         return $secondRequest === $request;
     });
     $gateway->addAction($actionMock);
     $testCase = $this;
     $extensionMock = $this->createExtensionMock();
     $extensionMock->expects($this->at(0))->method('onPreExecute')->willReturnCallback(function (Context $context) use($testCase, $firstRequest) {
         $testCase->assertSame($firstRequest, $context->getRequest());
         $testCase->assertEmpty($context->getPrevious());
     });
     $extensionMock->expects($this->at(1))->method('onPreExecute')->willReturnCallback(function (Context $context) use($testCase, $secondRequest) {
         $testCase->assertSame($secondRequest, $context->getRequest());
         $testCase->assertCount(1, $context->getPrevious());
         $this->assertContainsOnly('Payum\\Core\\Extension\\Context', $context->getPrevious());
     });
     $gateway->addExtension($extensionMock);
     $gateway->execute($firstRequest);
 }
Exemple #2
0
 /**
  * @param Gateway     $gateway
  * @param ArrayObject $config
  */
 protected function buildExtensions(Gateway $gateway, ArrayObject $config)
 {
     foreach ($config as $name => $value) {
         if (0 === strpos($name, 'payum.extension')) {
             $prepend = in_array($name, $config['payum.prepend_extensions']);
             $gateway->addExtension($value, $prepend);
         }
     }
 }
 /**
  * @param Gateway     $gateway
  * @param ArrayObject $config
  */
 protected function buildExtensions(Gateway $gateway, ArrayObject $config)
 {
     foreach ($config as $name => $value) {
         if (0 === strpos($name, 'payum.extension')) {
             $prepend = in_array($name, $config['payum.prepend_extensions']);
             if (is_callable($value)) {
                 $gateway->addExtension(call_user_func_array($value, array($config)), $prepend);
             } else {
                 $gateway->addExtension($value, $prepend);
             }
         }
     }
 }