From 2ae592569006cf8187a80384626f796011fe309f Mon Sep 17 00:00:00 2001 From: Craig Paul Date: Wed, 19 Oct 2016 09:22:12 -0600 Subject: [PATCH] Adds Moneris tests --- tests/MonerisTest.php | 102 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tests/MonerisTest.php diff --git a/tests/MonerisTest.php b/tests/MonerisTest.php new file mode 100644 index 0000000..e6f4f3a --- /dev/null +++ b/tests/MonerisTest.php @@ -0,0 +1,102 @@ +id = 'store1'; + $this->token = 'yesguy'; + $this->params = [ + 'environment' => Moneris::ENV_TESTING + ]; + } + + /** @test */ + public function it_can_instantiate_via_the_constructor() + { + $moneris = new Moneris($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); + } + + /** @test */ + public function it_can_instantiate_via_a_static_create_method() + { + $moneris = 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); + } + + /** @test */ + public function it_can_access_properties_of_the_class() + { + $moneris = new Moneris($this->id, $this->token, $this->params); + + $this->assertEquals($this->id, $moneris->id); + $this->assertEquals($this->token, $moneris->token); + $this->assertEquals($this->params['environment'], $moneris->environment); + $this->assertEquals($this->params, $moneris->params); + } + + /** @test */ + public function it_fails_to_retrieve_a_non_existent_property_of_the_class() + { + $moneris = new Moneris($this->id, $this->token, $this->params); + + $this->expectException(InvalidArgumentException::class); + + $moneris->nonExistentProperty; + } + + /** @test */ + public function it_can_retrieve_the_gateway_for_moneris() + { + $moneris = new Moneris($this->id, $this->token, $this->params); + + $gateway = $moneris->gateway(); + + $this->assertEquals(Gateway::class, get_class($gateway)); + $this->assertObjectHasAttribute('id', $gateway); + $this->assertObjectHasAttribute('token', $gateway); + $this->assertObjectHasAttribute('environment', $gateway); + } +} \ No newline at end of file