Skip to content

Commit

Permalink
Merge pull request #66 from sandervanhooft/master
Browse files Browse the repository at this point in the history
Added wrapper endpoint tests
  • Loading branch information
sandervanhooft authored Aug 25, 2018
2 parents 304e9c4 + 85f4089 commit c087ed3
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/Wrappers/MollieApiWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,47 @@ public function testSetBadToken()
$wrapper = new MollieApiWrapper($this->app['config'], $this->app[MollieApiClient::class]);
$wrapper->setAccessToken('BAD');
}

public function testWrappedEndpoints()
{
$endpoints = [
'customerPayments',
'customers',
'customers',
'invoices',
'mandates',
'methods',
'payments',
'profiles',
'refunds',
'settlements',
'subscriptions',
];

$client = $this->app[MollieApiClient::class];
$wrapper = new MollieApiWrapper(
$this->app['config'],
$client
);

foreach ($endpoints as $endpoint) {
$this->assertWrappedEndpoint($client, $wrapper, $endpoint);
}
}

/**
* Asserts that the referenced wrapper method matches the client attribute
* I.e. $wrapper->payments() returns the same as $client->payments.
*
* @param MollieApiClient $client
* @param MollieApiWrapper $wrapper
* @param string $reference
* @return null
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
protected function assertWrappedEndpoint($client, $wrapper, $reference)
{
$this->assertEquals($client->$reference, $wrapper->$reference());
}
}

0 comments on commit c087ed3

Please sign in to comment.