-
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.
[API V2] Client Library and Doc Update - PHP
Description: Created CurrencyPercentageTier and PercentageTier resources. Created test cases to new resources. Updated test cases of Addon and Subscription.
- Loading branch information
1 parent
e9ba50f
commit a308f0f
Showing
11 changed files
with
537 additions
and
33 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
|
||
class Recurly_CurrencyPercentageTierTest extends Recurly_TestCase | ||
{ | ||
public function testCreateXml() { | ||
$percentageTierByCurrency = new Recurly_CurrencyPercentageTier(); | ||
$percentageTierByCurrency->ending_amount_in_cents = 100; | ||
$percentageTierByCurrency->usage_percentage = '10.0'; | ||
|
||
$doc = new DOMDocument("1.0"); | ||
$root = $doc->appendChild($doc->createElement('tiers')); | ||
$percentageTierByCurrency->populateXmlDoc($doc, $root, $percentageTierByCurrency); | ||
|
||
$this->assertXmlStringEqualsXmlString( | ||
"<tiers> | ||
<tier> | ||
<ending_amount_in_cents>100</ending_amount_in_cents> | ||
<usage_percentage>10.0</usage_percentage> | ||
</tier> | ||
</tiers>", $doc->saveXml()); | ||
} | ||
|
||
public function testCreateXml_EmptyCreatesNoElement() { | ||
$percentageTierByCurrency = new Recurly_CurrencyPercentageTier(); | ||
|
||
$doc = new DOMDocument("1.0"); | ||
$root = $doc->appendChild($doc->createElement('wrapper')); | ||
$percentageTierByCurrency->populateXmlDoc($doc, $root, $percentageTierByCurrency); | ||
|
||
$this->assertEquals( | ||
"<?xml version=\"1.0\"?>\n<wrapper/>\n", | ||
$doc->saveXml() | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
|
||
class Recurly_PercentageTierTest extends Recurly_TestCase | ||
{ | ||
public function testCreateXml() { | ||
$percentageTier = new Recurly_PercentageTier(); | ||
$percentageTier->currency = 'USD'; | ||
$percentageTierByCurrency = new Recurly_CurrencyPercentageTier(); | ||
$percentageTierByCurrency->ending_amount_in_cents = 100; | ||
$percentageTierByCurrency->usage_percentage = '10.0'; | ||
$percentageTierByCurrency2 = new Recurly_CurrencyPercentageTier(); | ||
$percentageTierByCurrency2->ending_amount_in_cents = null; | ||
$percentageTierByCurrency2->usage_percentage = '20.0'; | ||
$percentageTier->tiers = array($percentageTierByCurrency, $percentageTierByCurrency2); | ||
|
||
$doc = new DOMDocument("1.0"); | ||
$root = $doc->appendChild($doc->createElement('percentage_tiers')); | ||
$percentageTier->populateXmlDoc($doc, $root, $percentageTier); | ||
|
||
$this->assertXmlStringEqualsXmlString( | ||
"<percentage_tiers> | ||
<percentage_tier> | ||
<currency>USD</currency> | ||
<tiers> | ||
<tier> | ||
<ending_amount_in_cents>100</ending_amount_in_cents> | ||
<usage_percentage>10.0</usage_percentage> | ||
</tier> | ||
<tier> | ||
<ending_amount_in_cents nil=\"nil\"/> | ||
<usage_percentage>20.0</usage_percentage> | ||
</tier> | ||
</tiers> | ||
</percentage_tier> | ||
</percentage_tiers>", $doc->saveXml()); | ||
} | ||
|
||
public function testCreateXml_EmptyCreatesNoElement() { | ||
$percentageTier = new Recurly_PercentageTier(); | ||
|
||
$doc = new DOMDocument("1.0"); | ||
$root = $doc->appendChild($doc->createElement('wrapper')); | ||
$percentageTier->populateXmlDoc($doc, $root, $percentageTier); | ||
|
||
$this->assertEquals( | ||
"<?xml version=\"1.0\"?>\n<wrapper/>\n", | ||
$doc->saveXml() | ||
); | ||
} | ||
} |
Oops, something went wrong.