-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass the client from pager to its items
Fixes #254
- Loading branch information
Showing
3 changed files
with
28 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,42 @@ | ||
<?php | ||
|
||
|
||
class Recurly_BaseTest extends Recurly_TestCase { | ||
// Do a song and dance to gain access to private/protected properties. | ||
function getProtectedProperty($obj, $property) { | ||
$reflection = new \ReflectionClass($obj); | ||
$property = $reflection->getProperty($property); | ||
$property->setAccessible(true); | ||
return $property->getValue($obj); | ||
} | ||
|
||
class Recurly_BaseTest extends Recurly_TestCase { | ||
public function testParsingEmptyXML() { | ||
$this->client->addResponse('GET', 'abcdef1234567890', 'accounts/empty.xml'); | ||
|
||
$account = Recurly_Base::_get('abcdef1234567890', $this->client); | ||
$this->assertNull($account); | ||
} | ||
|
||
public function testPassingClientToPagerItems() { | ||
$this->client->addResponse('GET', 'subscriptions', 'subscriptions/index-200.xml'); | ||
|
||
$subscriptions = Recurly_Base::_get('subscriptions', $this->client); | ||
$this->assertInstanceOf('Recurly_SubscriptionList', $subscriptions); | ||
$this->assertEquals(getProtectedProperty($subscriptions, '_client'), $this->client); | ||
|
||
$subscription = $subscriptions->current(); | ||
$this->assertInstanceOf('Recurly_Subscription', $subscription); | ||
$this->assertEquals(getProtectedProperty($subscription, '_client'), $this->client); | ||
} | ||
|
||
public function testPassingClientToStub() { | ||
$this->client->addResponse('GET', 'abcdef1234567890', 'adjustments/show-200.xml'); | ||
|
||
$adjustment = Recurly_Base::_get('abcdef1234567890', $this->client); | ||
$this->assertInstanceOf('Recurly_Adjustment', $adjustment); | ||
$this->assertInstanceOf('Recurly_Stub', $adjustment->invoice); | ||
|
||
// The client is protected so we do a little song and dance to access it: | ||
$reflection = new \ReflectionClass($adjustment->invoice); | ||
$property = $reflection->getProperty('_client'); | ||
$property->setAccessible(true); | ||
$this->assertEquals($property->getValue($adjustment->invoice), $this->client); | ||
$invoice = $adjustment->invoice; | ||
$this->assertInstanceOf('Recurly_Stub', $invoice); | ||
$this->assertEquals(getProtectedProperty($invoice, '_client'), $this->client); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters