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

Commit

Permalink
Updates receipt reading method for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Oct 25, 2016
1 parent 2286c2c commit 42ce4b4
Showing 1 changed file with 43 additions and 46 deletions.
89 changes: 43 additions & 46 deletions tests/VaultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ public function it_can_add_a_credit_card_to_the_moneris_vault_and_returns_a_data
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertNotNull($receipt->DataKey);
$this->assertNotNull($receipt->read('key'));
}

/** @test */
public function it_can_update_a_credit_card_in_the_moneris_vault_and_returns_a_data_key_for_storage()
{
$response = $this->vault->add($this->card);
$key = $response->receipt()->DataKey;
$key = $response->receipt()->read('key');

$this->assertEquals('2012', $response->transaction->params['expdate']);

Expand All @@ -84,28 +84,27 @@ public function it_can_update_a_credit_card_in_the_moneris_vault_and_returns_a_d
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertNotNull($receipt->DataKey);
$this->assertEquals($key, $receipt->DataKey);
$this->assertNotNull($receipt->read('key'));
$this->assertEquals($key, $receipt->read('key'));
$this->assertEquals('2112', $response->transaction->params['expdate']);
}

/** @test */
public function it_can_delete_a_credit_card_from_the_moneris_vault_and_returns_a_data_key_for_storage()
{
$response = $this->vault->add($this->card);
$key = $response->receipt()->DataKey;
$key = $response->receipt()->read('key');

$response = $this->vault->delete($key);
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertNotNull($receipt->DataKey);
$this->assertEquals($key, $receipt->DataKey);
$this->assertNotNull($receipt->read('key'));
$this->assertEquals($key, $receipt->read('key'));
}

/** @test */
public function it_can_tokenize_a_previous_transaction_to_add_the_transactions_credit_card_in_the_moneris_vault_and_returns_a_data_key_for_storage(
)
public function it_can_tokenize_a_previous_transaction_to_add_the_transactions_credit_card_in_the_moneris_vault_and_returns_a_data_key_for_storage()
{
$gateway = Moneris::create($this->id, $this->token, ['environment' => Moneris::ENV_TESTING]);

Expand All @@ -120,42 +119,42 @@ public function it_can_tokenize_a_previous_transaction_to_add_the_transactions_c
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertNotNull($receipt->DataKey);
$this->assertNotNull($receipt->read('key'));
}

/** @test */
public function it_can_peek_into_the_vault_and_retrieve_a_masked_credit_card_from_the_moneris_vault_with_a_valid_data_key(
)
public function it_can_peek_into_the_vault_and_retrieve_a_masked_credit_card_from_the_moneris_vault_with_a_valid_data_key()
{
$response = $this->vault->add($this->card);
$key = $response->receipt()->DataKey;
$key = $response->receipt()->read('key');

$response = $this->vault->peek($key);
$receipt = $response->receipt();
$beginning = substr($this->visa, 0, 4);
$end = substr($this->visa, -4, 4);

$this->assertTrue($response->successful);
$this->assertNotNull($receipt->DataKey);
$this->assertEquals('2012', $receipt->ResolveData->expdate);
$this->assertEquals($beginning, substr($receipt->ResolveData->masked_pan, 0, 4));
$this->assertEquals($end, substr($receipt->ResolveData->masked_pan, -4, 4));
$this->assertNotNull($receipt->read('key'));
$this->assertEquals('12', $receipt->read('data')['expiry_date']['month']);
$this->assertEquals('20', $receipt->read('data')['expiry_date']['year']);
$this->assertEquals($beginning, substr($receipt->read('data')['masked_pan'], 0, 4));
$this->assertEquals($end, substr($receipt->read('data')['masked_pan'], -4, 4));
}

/** @test */
public function it_can_peek_into_the_vault_and_retrieve_a_full_credit_card_from_the_moneris_vault_with_a_valid_data_key(
)
public function it_can_peek_into_the_vault_and_retrieve_a_full_credit_card_from_the_moneris_vault_with_a_valid_data_key()
{
$response = $this->vault->add($this->card);
$key = $response->receipt()->DataKey;
$key = $response->receipt()->read('key');

$response = $this->vault->peek($key, true);
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertNotNull($receipt->DataKey);
$this->assertEquals('2012', $receipt->ResolveData->expdate);
$this->assertEquals($this->visa, $receipt->ResolveData->pan);
$this->assertNotNull($receipt->read('key'));
$this->assertEquals('12', $receipt->read('data')['expiry_date']['month']);
$this->assertEquals('20', $receipt->read('data')['expiry_date']['year']);
$this->assertEquals($this->visa, $receipt->read('data')['pan']);
}

/** @test */
Expand All @@ -174,14 +173,14 @@ public function it_can_retrieve_all_expiring_credit_cards_from_the_moneris_vault
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertGreaterThan(0, count($receipt->ResolveData));
$this->assertGreaterThan(0, count($receipt->read('data')));
}

