/** * @test */ public function shouldCallStaticRegistryOnGetStorage() { $staticRegistryMock = $this->createRegistryMock(); $staticRegistryMock ->expects($this->once()) ->method('getStorage') ->with('theName') ->willReturn('theStorage') ; $registry = new DynamicRegistry( $this->createStorageMock(), $staticRegistryMock ); $this->assertEquals('theStorage', $registry->getStorage('theName')); }
/** * @test * * @expectedException \Payum\Core\Exception\InvalidArgumentException * @expectedExceptionMessage Storage for given class "stdClass" does not exist. */ public function alwaysThrowOnGetStorageForObject() { $registry = new DynamicRegistry($this->createStorageMock(), $this->createGatewayFactoryRegistryMock()); $registry->setBackwardCompatibility(false); $registry->getStorage(new \stdClass()); }
/** * @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; }