/** * @test */ public function couldBeConstructedWithSourceModelAndToAndOptionnalToken() { $request = new Convert($source = new \stdClass(), $to = 'array', $token = $this->getMock(TokenInterface::class)); $this->assertSame($source, $request->getSource()); $this->assertSame($to, $request->getTo()); $this->assertSame($token, $request->getToken()); $this->assertNull($request->getResult()); }
function it_supports_only_converting_to_array_from_payment(Convert $fromSomethingElseToSomethingElseRequest, Convert $fromPaymentToArrayRequest, PaymentInterface $payment, PaymentMethodInterface $method) { $fromPaymentToArrayRequest->getTo()->willReturn('array'); $fromPaymentToArrayRequest->getSource()->willReturn($payment); $fromSomethingElseToSomethingElseRequest->getTo()->willReturn('json'); $fromSomethingElseToSomethingElseRequest->getSource()->willReturn($method); $this->supports($fromPaymentToArrayRequest)->shouldReturn(true); $this->supports($fromSomethingElseToSomethingElseRequest)->shouldReturn(false); }
function it_throws_exception_when_source_is_not_a_payment_interface(Convert $request) { $request->getSource()->willReturn(null); $this->shouldThrow(RequestNotSupportedException::class)->during('execute', [$request]); }