/** * @test */ public function shouldCallStaticRegistryOnGetGateways() { $staticRegistryMock = $this->createRegistryMock(); $staticRegistryMock->expects($this->once())->method('getGateways')->willReturn('theGateways'); $registry = new DynamicRegistry($this->createStorageMock(), $staticRegistryMock); $this->assertEquals('theGateways', $registry->getGateways()); }
/** * @test */ public function shouldCreateGatewaysUsingConfigOnGetGateways() { $factoryName = 'theFactoryName'; $gatewayConfig = new GatewayConfig(); $gatewayConfig->setConfig(array('factory' => $factoryName, 'foo' => 'fooVal', 'bar' => 'barVal')); $gatewayConfig->setGatewayName($gatewayName = 'theGatewayName'); $config = array('foo' => 'fooVal', 'bar' => 'barVal'); $gateway = new Gateway(); $gatewayFactoryMock = $this->getMock(GatewayFactoryInterface::class); $gatewayFactoryMock->expects($this->once())->method('create')->with($config)->willReturn($gateway); $gatewayFactoryRegistry = $this->createGatewayFactoryRegistryMock(); $gatewayFactoryRegistry->expects($this->once())->method('getGatewayFactory')->with($factoryName)->willReturn($gatewayFactoryMock); $storageMock = $this->createStorageMock(); $storageMock->expects($this->at(0))->method('findBy')->with([])->willReturn([$gatewayConfig]); $storageMock->expects($this->at(1))->method('findBy')->with(['gatewayName' => $gatewayName])->willReturn([$gatewayConfig]); $registry = new DynamicRegistry($storageMock, $gatewayFactoryRegistry); $this->assertSame([$gatewayName => $gateway], $registry->getGateways()); }