diff --git a/.travis.yml b/.travis.yml index 44c7349e8..d575ed51a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ php: env: global: - - STRIPE_MOCK_VERSION=0.5.0 + - STRIPE_MOCK_VERSION=0.8.0 matrix: - AUTOLOAD=1 - AUTOLOAD=0 diff --git a/init.php b/init.php index 690a237fc..5864cb01c 100644 --- a/init.php +++ b/init.php @@ -92,6 +92,7 @@ require(dirname(__FILE__) . '/lib/SubscriptionItem.php'); require(dirname(__FILE__) . '/lib/ThreeDSecure.php'); require(dirname(__FILE__) . '/lib/Token.php'); +require(dirname(__FILE__) . '/lib/Topup.php'); require(dirname(__FILE__) . '/lib/Transfer.php'); require(dirname(__FILE__) . '/lib/TransferReversal.php'); diff --git a/lib/Topup.php b/lib/Topup.php new file mode 100644 index 000000000..33d081e31 --- /dev/null +++ b/lib/Topup.php @@ -0,0 +1,32 @@ + 'Stripe\\SubscriptionItem', 'three_d_secure' => 'Stripe\\ThreeDSecure', 'token' => 'Stripe\\Token', + 'topup' => 'Stripe\\Topup', 'transfer' => 'Stripe\\Transfer', 'transfer_reversal' => 'Stripe\\TransferReversal', ]; diff --git a/tests/Stripe/ProductTest.php b/tests/Stripe/ProductTest.php index 4d873cb06..c2a3813c8 100644 --- a/tests/Stripe/ProductTest.php +++ b/tests/Stripe/ProductTest.php @@ -34,7 +34,8 @@ public function testIsCreatable() '/v1/products' ); $resource = Product::create([ - 'name' => 'name' + 'name' => 'name', + 'type' => 'good' ]); $this->assertInstanceOf("Stripe\\Product", $resource); } diff --git a/tests/Stripe/TopupTest.php b/tests/Stripe/TopupTest.php new file mode 100644 index 000000000..994447636 --- /dev/null +++ b/tests/Stripe/TopupTest.php @@ -0,0 +1,69 @@ +expectsRequest( + 'get', + '/v1/topups' + ); + $resources = Topup::all(); + $this->assertTrue(is_array($resources->data)); + $this->assertInstanceOf("Stripe\\Topup", $resources->data[0]); + } + + public function testIsRetrievable() + { + $this->expectsRequest( + 'get', + '/v1/topups/' . self::TEST_RESOURCE_ID + ); + $resource = Topup::retrieve(self::TEST_RESOURCE_ID); + $this->assertInstanceOf("Stripe\\Topup", $resource); + } + + public function testIsCreatable() + { + $this->expectsRequest( + 'post', + '/v1/topups' + ); + $resource = Topup::create([ + "amount" => 100, + "currency" => "usd", + "source" => "tok_123", + "description" => "description", + "statement_descriptor" => "statement descriptor" + ]); + $this->assertInstanceOf("Stripe\\Topup", $resource); + } + + public function testIsSaveable() + { + $resource = Topup::retrieve(self::TEST_RESOURCE_ID); + $resource->metadata["key"] = "value"; + $this->expectsRequest( + 'post', + '/v1/topups/' . $resource->id + ); + $resource->save(); + $this->assertInstanceOf("Stripe\\Topup", $resource); + } + + public function testIsUpdatable() + { + $this->expectsRequest( + 'post', + '/v1/topups/' . self::TEST_RESOURCE_ID + ); + $resource = Topup::update(self::TEST_RESOURCE_ID, [ + "metadata" => ["key" => "value"], + ]); + $this->assertInstanceOf("Stripe\\Topup", $resource); + } +}