From 762b4100277123b708240ec729bd724dbb53d58e Mon Sep 17 00:00:00 2001 From: Remi Jannel Date: Tue, 27 Nov 2018 08:35:30 -0500 Subject: [PATCH] Add support for Review resource. --- .travis.yml | 2 +- init.php | 1 + lib/Radar/Review.php | 38 +++++++++++++++++++++++++++++ lib/Util/Util.php | 1 + tests/Stripe/Radar/ReviewTest.php | 40 +++++++++++++++++++++++++++++++ tests/bootstrap.php | 2 +- 6 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 lib/Radar/Review.php create mode 100644 tests/Stripe/Radar/ReviewTest.php diff --git a/.travis.yml b/.travis.yml index e98be91c80..96dc6bb5ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ php: env: global: - - STRIPE_MOCK_VERSION=0.37.0 + - STRIPE_MOCK_VERSION=0.38.0 matrix: - AUTOLOAD=1 - AUTOLOAD=0 diff --git a/init.php b/init.php index 14ee89d4bb..adcc31058e 100644 --- a/init.php +++ b/init.php @@ -99,6 +99,7 @@ require(dirname(__FILE__) . '/lib/Person.php'); require(dirname(__FILE__) . '/lib/Plan.php'); require(dirname(__FILE__) . '/lib/Product.php'); +require(dirname(__FILE__) . '/lib/Radar/Review.php'); require(dirname(__FILE__) . '/lib/Radar/ValueList.php'); require(dirname(__FILE__) . '/lib/Radar/ValueListItem.php'); require(dirname(__FILE__) . '/lib/Recipient.php'); diff --git a/lib/Radar/Review.php b/lib/Radar/Review.php new file mode 100644 index 0000000000..06dd6c5a45 --- /dev/null +++ b/lib/Radar/Review.php @@ -0,0 +1,38 @@ +instanceUrl() . '/approve'; + list($response, $opts) = $this->_request('post', $url, $params, $opts); + $this->refreshFrom($response, $opts); + return $this; + } +} diff --git a/lib/Util/Util.php b/lib/Util/Util.php index a12ce3c529..00e8d7c23f 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -112,6 +112,7 @@ public static function convertToStripeObject($resp, $opts) \Stripe\Person::OBJECT_NAME => 'Stripe\\Person', \Stripe\Plan::OBJECT_NAME => 'Stripe\\Plan', \Stripe\Product::OBJECT_NAME => 'Stripe\\Product', + \Stripe\Radar\Review::OBJECT_NAME => 'Stripe\\Radar\\Review', \Stripe\Radar\ValueList::OBJECT_NAME => 'Stripe\\Radar\\ValueList', \Stripe\Radar\ValueListItem::OBJECT_NAME => 'Stripe\\Radar\\ValueListItem', \Stripe\Recipient::OBJECT_NAME => 'Stripe\\Recipient', diff --git a/tests/Stripe/Radar/ReviewTest.php b/tests/Stripe/Radar/ReviewTest.php new file mode 100644 index 0000000000..556d1b08bf --- /dev/null +++ b/tests/Stripe/Radar/ReviewTest.php @@ -0,0 +1,40 @@ +expectsRequest( + 'get', + '/v1/radar/reviews' + ); + $resources = Review::all(); + $this->assertTrue(is_array($resources->data)); + $this->assertInstanceOf("Stripe\\Radar\\Review", $resources->data[0]); + } + + public function testIsRetrievable() + { + $this->expectsRequest( + 'get', + '/v1/radar/reviews/' . self::TEST_RESOURCE_ID + ); + $resource = Review::retrieve(self::TEST_RESOURCE_ID); + $this->assertInstanceOf("Stripe\\Radar\\Review", $resource); + } + + public function testIsApprovable() + { + $resource = Review::retrieve(self::TEST_RESOURCE_ID); + $this->expectsRequest( + 'post', + '/v1/radar/reviews/' . self::TEST_RESOURCE_ID . '/approve' + ); + $resource->approve(); + $this->assertInstanceOf("Stripe\\Radar\\Review", $resource); + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 691658516d..8e261568ec 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,6 +1,6 @@