/home/desid573/public_html/app/braintree/tests/unit
NameSizeModeActions
ClientApi/-0755rm
Result/-0755rm
AddOnTest.php8870644editdlrm
AddressTest.php22930644editdlrm
AuthorizationAdjustmentTest.php10600644editdlrm
BraintreeTest.php7010644editdlrm
ConfigurationTest.php183930644editdlrm
CreditCardTest.php50680644editdlrm
CreditCardVerificationTest.php7470644editdlrm
CustomerTest.php19360644editdlrm
DigestTest.php35600644editdlrm
DisbursementDetailsTest.php6180644editdlrm
DisbursementTest.php32150644editdlrm
DiscountTest.php9280644editdlrm
DisputeTest.php168530644editdlrm
DocumentUploadTest.php4340644editdlrm
EndsWithNodeTest.php3430644editdlrm
GatewayTest.php16500644editdlrm
HttpTest.php20560644editdlrm
InstanceTest.php10830644editdlrm
MerchantAccountTest.php31190644editdlrm
MultipleValueNodeTest.php5660644editdlrm
MultipleValueOrTextNodeTest.php14700644editdlrm
OAuthAccessRevocationTest.php3990644editdlrm
OAuthTest.php19470644editdlrm
PaginatedCollectionTest.php27000644editdlrm
PaymentMethodTest.php44070644editdlrm
PayPalAccountTest.php13070644editdlrm
RangeNodeTest.php10120644editdlrm
ResourceCollectionTest.php29180644editdlrm
SanityTest.php5150644editdlrm
SubscriptionSearchTest.php21510644editdlrm
SubscriptionTest.php5060644editdlrm
TextNodeTest.php10860644editdlrm
TransactionLineItemTest.php5720644editdlrm
TransactionTest.php43000644editdlrm
TransparentRedirectTest.php10330644editdlrm
UnknownPaymentMethodTest.php7700644editdlrm
UsBankAccountTest.php17680644editdlrm
UsBankAccountVerificationTest.php9410644editdlrm
UtilTest.php129980644editdlrm
WebhookNotificationTest.php400530644editdlrm
Xml_GeneratorTest.php29750644editdlrm
Xml_ParserTest.php186680644editdlrm
Edit: /home/desid573/public_html/app/braintree/tests/unit/Xml_ParserTest.php (18668B)
123'); $this->assertEquals($array, ['root' => ['foo' => 123]]); } public function testDashesUnderscores() { $xml =<< XML; $array = Braintree\Xml::buildArrayFromXml($xml); $this->assertEquals(['root' => ['dashEs' => '', 'underScores' => '']], $array); } public function testCustomFieldsUnderscore() { $xml =<< convert to underscore XML; $array = Braintree\Xml::buildArrayFromXml($xml); $this->assertEquals(['root' => ['customFields' => ['with_dashes' => 'convert to underscore']]], $array); } public function testNullOrEmptyString() { $xml = << XML; $array = Braintree\Xml::buildArrayFromXml($xml); $this->assertEquals(['root' => ['aNilValue' => null, 'anEmptyString' => '']], $array); } public function testTypeCastsDatetimes() { $xml = << 2009-10-28T10:19:49Z XML; $array = Braintree\Xml::buildArrayFromXml($xml); date_default_timezone_set('UTC'); $dateTime = new DateTime('2009-10-28T10:19:49', new DateTimeZone('UTC')); $this->assertEquals(['root' => ['createdAt' => $dateTime]], $array); $this->assertInstanceOf('DateTime', $array['root']['createdAt']); } public function testTypeCastsDates() { $xml = << 2009-10-28 XML; $array = Braintree\Xml::buildArrayFromXml($xml); date_default_timezone_set('UTC'); $dateTime = new DateTime('2009-10-28', new DateTimeZone('UTC')); $this->assertEquals(['root' => ['someDate' => $dateTime]], $array); } public function testBuildsArray() { $xml = << Adam Ben XML; $array = Braintree\Xml::buildArrayFromXml($xml); $this->assertEquals(['root' => ['customers' => [['name' => 'Adam'], ['name' => 'Ben']] ] ], $array ); } public function testReturnsBoolean() { $xml = << true 1 false anything true XML; $array = Braintree\Xml::buildArrayFromXml($xml); $this->assertEquals( ['root' => ['castedTrue' => true, 'castedOne' => true, 'castedFalse' => false, 'castedAnything' => false, 'uncastedTrue' => 'true'] ], $array); } public function testEmptyArrayAndNestedElements() { $xml = << 1 XML; $array = Braintree\Xml::buildArrayFromXml($xml); $this->assertEquals( ['root' => [ 'noValues' => [], 'nestedValues' => [ 'value' => 1 ] ] ], $array); } public function testParsingNilEqualsTrueAfterArray() { $xml = << Dan XML; $array = Braintree\Xml::buildArrayFromXml($xml); $this->assertEquals(null, $array['root']['blank']); } public function testTransactionParsingNil() { $xml = << 8ysndw settled sale USD 1.00 default 2010-04-01T19:32:23Z 2010-04-02T08:05:35Z First Last Widgets Inc 1234 My Street Apt 1 Ottawa ON K1C2N6 Canada M M M 13390 1000 Approved 510510 5100 MasterCard 09 2011 US 2010-04-01T19:32:24Z authorized 1.00 dmanges-am API 2010-04-01T19:32:25Z submitted_for_settlement 1.00 dmanges-am API 2010-04-02T08:05:36Z settled 1.00 XML; $array = Braintree\Xml::buildArrayFromXml($xml); $this->assertEquals(null, $array['transaction']['avsErrorResponseCode']); $this->assertEquals(null, $array['transaction']['refundId']); $this->assertEquals(null, $array['transaction']['orderId']); $this->assertEquals(null, $array['transaction']['channel']); $this->assertEquals(null, $array['transaction']['customer']['fax']); $this->assertEquals(null, $array['transaction']['creditCard']['token']); $this->assertEquals(null, $array['transaction']['creditCard']['cardholderName']); $this->assertEquals('First', $array['transaction']['customer']['firstName']); $this->assertEquals('Approved', $array['transaction']['processorResponseText']); } public function testParsingWithNodeHavingSameNameAsNodesDirectlyUnderCollection() { $xml = << 50 one two bug was here END; $array = Braintree\Xml::buildArrayFromXml($xml); $this->assertEquals(['baz' => 'two', 'bar' => 'bug was here'], $array['foos']['bar'][1]); } public function testParsingCreditCardSearchResults() { $xml = << 1 50 8 411111 John Doe Visa 2010-07-02T15:50:51Z 589636 true 05 2009 true US 1111 22pb 2010-07-02T15:50:51Z 411111 Visa 2010-07-02T15:52:09Z 613603 false 05 2009 true US 1111 hzjh8b 54.32 integration_trialless_plan 2010-07-02 2010-08-02 2010-07-02 2010-08-01 sandbox_credit_card false Active 0 3wx6 2dpk76 submitted_for_settlement sale USD 54.32 sandbox_credit_card 2010-07-02T15:52:09Z 2010-07-02T15:52:09Z 613603 Mike Jones I I I 9ZR5QB 1000 Approved sb8w 411111 1111 Visa 05 2010 US 2010-07-02T15:52:09Z authorized 54.32 merchant Recurring 2010-07-02T15:52:09Z submitted_for_settlement 54.32 merchant Recurring hzjh8b 3wx6 2010-07-02T15:52:09Z END; $array = Braintree\Xml::buildArrayFromXml($xml); $creditCards = $array['paymentMethods']['creditCard']; $creditCardWithSubscription = $creditCards[1]; $transaction = $creditCardWithSubscription['subscriptions'][0]['transactions'][0]; $this->assertEquals('411111', $transaction['creditCard']['bin']); $this->assertEquals('1111', $transaction['creditCard']['last4']); $this->assertEquals('Visa', $transaction['creditCard']['cardType']); } public function xmlAndBack($array) { $xml = Braintree\Xml::buildXmlFromArray($array); return Braintree\Xml::buildArrayFromXml($xml); } public function testSimpleCaseRoundtrip() { $array = ['root' => [ 'foo' => 'fooValue', 'bar' => 'barValue'] ]; $array2 = $this->xmlAndBack($array); $this->assertEquals($array, $array2); } public function testArrayRoundtrip() { $array = ['root' => [ 'items' => [ ['name' => 'first'], ['name' => 'second'], ] ]]; $array2 = $this->xmlAndBack($array); $this->assertEquals($array, $array2); } public function testBooleanRoundtrip() { $array = ['root' => [ 'stringTrue' => true, 'boolTrue' => true, 'stringFalse' => false, 'boolFalse' => false, ]]; $array2 = $this->xmlAndBack($array); $this->assertEquals($array, $array2); } public function testTimestampRoundtrip() { date_default_timezone_set('UTC'); $array = ['root' => [ 'aTimestamp' => date('D M d H:i:s e Y', mktime(1, 2, 3, 10, 28, 2009)), ]]; $array2 = $this->xmlAndBack($array); $this->assertEquals($array, $array2); } public function testNullvsEmptyStringToXml() { $array = ['root' => [ 'anEmptyString' => '', 'aNullValue' => null, ]]; $xml = Braintree\Xml::buildXmlFromArray($array); $xml2 =<< XML; $this->assertEquals($xml, $xml2); } public function testIncludesTheEncodingRoundtrip() { $array = ['root' => [ 'root' => 'bar', ]]; $xml = Braintree\Xml::buildXmlFromArray($array); $this->assertRegExp('<\?xml version=\"1.0\" encoding=\"UTF-8\"\?>', $xml); } public function testRootNodeAndStringRoundtrip() { $array = ['id' => '123']; $array2 = $this->xmlAndBack($array); $this->assertEquals($array, $array2); } }