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

Commit

Permalink
Changes static moneris constructor to return Gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Oct 21, 2016
1 parent 2a45ff4 commit 61145f4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/Moneris.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ public function __construct(string $id, string $token, array $params = [])
* @param string $token
* @param array $params
*
* @return $this
* @return \CraigPaul\Moneris\Gateway
*/
public static function create(string $id, string $token, array $params = [])
{
return new static($id, $token, $params);
$moneris = new static($id, $token, $params);

return $moneris->connect();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/GatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function setUp()
parent::setUp();

$params = ['environment' => $this->environment];
$this->gateway = Moneris::create($this->id, $this->token, $params)->connect();
$this->gateway = Moneris::create($this->id, $this->token, $params);
$this->params = [
'order_id' => uniqid('1234-56789', true),
'amount' => '1.00',
Expand Down
13 changes: 6 additions & 7 deletions tests/MonerisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ public function it_can_instantiate_via_the_constructor()
}

/** @test */
public function it_can_instantiate_via_a_static_create_method()
public function it_can_instantiate_via_a_static_create_method_and_return_the_gateway()
{
$moneris = Moneris::create($this->id, $this->token, $this->params);
$gateway = Moneris::create($this->id, $this->token, $this->params);

$this->assertEquals(Moneris::class, get_class($moneris));
$this->assertObjectHasAttribute('id', $moneris);
$this->assertObjectHasAttribute('token', $moneris);
$this->assertObjectHasAttribute('environment', $moneris);
$this->assertObjectHasAttribute('params', $moneris);
$this->assertEquals(Gateway::class, get_class($gateway));
$this->assertObjectHasAttribute('id', $gateway);
$this->assertObjectHasAttribute('token', $gateway);
$this->assertObjectHasAttribute('environment', $gateway);
}

/** @test */
Expand Down
6 changes: 3 additions & 3 deletions tests/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function setUp()
parent::setUp();

$this->params = ['environment' => Moneris::ENV_TESTING];
$this->gateway = Moneris::create($this->id, $this->token, $this->params)->connect();
$this->gateway = Moneris::create($this->id, $this->token, $this->params);
$this->params = [
'type' => 'purchase',
'crypt_type' => Crypt::SSL_ENABLED_MERCHANT,
Expand Down Expand Up @@ -74,7 +74,7 @@ public function it_can_submit_a_proper_request_to_the_moneris_api()
public function it_can_submit_a_avs_secured_request_to_the_moneris_api()
{
$params = ['environment' => Moneris::ENV_TESTING, 'avs' => true];
$gateway = Moneris::create($this->id, $this->token, $params)->connect();
$gateway = Moneris::create($this->id, $this->token, $params);
$response = $gateway->purchase([
'order_id' => uniqid('1234-56789', true),
'amount' => '1.00',
Expand All @@ -92,7 +92,7 @@ public function it_can_submit_a_avs_secured_request_to_the_moneris_api()
public function it_can_submit_a_cvd_secured_request_to_the_moneris_api()
{
$params = ['environment' => Moneris::ENV_TESTING, 'cvd' => true];
$gateway = Moneris::create($this->id, $this->token, $params)->connect();
$gateway = Moneris::create($this->id, $this->token, $params);
$response = $gateway->purchase([
'order_id' => uniqid('1234-56789', true),
'amount' => '1.00',
Expand Down
2 changes: 1 addition & 1 deletion tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function setUp()
parent::setUp();

$this->params = ['environment' => Moneris::ENV_TESTING];
$this->gateway = Moneris::create($this->id, $this->token, $this->params)->connect();
$this->gateway = Moneris::create($this->id, $this->token, $this->params);
$this->params = [
'type' => 'purchase',
'crypt_type' => Crypt::SSL_ENABLED_MERCHANT,
Expand Down
2 changes: 1 addition & 1 deletion tests/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function setUp()
parent::setUp();

$this->params = ['environment' => Moneris::ENV_TESTING];
$this->gateway = Moneris::create($this->id, $this->token, $this->params)->connect();
$this->gateway = Moneris::create($this->id, $this->token, $this->params);
$this->params = [
'type' => 'purchase',
'order_id' => uniqid('1234-56789', true),
Expand Down

0 comments on commit 61145f4

Please sign in to comment.