From ff82a3fdffe93c1edd3dd1f869c03c0e2ad28fa7 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/Review.php | 38 +++++++++++++++++++++++++++++++++++ lib/Util/Util.php | 1 + tests/Stripe/ReviewTest.php | 40 +++++++++++++++++++++++++++++++++++++ tests/bootstrap.php | 2 +- 6 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 lib/Review.php create mode 100644 tests/Stripe/ReviewTest.php diff --git a/.travis.yml b/.travis.yml index e98be91c8..96dc6bb5b 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 14ee89d4b..66a03138a 100644 --- a/init.php +++ b/init.php @@ -106,6 +106,7 @@ require(dirname(__FILE__) . '/lib/Refund.php'); require(dirname(__FILE__) . '/lib/Reporting/ReportRun.php'); require(dirname(__FILE__) . '/lib/Reporting/ReportType.php'); +require(dirname(__FILE__) . '/lib/Review.php'); require(dirname(__FILE__) . '/lib/SKU.php'); require(dirname(__FILE__) . '/lib/Sigma/ScheduledQueryRun.php'); require(dirname(__FILE__) . '/lib/Source.php'); diff --git a/lib/Review.php b/lib/Review.php new file mode 100644 index 000000000..e9c16c714 --- /dev/null +++ b/lib/Review.php @@ -0,0 +1,38 @@ +instanceUrl() . '/approve'; + list($response, $opts) = $this->_request('post', $url, $params, $options); + $this->refreshFrom($response, $opts); + return $this; + } +} diff --git a/lib/Util/Util.php b/lib/Util/Util.php index a12ce3c52..e09d1cf98 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -119,6 +119,7 @@ public static function convertToStripeObject($resp, $opts) \Stripe\Refund::OBJECT_NAME => 'Stripe\\Refund', \Stripe\Reporting\ReportRun::OBJECT_NAME => 'Stripe\\Reporting\\ReportRun', \Stripe\Reporting\ReportType::OBJECT_NAME => 'Stripe\\Reporting\\ReportType', + \Stripe\Review::OBJECT_NAME => 'Stripe\\Review', \Stripe\SKU::OBJECT_NAME => 'Stripe\\SKU', \Stripe\Sigma\ScheduledQueryRun::OBJECT_NAME => 'Stripe\\Sigma\\ScheduledQueryRun', \Stripe\Source::OBJECT_NAME => 'Stripe\\Source', diff --git a/tests/Stripe/ReviewTest.php b/tests/Stripe/ReviewTest.php new file mode 100644 index 000000000..7c82c21c0 --- /dev/null +++ b/tests/Stripe/ReviewTest.php @@ -0,0 +1,40 @@ +expectsRequest( + 'post', + '/v1/reviews/' . self::TEST_RESOURCE_ID . '/approve' + ); + $resource->approve(); + $this->assertInstanceOf("Stripe\\Review", $resource); + } + + public function testIsListable() + { + $this->expectsRequest( + 'get', + '/v1/reviews' + ); + $resources = Review::all(); + $this->assertTrue(is_array($resources->data)); + $this->assertInstanceOf("Stripe\\Review", $resources->data[0]); + } + + public function testIsRetrievable() + { + $this->expectsRequest( + 'get', + '/v1/reviews/' . self::TEST_RESOURCE_ID + ); + $resource = Review::retrieve(self::TEST_RESOURCE_ID); + $this->assertInstanceOf("Stripe\\Review", $resource); + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 691658516..8e261568e 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,6 +1,6 @@