Skip to content

Commit

Permalink
Add tests for the TaxCode APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Jun 4, 2021
1 parent 4070e9b commit 41be0bc
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
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.105.0
- STRIPE_MOCK_VERSION=0.106.0
cache:
directories:
- $HOME/.composer/cache/files
Expand Down
50 changes: 50 additions & 0 deletions tests/Stripe/Service/TaxCodeServiceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Stripe\Service;

/**
* @internal
* @covers \Stripe\Service\TaxCodeService
*/
final class TaxCodeServiceTest extends \PHPUnit\Framework\TestCase
{
use \Stripe\TestHelper;

const TEST_RESOURCE_ID = 'txcd_123';

/** @var \Stripe\StripeClient */
private $client;

/** @var TaxCodeService */
private $service;

/**
* @before
*/
protected function setUpService()
{
$this->client = new \Stripe\StripeClient(['api_key' => 'sk_test_123', 'api_base' => MOCK_URL]);
$this->service = new TaxCodeService($this->client);
}

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

public function testRetrieve()
{
$this->expectsRequest(
'get',
'/v1/tax_codes/' . self::TEST_RESOURCE_ID
);
$resource = $this->service->retrieve(self::TEST_RESOURCE_ID);
static::assertInstanceOf(\Stripe\TaxCode::class, $resource);
}
}
35 changes: 35 additions & 0 deletions tests/Stripe/TaxCodeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Stripe;

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

const TEST_RESOURCE_ID = 'txcd_123';

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

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

0 comments on commit 41be0bc

Please sign in to comment.