Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Apr 29, 2020
1 parent 6f2334c commit 20af088
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ matrix:

env:
global:
- STRIPE_MOCK_VERSION=0.88.0
- STRIPE_MOCK_VERSION=0.89.0
cache:
directories:
- $HOME/.composer/cache/files
Expand Down
78 changes: 78 additions & 0 deletions tests/Stripe/PriceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace Stripe;

/**
* @internal
* @covers \Stripe\Price
*/
final class PriceTest extends \PHPUnit\Framework\TestCase
{
use TestHelper;

const TEST_RESOURCE_ID = 'price_123';

public function testIsListable()
{
$this->expectsRequest(
'get',
'/v1/prices'
);
$resources = Price::all();
static::assertInternalType('array', $resources->data);
static::assertInstanceOf(\Stripe\Price::class, $resources->data[0]);
}

public function testIsRetrievable()
{
$this->expectsRequest(
'get',
'/v1/prices/' . self::TEST_RESOURCE_ID
);
$resource = Price::retrieve(self::TEST_RESOURCE_ID);
static::assertInstanceOf(\Stripe\Price::class, $resource);
}

public function testIsCreatable()
{
$this->expectsRequest(
'post',
'/v1/prices'
);
$resource = Price::create([
'unit_amount' => 2000,
'currency' => 'usd',
'recurring' => [
'interval' => 'month',
],
'product_data' => [
'name' => 'Product Name',
],
]);
static::assertInstanceOf(\Stripe\Price::class, $resource);
}

public function testIsSaveable()
{
$resource = Price::retrieve(self::TEST_RESOURCE_ID);
$resource->metadata['key'] = 'value';
$this->expectsRequest(
'post',
'/v1/prices/' . $resource->id
);
$resource->save();
static::assertInstanceOf(\Stripe\Price::class, $resource);
}

public function testIsUpdatable()
{
$this->expectsRequest(
'post',
'/v1/prices/' . self::TEST_RESOURCE_ID
);
$resource = Price::update(self::TEST_RESOURCE_ID, [
'metadata' => ['key' => 'value'],
]);
static::assertInstanceOf(\Stripe\Price::class, $resource);
}
}
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once __DIR__ . '/StripeMock.php';

\define('MOCK_MINIMUM_VERSION', '0.88.0');
\define('MOCK_MINIMUM_VERSION', '0.89.0');

if (\Stripe\StripeMock::start()) {
\register_shutdown_function('\Stripe\StripeMock::stop');
Expand Down

0 comments on commit 20af088

Please sign in to comment.