stripe/stripe-php — pull request #8 by epriestley (2012-04-04 16:14:06+00:00)
Title: Fix some failures in test suite

Summary: The test suite has a few failing tests. Update them so they pass:

- Improved messaging for missing SimpleTest.
- Improved messaging for missing STRIPE_API_KEY.
- Fixed toString() test cases: `Stripe_ChargeTest::testToString()` and `Stripe_ObjectTest::testToString()` are testing for a string format not present in the code. The actual __toString() implementation is just to JSON-encode the object dictionary. Since the encoding depends on the availiblity of JSON_PRETTY_PRINT, I replaced the exact-string test with a valid-JSON test. I removed the Charge-specific test because Stripe_ChargeTest has no code specific to string casting.
- Fixed `Stripe_CustomerTest::testDeletion()`. This test would try to create a customer with fields "amount" and "currency", which are not valid according to the API documentation. The create call would throw an exception to this effect. Instead, create a valid customer.
- Fixed `Stripe_CustomerTest::testSave()`. This test would set a bogus attribute ("bogus") on the object and then try to save it. This would cause the API to throw an exception ("Field 'bogus' is invalid..."). Instead, move the "bogus" test to a new `testBogusAttribute()` test and verify that saving a bogus attribute throws an exception.
- Fixed `Stripe_CustomerTest::testCancelSubscription()`. This test would try to create a customer with a plan that may not exist. This would cause the API to throw an exception ("Plan 'gold' does not exist..."). Instead, make sure the plan exists before creating the customer.
- Fixed `Stripe_InvoiceTest::testUpcoming()`. This test would try to retrieve the upcoming invoice for a customer that does not have an upcoming invoice. This would cause the API to throw an exception ("Customer 'cus_...' does not have..."). Instead, add an invoice item to create an upcoming invoice before querying for the upcoming invoice.
- Moved some utility methods to a base StripeTestCase class.
- Instead of hard-coding a credit card expiry year of 2015, use the current year plus 3, so tests don't unexpectedly fail in June, 2015.
- Added some .gitignore entries.

Test Plan: Ran unit tests, which now pass in my environment.