From 59706d0b05906a5da9248cfdb8990da1553a1df8 Mon Sep 17 00:00:00 2001 From: Craig Paul Date: Wed, 19 Oct 2016 13:34:15 -0600 Subject: [PATCH] Adds transaction tests --- tests/TransactionTest.php | 69 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/TransactionTest.php diff --git a/tests/TransactionTest.php b/tests/TransactionTest.php new file mode 100644 index 0000000..bf622aa --- /dev/null +++ b/tests/TransactionTest.php @@ -0,0 +1,69 @@ +params = ['environment' => Moneris::ENV_TESTING]; + $this->gateway = Moneris::create($this->id, $this->token, $this->params)->connect(); + $this->params = [ + 'order_id' => '1234-567890', + 'amount' => '1.00', + 'pan' => $this->visa, + 'expdate' => '2012', + ]; + $this->transaction = new Transaction($this->gateway, $this->params); + } + + /** @test */ + public function it_can_access_properties_of_the_class() + { + $this->assertEquals($this->gateway, $this->transaction->gateway); + $this->assertEquals($this->params, $this->transaction->params); + } + + /** @test */ + public function it_can_prepare_parameters_that_were_submitted_improperly() + { + $order = ' 1234-567890'; + $card = '4242 4242 4242 4242'; + $transaction = new Transaction($this->gateway, [ + 'order_id' => $order, + 'amount' => '1.00', + 'pan' => $card, + 'expdate' => '2012', + ]); + + $this->assertEquals(trim($order), $transaction->params['order_id']); + $this->assertEquals(preg_replace('/\D/', '', $card), $transaction->params['pan']); + } +} \ No newline at end of file