/** * @test */ public function shouldInitializeStorageExtensionsForEachStorageInRegistry() { $storageOneMock = $this->getMock('Payum\\Core\\Storage\\StorageInterface'); $storageTwoMock = $this->getMock('Payum\\Core\\Storage\\StorageInterface'); $storageThreeMock = $this->getMock('Payum\\Core\\Storage\\StorageInterface'); $gatewayFooMock = $this->getMock('Payum\\Core\\Gateway'); $gatewayFooMock->expects($this->exactly(3))->method('addExtension'); $gatewayBarMock = $this->getMock('Payum\\Core\\Gateway'); $gatewayBarMock->expects($this->exactly(3))->method('addExtension'); $registry = new SimpleRegistry(array('foo' => $gatewayFooMock, 'bar' => $gatewayBarMock), array('fooClass' => $storageOneMock, 'barClass' => $storageTwoMock, 'ololClass' => $storageThreeMock)); $registry->getGateway('foo'); $registry->getGateway('bar'); }
/** * @test */ public function shouldNotInitializeStorageExtensionsIfAddStorageExtensionsSetFalse() { $storageOneMock = $this->getMock(StorageInterface::class); $storageTwoMock = $this->getMock(StorageInterface::class); $storageThreeMock = $this->getMock(StorageInterface::class); $gatewayFooMock = $this->getMock(Gateway::class); $gatewayFooMock->expects($this->never())->method('addExtension'); $gatewayBarMock = $this->getMock(Gateway::class); $gatewayBarMock->expects($this->never())->method('addExtension'); $registry = new SimpleRegistry(array('foo' => $gatewayFooMock, 'bar' => $gatewayBarMock), array('fooClass' => $storageOneMock, 'barClass' => $storageTwoMock, 'ololClass' => $storageThreeMock)); $registry->setAddStorageExtensions(false); $registry->getGateway('foo'); $registry->getGateway('bar'); }