Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

Commit

Permalink
Adds transaction tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Oct 19, 2016
1 parent b868a88 commit 59706d0
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tests/TransactionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

use CraigPaul\Moneris\Moneris;
use CraigPaul\Moneris\Transaction;

class TransactionTest extends TestCase
{
/**
* The Moneris gateway.
*
* @var \CraigPaul\Moneris\Gateway
*/
protected $gateway;

/**
* The Moneris API parameters.
*
* @var array
*/
protected $params;

/**
* @var \CraigPaul\Moneris\Transaction
*/
protected $transaction;

/**
* Set up the test environment.
*
* @return void
*/
public function setUp()
{
parent::setUp();

$this->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']);
}
}

0 comments on commit 59706d0

Please sign in to comment.