/** * @test */ public function shouldCallStaticRegistryIfGatewayConfigNotFoundOnGetGateway() { $staticRegistryMock = $this->createRegistryMock(); $staticRegistryMock->expects($this->once())->method('getGateway')->with('theGatewayName')->willReturn('theGateway'); $staticRegistryMock->expects($this->never())->method('getGatewayFactory'); $storageMock = $this->createStorageMock(); $storageMock->expects($this->once())->method('findBy')->with(array('gatewayName' => 'theGatewayName'))->willReturn(null); $registry = new DynamicRegistry($storageMock, $staticRegistryMock); $this->assertSame('theGateway', $registry->getGateway('theGatewayName')); }
/** * @test * * @expectedException \Payum\Core\Exception\InvalidArgumentException * @expectedExceptionMessage Gateway "theGatewayName" does not exist. */ public function throwIfGatewayConfigNotFoundOnGetGateway() { $gatewayFactoryRegistry = $this->createGatewayFactoryRegistryMock(); $gatewayFactoryRegistry->expects($this->never())->method('getGatewayFactory'); $storageMock = $this->createStorageMock(); $storageMock->expects($this->once())->method('findBy')->with(array('gatewayName' => 'theGatewayName'))->willReturn(null); $registry = new DynamicRegistry($storageMock, $gatewayFactoryRegistry); $registry->setBackwardCompatibility(false); $registry->getGateway('theGatewayName'); }