diff --git a/.travis.yml b/.travis.yml index 7cd031e41..d76ebfa10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ php: env: global: - - STRIPE_MOCK_VERSION=0.32.0 + - STRIPE_MOCK_VERSION=0.33.0 matrix: - AUTOLOAD=1 - AUTOLOAD=0 diff --git a/init.php b/init.php index 3f0e5f985..c78718008 100644 --- a/init.php +++ b/init.php @@ -106,6 +106,9 @@ require(dirname(__FILE__) . '/lib/SourceTransaction.php'); require(dirname(__FILE__) . '/lib/Subscription.php'); require(dirname(__FILE__) . '/lib/SubscriptionItem.php'); +require(dirname(__FILE__) . '/lib/Terminal/ConnectionToken.php'); +require(dirname(__FILE__) . '/lib/Terminal/Location.php'); +require(dirname(__FILE__) . '/lib/Terminal/Reader.php'); require(dirname(__FILE__) . '/lib/ThreeDSecure.php'); require(dirname(__FILE__) . '/lib/Token.php'); require(dirname(__FILE__) . '/lib/Topup.php'); diff --git a/lib/Terminal/ConnectionToken.php b/lib/Terminal/ConnectionToken.php new file mode 100644 index 000000000..92a5b997b --- /dev/null +++ b/lib/Terminal/ConnectionToken.php @@ -0,0 +1,17 @@ + 'Stripe\\Subscription', \Stripe\SubscriptionItem::OBJECT_NAME => 'Stripe\\SubscriptionItem', \Stripe\ThreeDSecure::OBJECT_NAME => 'Stripe\\ThreeDSecure', + \Stripe\Terminal\ConnectionToken::OBJECT_NAME => 'Stripe\\Terminal\\ConnectionToken', + \Stripe\Terminal\Location::OBJECT_NAME => 'Stripe\\Terminal\\Location', + \Stripe\Terminal\Reader::OBJECT_NAME => 'Stripe\\Terminal\\Reader', \Stripe\Token::OBJECT_NAME => 'Stripe\\Token', \Stripe\Topup::OBJECT_NAME => 'Stripe\\Topup', \Stripe\Transfer::OBJECT_NAME => 'Stripe\\Transfer', diff --git a/tests/Stripe/Terminal/ConnectionTokenTest.php b/tests/Stripe/Terminal/ConnectionTokenTest.php new file mode 100644 index 000000000..bbb1609f5 --- /dev/null +++ b/tests/Stripe/Terminal/ConnectionTokenTest.php @@ -0,0 +1,16 @@ +expectsRequest( + 'post', + '/v1/terminal/connection_tokens' + ); + $resource = ConnectionToken::create(); + $this->assertInstanceOf("Stripe\\Terminal\\ConnectionToken", $resource); + } +} diff --git a/tests/Stripe/Terminal/LocationTest.php b/tests/Stripe/Terminal/LocationTest.php new file mode 100644 index 000000000..d14b0d3ac --- /dev/null +++ b/tests/Stripe/Terminal/LocationTest.php @@ -0,0 +1,84 @@ +expectsRequest( + 'get', + '/v1/terminal/locations' + ); + $resources = Location::all(); + $this->assertTrue(is_array($resources->data)); + $this->assertInstanceOf("Stripe\\Terminal\\Location", $resources->data[0]); + } + + public function testIsRetrievable() + { + $this->expectsRequest( + 'get', + '/v1/terminal/locations/' . self::TEST_RESOURCE_ID + ); + $resource = Location::retrieve(self::TEST_RESOURCE_ID); + $this->assertInstanceOf("Stripe\\Terminal\\Location", $resource); + } + + public function testIsSaveable() + { + $resource = Location::retrieve(self::TEST_RESOURCE_ID); + $resource->display_name = "new-name"; + + $this->expectsRequest( + 'post', + '/v1/terminal/locations/' . self::TEST_RESOURCE_ID + ); + $resource->save(); + $this->assertInstanceOf("Stripe\\Terminal\\Location", $resource); + } + + public function testIsUpdatable() + { + $this->expectsRequest( + 'post', + '/v1/terminal/locations/' . self::TEST_RESOURCE_ID, + ["display_name" => "new-name"] + ); + $resource = Location::update(self::TEST_RESOURCE_ID, [ + "display_name" => "new-name", + ]); + $this->assertInstanceOf("Stripe\\Terminal\\Location", $resource); + } + + public function testIsCreatable() + { + $this->expectsRequest( + 'post', + '/v1/terminal/locations', + [ + "display_name" => "name", + "address" => [ + "line1" => "line1", + "country" => "US", + "state" => "CA", + "postal_code" => "12345", + "city" => "San Francisco" + ] + ] + ); + $resource = Location::create([ + "display_name" => "name", + "address" => [ + "line1" => "line1", + "country" => "US", + "state" => "CA", + "postal_code" => "12345", + "city" => "San Francisco" + ] + ]); + $this->assertInstanceOf("Stripe\\Terminal\\Location", $resource); + } +} diff --git a/tests/Stripe/Terminal/ReaderTest.php b/tests/Stripe/Terminal/ReaderTest.php new file mode 100644 index 000000000..190772840 --- /dev/null +++ b/tests/Stripe/Terminal/ReaderTest.php @@ -0,0 +1,66 @@ +expectsRequest( + 'get', + '/v1/terminal/readers' + ); + $resources = Reader::all(); + $this->assertTrue(is_array($resources->data)); + $this->assertInstanceOf("Stripe\\Terminal\\Reader", $resources->data[0]); + } + + public function testIsRetrievable() + { + $this->expectsRequest( + 'get', + '/v1/terminal/readers/' . self::TEST_RESOURCE_ID + ); + $resource = Reader::retrieve(self::TEST_RESOURCE_ID); + $this->assertInstanceOf("Stripe\\Terminal\\Reader", $resource); + } + + public function testIsSaveable() + { + $resource = Reader::retrieve(self::TEST_RESOURCE_ID); + $resource->label = "new-name"; + + $this->expectsRequest( + 'post', + '/v1/terminal/readers/' . self::TEST_RESOURCE_ID + ); + $resource->save(); + $this->assertInstanceOf("Stripe\\Terminal\\Reader", $resource); + } + + public function testIsUpdatable() + { + $this->expectsRequest( + 'post', + '/v1/terminal/readers/' . self::TEST_RESOURCE_ID, + ["label" => "new-name"] + ); + $resource = Reader::update(self::TEST_RESOURCE_ID, [ + "label" => "new-name", + ]); + $this->assertInstanceOf("Stripe\\Terminal\\Reader", $resource); + } + + public function testIsCreatable() + { + $this->expectsRequest( + 'post', + '/v1/terminal/readers', + ["registration_code" => "a-b-c"] + ); + $resource = Reader::create(['registration_code' => 'a-b-c']); + $this->assertInstanceOf("Stripe\\Terminal\\Reader", $resource); + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 1bf4aa041..8784715ff 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,6 +1,6 @@