protected function buildRegistry(array $gateways = [], array $storages = [], array $gatewayFactories = []) { $fallbackRegistry = new SimpleRegistry($gateways, $storages, $gatewayFactories); $fallbackRegistry->setAddStorageExtensions(false); if ($this->gatewayConfigStorage) { $fallbackRegistry = new ComSalesPayumRegistryDynamic_registry($this->gatewayConfigStorage, $fallbackRegistry); } if ($this->mainRegistry) { $registry = new FallbackRegistry($this->mainRegistry, $fallbackRegistry); } else { $registry = $fallbackRegistry; } return $registry; }
/** * @test */ public function shouldNotInitializeStorageExtensionsOnGetGatewaysIfNotGenericGateway() { $storageOneMock = $this->getMock('Payum\\Core\\Storage\\StorageInterface'); $gatewayFooMock = $this->getMock('Payum\\Core\\GatewayInterface'); $gatewayBarMock = $this->getMock('Payum\\Core\\Gateway'); $registry = new SimpleRegistry(array('foo' => $gatewayFooMock, 'bar' => $gatewayBarMock), array('fooClass' => $storageOneMock)); $registry->getGateways(); }
/** * @test */ public function shouldInitializeStorageExtensionsOnGetPayments() { $storageOneMock = $this->getMock('Payum\\Core\\Storage\\StorageInterface'); $paymentFooMock = $this->getMock('Payum\\Core\\PaymentInterface'); $paymentFooMock->expects($this->once())->method('addExtension'); $paymentBarMock = $this->getMock('Payum\\Core\\PaymentInterface'); $paymentBarMock->expects($this->once())->method('addExtension'); $registry = new SimpleRegistry(array('foo' => $paymentFooMock, 'bar' => $paymentBarMock), array('fooClass' => $storageOneMock), 'foo'); $registry->getPayments(); $registry->getPayments(); }
/** * @test */ public function shouldNotInitializeStorageExtensionsOnGetPaymentsIfNotGenericPayment() { $storageOneMock = $this->getMock('Payum\Core\Storage\StorageInterface'); $paymentFooMock = $this->getMock('Payum\Core\PaymentInterface'); $paymentBarMock = $this->getMock('Payum\Core\Payment'); $registry = new SimpleRegistry( array('foo' => $paymentFooMock, 'bar' => $paymentBarMock), array( 'fooClass' => $storageOneMock, ) ); $registry->getPayments(); }
/** * @param array $gateways * @param array $storages * @param array $gatewayFactories * * @return RegistryInterface */ protected function buildRegistry(array $gateways = [], array $storages = [], array $gatewayFactories = []) { $registry = new SimpleRegistry($gateways, $storages, $gatewayFactories); $registry->setAddStorageExtensions(false); if ($this->gatewayConfigStorage) { $dynamicRegistry = new DynamicRegistry($this->gatewayConfigStorage, $registry); $dynamicRegistry->setBackwardCompatibility(false); $registry = new FallbackRegistry($dynamicRegistry, $registry); } if ($this->mainRegistry) { $registry = new FallbackRegistry($this->mainRegistry, $registry); } return $registry; }