From a5ba220ae1165cda7e4f6892a04e0ef60a44d240 Mon Sep 17 00:00:00 2001 From: GaryJones Date: Fri, 23 Nov 2012 12:22:04 +0000 Subject: [PATCH] Add tests for concrete method inside abstract SignatureMethod class. --- tests/SignatureMethodTest.php | 80 +++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 tests/SignatureMethodTest.php diff --git a/tests/SignatureMethodTest.php b/tests/SignatureMethodTest.php new file mode 100644 index 0000000..3871dcd --- /dev/null +++ b/tests/SignatureMethodTest.php @@ -0,0 +1,80 @@ +getSignatureMethod(); + + // Get mock objects + $client = $this->getClient(); + + // Run method being tested + $signature_key = $signature_method->getSignatureKey($client); + + // Check results + $this->assertEquals('secret&', $signature_key); + } + + public function testGetSignatureKeyWithToken() + { + // Create instance of class to test, with mock objects passed in. + $signature_method = $this->getSignatureMethod(); + + // Get mock objects + $client = $this->getClient(); + $token = $this->getToken(); + + // Run method being tested + $signature_key = $signature_method->getSignatureKey($client, $token); + + // Check results + $this->assertEquals('secret&token_secret', $signature_key); + } + + private function getSignatureMethod() + { + return new FooBarSignatureMethod; + } + + private function getClient() + { + return m::mock('GaryJones\OAuth\Client', function ($mock) { + $mock->shouldReceive('getSecret')->withNoArgs()->andReturn('secret')->once(); + }); + } + + private function getToken() + { + return m::mock('GaryJones\OAuth\Token', function ($mock) { + $mock->shouldReceive('getSecret')->withNoArgs()->andReturn('token_secret'); + }); + } +}