From 3fbc80c45c769bd4b8af3536a4452967b58f3ffa Mon Sep 17 00:00:00 2001 From: Brandur Date: Thu, 6 Apr 2017 13:44:56 -0700 Subject: [PATCH] Fix transfer/transfer reversal tests by specifying old API version --- tests/TestCase.php | 5 +++-- tests/TransferReversalTest.php | 6 +++++- tests/TransferTest.php | 23 ++++++++++++++--------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index c2669d9b4..5d39ffbe2 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -77,7 +77,7 @@ protected static function createTestCharge(array $attributes = array()) /** * Create a valid test charge. */ - protected static function createTestTransfer(array $attributes = array()) + protected static function createTestTransfer(array $attributes = array(), $opts = null) { self::authorizeFromEnv(); @@ -89,7 +89,8 @@ protected static function createTestTransfer(array $attributes = array()) 'currency' => 'usd', 'description' => 'Transfer to test@example.com', 'recipient' => $recipient->id - ) + ), + $opts ); } diff --git a/tests/TransferReversalTest.php b/tests/TransferReversalTest.php index 414f81688..86d746650 100644 --- a/tests/TransferReversalTest.php +++ b/tests/TransferReversalTest.php @@ -4,10 +4,14 @@ class TransferReversalTest extends TestCase { + // The resource that was traditionally called "transfer" became a "payout" + // in API version 2017-04-06. We're testing traditional transfers here, so + // we force the API version just prior anywhere that we need to. + private $opts = array('stripe_version' => '2017-02-14'); public function testList() { - $transfer = self::createTestTransfer(); + $transfer = self::createTestTransfer(array(), $this->opts); $all = $transfer->reversals->all(); $this->assertSame(false, $all['has_more']); $this->assertSame(0, count($all->data)); diff --git a/tests/TransferTest.php b/tests/TransferTest.php index b6412a51a..9aa69779a 100644 --- a/tests/TransferTest.php +++ b/tests/TransferTest.php @@ -4,6 +4,11 @@ class TransferTest extends TestCase { + // The resource that was traditionally called "transfer" became a "payout" + // in API version 2017-04-06. We're testing traditional transfers here, so + // we force the API version just prior anywhere that we need to. + private $opts = array('stripe_version' => '2017-02-14'); + public function testCreate() { $recipient = self::createTestRecipient(); @@ -13,7 +18,7 @@ public function testCreate() 'amount' => 100, 'currency' => 'usd', 'recipient' => $recipient->id - )); + ), $this->opts); $this->assertSame('pending', $transfer->status); } @@ -26,8 +31,8 @@ public function testRetrieve() 'amount' => 100, 'currency' => 'usd', 'recipient' => $recipient->id - )); - $reloaded = Transfer::retrieve($transfer->id); + ), $this->opts); + $reloaded = Transfer::retrieve($transfer->id, $this->opts); $this->assertSame($reloaded->id, $transfer->id); } @@ -43,8 +48,8 @@ public function testCancel() 'amount' => 100, 'currency' => 'usd', 'recipient' => $recipient->id - )); - $reloaded = Transfer::retrieve($transfer->id); + ), $this->opts); + $reloaded = Transfer::retrieve($transfer->id, $this->opts); $this->assertSame($reloaded->id, $transfer->id); $reloaded->cancel(); @@ -59,12 +64,12 @@ public function testTransferUpdateMetadata() 'amount' => 100, 'currency' => 'usd', 'recipient' => $recipient->id - )); + ), $this->opts); $transfer->metadata['test'] = 'foo bar'; $transfer->save(); - $updatedTransfer = Transfer::retrieve($transfer->id); + $updatedTransfer = Transfer::retrieve($transfer->id, $this->opts); $this->assertSame('foo bar', $updatedTransfer->metadata['test']); } @@ -77,12 +82,12 @@ public function testTransferUpdateMetadataAll() 'amount' => 100, 'currency' => 'usd', 'recipient' => $recipient->id - )); + ), $this->opts); $transfer->metadata = array('test' => 'foo bar'); $transfer->save(); - $updatedTransfer = Transfer::retrieve($transfer->id); + $updatedTransfer = Transfer::retrieve($transfer->id, $this->opts); $this->assertSame('foo bar', $updatedTransfer->metadata['test']); }