/** @test */
public function it_can_make_a_purchase_with_a_credit_card_stored_in_the_moneris_vault()
{
$response = $this->vault->add($this->card);
$key = $response->receipt()->DataKey;
$key = $response->receipt()->read('key');

$params = array_merge($this->params, [
'data_key' => $key,
Expand All @@ -191,8 +190,8 @@ public function it_can_make_a_purchase_with_a_credit_card_stored_in_the_moneris_
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertEquals($key, $receipt->DataKey);
$this->assertEquals('true', $receipt->Complete);
$this->assertEquals($key, $receipt->read('key'));
$this->assertEquals(true, $receipt->read('complete'));
}

/** @test */
Expand All @@ -202,7 +201,7 @@ public function it_can_submit_a_cvd_secured_purchase_with_a_credit_card_stored_i
$vault = Moneris::create($this->id, $this->token, $params)->cards();

$response = $this->vault->add($this->card);
$key = $response->receipt()->DataKey;
$key = $response->receipt()->read('key');

$params = array_merge($this->params, [
'data_key' => $key,
Expand All @@ -213,8 +212,8 @@ public function it_can_submit_a_cvd_secured_purchase_with_a_credit_card_stored_i
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertEquals($key, $receipt->DataKey);
$this->assertEquals('true', $receipt->Complete);
$this->assertEquals($key, $receipt->read('key'));
$this->assertEquals(true, $receipt->read('complete'));
}

/** @test */
Expand All @@ -224,7 +223,7 @@ public function it_can_submit_an_avs_secured_purchase_with_a_credit_card_stored_
$vault = Moneris::create($this->id, $this->token, $params)->cards();

$response = $this->vault->add($this->card);
$key = $response->receipt()->DataKey;
$key = $response->receipt()->read('key');

$params = array_merge($this->params, [
'data_key' => $key,
Expand All @@ -237,15 +236,15 @@ public function it_can_submit_an_avs_secured_purchase_with_a_credit_card_stored_
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertEquals($key, $receipt->DataKey);
$this->assertEquals('true', $receipt->Complete);
$this->assertEquals($key, $receipt->read('key'));
$this->assertEquals(true, $receipt->read('complete'));
}

/** @test */
public function it_can_pre_authorize_a_credit_card_stored_in_the_moneris_vault()
{
$response = $this->vault->add($this->card);
$key = $response->receipt()->DataKey;
$key = $response->receipt()->read('key');

$params = array_merge($this->params, [
'data_key' => $key,
Expand All @@ -255,8 +254,8 @@ public function it_can_pre_authorize_a_credit_card_stored_in_the_moneris_vault()
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertEquals($key, $receipt->DataKey);
$this->assertEquals('true', $receipt->Complete);
$this->assertEquals($key, $receipt->read('key'));
$this->assertEquals(true, $receipt->read('complete'));
}

/** @test */
Expand All @@ -266,7 +265,7 @@ public function it_can_submit_a_cvd_secured_pre_authorization_request_for_a_cred
$vault = Moneris::create($this->id, $this->token, $params)->cards();

$response = $this->vault->add($this->card);
$key = $response->receipt()->DataKey;
$key = $response->receipt()->read('key');

$params = array_merge($this->params, [
'data_key' => $key,
Expand All @@ -277,8 +276,8 @@ public function it_can_submit_a_cvd_secured_pre_authorization_request_for_a_cred
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertEquals($key, $receipt->DataKey);
$this->assertEquals('true', $receipt->Complete);
$this->assertEquals($key, $receipt->read('key'));
$this->assertEquals(true, $receipt->read('complete'));
}

/** @test */
Expand All @@ -288,7 +287,7 @@ public function it_can_submit_an_avs_secured_pre_authorization_request_for_a_cre
$vault = Moneris::create($this->id, $this->token, $params)->cards();

$response = $this->vault->add($this->card);
$key = $response->receipt()->DataKey;
$key = $response->receipt()->read('key');

$params = array_merge($this->params, [
'data_key' => $key,
Expand All @@ -301,15 +300,15 @@ public function it_can_submit_an_avs_secured_pre_authorization_request_for_a_cre
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertEquals($key, $receipt->DataKey);
$this->assertEquals('true', $receipt->Complete);
$this->assertEquals($key, $receipt->read('key'));
$this->assertEquals(true, $receipt->read('complete'));
}

/** @test */
public function it_can_capture_a_pre_authorized_credit_card_stored_in_the_moneris_vault()
{
$response = $this->vault->add($this->card);
$key = $response->receipt()->DataKey;
$key = $response->receipt()->read('key');

$params = array_merge($this->params, [
'data_key' => $key,
Expand All @@ -318,10 +317,8 @@ public function it_can_capture_a_pre_authorized_credit_card_stored_in_the_moneri
$response = $this->vault->preauth($params);
$response = $this->vault->capture($response->transaction);
$receipt = $response->receipt();
$key = $receipt->DataKey;

$this->assertTrue($response->successful);
$this->assertEquals($key, $receipt->DataKey);
$this->assertEquals('true', $receipt->Complete);
$this->assertEquals(true, $receipt->read('complete'));
}
}

0 comments on commit 42ce4b4

Please sign in to comment.