From 8047a03cab7501b32367fc4d0720dd4e8202f62d Mon Sep 17 00:00:00 2001 From: Craig Paul Date: Wed, 19 Oct 2016 16:33:42 -0600 Subject: [PATCH] Adds response tests --- tests/ResponseTest.php | 92 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 tests/ResponseTest.php diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php new file mode 100644 index 0000000..08fe85b --- /dev/null +++ b/tests/ResponseTest.php @@ -0,0 +1,92 @@ +params = ['environment' => Moneris::ENV_TESTING]; + $this->gateway = Moneris::create($this->id, $this->token, $this->params)->connect(); + $this->params = [ + 'type' => 'purchase', + 'crypt_type' => Crypt::SSL_ENABLED_MERCHANT, + 'order_id' => uniqid('1234-56789', true), + 'amount' => '1.00', + 'pan' => $this->visa, + 'expdate' => '2012', + ]; + $this->transaction = new Transaction($this->gateway, $this->params); + } + + /** @test */ + public function it_can_instantiate_via_the_constructor() + { + $response = new Response($this->transaction); + + $this->assertEquals(Response::class, get_class($response)); + $this->assertObjectHasAttribute('status', $response); + $this->assertObjectHasAttribute('successful', $response); + $this->assertObjectHasAttribute('transaction', $response); + } + + /** @test */ + public function it_can_instantiate_via_a_static_create_method() + { + $response = Response::create($this->transaction); + + $this->assertEquals(Response::class, get_class($response)); + $this->assertObjectHasAttribute('status', $response); + $this->assertObjectHasAttribute('successful', $response); + $this->assertObjectHasAttribute('transaction', $response); + } + + /** @test */ + public function it_can_validate_an_api_response_from_a_proper_transaction() + { + $response = Processor::process($this->transaction); + + $response = $response->validate(); + + $this->assertTrue($response->successful); + } +} \ No newline at end of file