Skip to content

Commit

Permalink
Fix transfer/transfer reversal tests by specifying old API version
Browse files Browse the repository at this point in the history
  • Loading branch information
brandur committed Apr 6, 2017
1 parent 91c3055 commit 3fbc80c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
5 changes: 3 additions & 2 deletions tests/TestCase.php
Expand Up @@ -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();

Expand All @@ -89,7 +89,8 @@ protected static function createTestTransfer(array $attributes = array())
'currency' => 'usd',
'description' => 'Transfer to test@example.com',
'recipient' => $recipient->id
)
),
$opts
);
}

Expand Down
6 changes: 5 additions & 1 deletion tests/TransferReversalTest.php
Expand Up @@ -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));
Expand Down
23 changes: 14 additions & 9 deletions tests/TransferTest.php
Expand Up @@ -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();
Expand All @@ -13,7 +18,7 @@ public function testCreate()
'amount' => 100,
'currency' => 'usd',
'recipient' => $recipient->id
));
), $this->opts);
$this->assertSame('pending', $transfer->status);
}

Expand All @@ -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);
}

Expand All @@ -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();
Expand All @@ -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']);
}

Expand All @@ -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']);
}

Expand Down

0 comments on commit 3fbc80c

Please sign in to comment.