Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP-CS-Fixer @PHPUnit57Migration changes #847

Merged
merged 1 commit into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions tests/Stripe/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testIsListable()
'/v1/accounts'
);
$resources = Account::all();
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
$this->assertInstanceOf(\Stripe\Account::class, $resources->data[0]);
}

Expand Down Expand Up @@ -126,7 +126,7 @@ public function testPersons()
'/v1/accounts/' . $account->id . '/persons'
);
$persons = $account->persons();
$this->assertTrue(is_array($persons->data));
$this->assertInternalType('array', $persons->data);
$this->assertInstanceOf(\Stripe\Person::class, $persons->data[0]);
}

Expand Down Expand Up @@ -159,7 +159,7 @@ public function testCanListCapabilities()
'/v1/accounts/' . self::TEST_RESOURCE_ID . '/capabilities'
);
$resources = Account::allCapabilities(self::TEST_RESOURCE_ID);
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
}

public function testCanCreateExternalAccount()
Expand Down Expand Up @@ -213,7 +213,7 @@ public function testCanListExternalAccounts()
'/v1/accounts/' . self::TEST_RESOURCE_ID . '/external_accounts'
);
$resources = Account::allExternalAccounts(self::TEST_RESOURCE_ID);
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
}

public function testCanCreateLoginLink()
Expand Down Expand Up @@ -281,7 +281,7 @@ public function testCanListPersons()
'/v1/accounts/' . self::TEST_RESOURCE_ID . '/persons'
);
$resources = Account::allPersons(self::TEST_RESOURCE_ID);
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
}

public function testSerializeNewAdditionalOwners()
Expand Down Expand Up @@ -395,11 +395,10 @@ public function testSerializeUnsetAdditionalOwners()
$this->assertSame($expected, $obj->serializeParameters());
}

/**
* @expectedException \InvalidArgumentException
*/
public function testSerializeAdditionalOwnersDeletedItem()
{
$this->expectException(\InvalidArgumentException::class);

$obj = Util\Util::convertToStripeObject([
'object' => 'account',
'legal_entity' => [
Expand Down
10 changes: 4 additions & 6 deletions tests/Stripe/AlipayAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ public function testHasCorrectUrlForCustomer()
);
}

/**
* @expectedException \Stripe\Exception\BadMethodCallException
*/
public function testIsNotDirectlyRetrievable()
{
$this->expectException(\Stripe\Exception\BadMethodCallException::class);

AlipayAccount::retrieve(self::TEST_RESOURCE_ID);
}

Expand All @@ -53,11 +52,10 @@ public function testIsSaveable()
$this->assertSame(\Stripe\AlipayAccount::class, get_class($resource));
}

/**
* @expectedException \Stripe\Exception\BadMethodCallException
*/
public function testIsNotDirectlyUpdatable()
{
$this->expectException(\Stripe\Exception\BadMethodCallException::class);

AlipayAccount::update(self::TEST_RESOURCE_ID, [
"metadata" => ["key" => "value"],
]);
Expand Down
23 changes: 11 additions & 12 deletions tests/Stripe/ApiRequestorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,11 @@ public function testDefaultHeaders()
$this->assertSame($headers['Authorization'], 'Bearer ' . $apiKey);
}

/**
* @expectedException \Stripe\Exception\AuthenticationException
* @expectedExceptionMessageRegExp #No API key provided#
*/
public function testRaisesAuthenticationErrorWhenNoApiKey()
{
$this->expectException(\Stripe\Exception\AuthenticationException::class);
$this->expectExceptionMessageRegExp('#No API key provided#');

Stripe::setApiKey(null);
Charge::create();
}
Expand Down Expand Up @@ -112,7 +111,7 @@ public function testRaisesInvalidRequestErrorOn400()
$this->fail("Did not raise error");
} catch (Exception\InvalidRequestException $e) {
$this->assertSame(400, $e->getHttpStatus());
$this->assertTrue(is_array($e->getJsonBody()));
$this->assertInternalType('array', $e->getJsonBody());
$this->assertSame('Missing id', $e->getMessage());
$this->assertSame('id', $e->getStripeParam());
} catch (\Exception $e) {
Expand Down Expand Up @@ -142,7 +141,7 @@ public function testRaisesIdempotencyErrorOn400AndTypeIdempotencyError()
$this->fail("Did not raise error");
} catch (Exception\IdempotencyException $e) {
$this->assertSame(400, $e->getHttpStatus());
$this->assertTrue(is_array($e->getJsonBody()));
$this->assertInternalType('array', $e->getJsonBody());
$this->assertSame("Keys for idempotent requests can only be used with the same parameters they were first used with. Try using a key other than 'abc' if you meant to execute a different request.", $e->getMessage());
} catch (\Exception $e) {
$this->fail("Unexpected exception: " . get_class($e));
Expand Down Expand Up @@ -171,7 +170,7 @@ public function testRaisesAuthenticationErrorOn401()
$this->fail("Did not raise error");
} catch (Exception\AuthenticationException $e) {
$this->assertSame(401, $e->getHttpStatus());
$this->assertTrue(is_array($e->getJsonBody()));
$this->assertInternalType('array', $e->getJsonBody());
$this->assertSame('You did not provide an API key.', $e->getMessage());
} catch (\Exception $e) {
$this->fail("Unexpected exception: " . get_class($e));
Expand Down Expand Up @@ -204,7 +203,7 @@ public function testRaisesCardErrorOn402()
$this->fail("Did not raise error");
} catch (Exception\CardException $e) {
$this->assertSame(402, $e->getHttpStatus());
$this->assertTrue(is_array($e->getJsonBody()));
$this->assertInternalType('array', $e->getJsonBody());
$this->assertSame('Your card was declined.', $e->getMessage());
$this->assertSame('card_declined', $e->getStripeCode());
$this->assertSame('generic_decline', $e->getDeclineCode());
Expand Down Expand Up @@ -236,7 +235,7 @@ public function testRaisesPermissionErrorOn403()
$this->fail("Did not raise error");
} catch (Exception\PermissionException $e) {
$this->assertSame(403, $e->getHttpStatus());
$this->assertTrue(is_array($e->getJsonBody()));
$this->assertInternalType('array', $e->getJsonBody());
$this->assertSame("The provided key 'sk_test_********************1234' does not have access to account 'foo' (or that account does not exist). Application access may have been revoked.", $e->getMessage());
} catch (\Exception $e) {
$this->fail("Unexpected exception: " . get_class($e));
Expand Down Expand Up @@ -266,7 +265,7 @@ public function testRaisesInvalidRequestErrorOn404()
$this->fail("Did not raise error");
} catch (Exception\InvalidRequestException $e) {
$this->assertSame(404, $e->getHttpStatus());
$this->assertTrue(is_array($e->getJsonBody()));
$this->assertInternalType('array', $e->getJsonBody());
$this->assertSame('No such charge: foo', $e->getMessage());
$this->assertSame('id', $e->getStripeParam());
} catch (\Exception $e) {
Expand Down Expand Up @@ -295,7 +294,7 @@ public function testRaisesRateLimitErrorOn429()
$this->fail("Did not raise error");
} catch (Exception\RateLimitException $e) {
$this->assertSame(429, $e->getHttpStatus());
$this->assertTrue(is_array($e->getJsonBody()));
$this->assertInternalType('array', $e->getJsonBody());
$this->assertSame('Too many requests', $e->getMessage());
} catch (\Exception $e) {
var_dump($e);
Expand Down Expand Up @@ -325,7 +324,7 @@ public function testRaisesRateLimitErrorOn400AndCodeRateLimit()
$this->fail("Did not raise error");
} catch (Exception\RateLimitException $e) {
$this->assertSame(400, $e->getHttpStatus());
$this->assertTrue(is_array($e->getJsonBody()));
$this->assertInternalType('array', $e->getJsonBody());
$this->assertSame('Too many requests', $e->getMessage());
} catch (\Exception $e) {
$this->fail("Unexpected exception: " . get_class($e));
Expand Down
2 changes: 1 addition & 1 deletion tests/Stripe/ApplePayDomainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function testIsListable()
'/v1/apple_pay/domains'
);
$resources = ApplePayDomain::all();
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
$this->assertInstanceOf(\Stripe\ApplePayDomain::class, $resources->data[0]);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Stripe/ApplicationFeeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testIsListable()
'/v1/application_fees'
);
$resources = ApplicationFee::all();
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
$this->assertInstanceOf(\Stripe\ApplicationFee::class, $resources->data[0]);
}

Expand Down Expand Up @@ -65,7 +65,7 @@ public function testCanListRefunds()
'/v1/application_fees/' . self::TEST_RESOURCE_ID . '/refunds'
);
$resources = ApplicationFee::allRefunds(self::TEST_RESOURCE_ID);
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
$this->assertInstanceOf(\Stripe\ApplicationFeeRefund::class, $resources->data[0]);
}
}
2 changes: 1 addition & 1 deletion tests/Stripe/BalanceTransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function testIsListable()
'/v1/balance_transactions'
);
$resources = BalanceTransaction::all();
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
$this->assertInstanceOf(\Stripe\BalanceTransaction::class, $resources->data[0]);
}

Expand Down
10 changes: 4 additions & 6 deletions tests/Stripe/BankAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ public function testHasCorrectUrlForAccount()
);
}

/**
* @expectedException \Stripe\Exception\BadMethodCallException
*/
public function testIsNotDirectlyRetrievable()
{
$this->expectException(\Stripe\Exception\BadMethodCallException::class);

BankAccount::retrieve(self::TEST_RESOURCE_ID);
}

Expand All @@ -62,11 +61,10 @@ public function testIsSaveable()
$this->assertSame(\Stripe\BankAccount::class, get_class($resource));
}

/**
* @expectedException \Stripe\Exception\BadMethodCallException
*/
public function testIsNotDirectlyUpdatable()
{
$this->expectException(\Stripe\Exception\BadMethodCallException::class);

BankAccount::update(self::TEST_RESOURCE_ID, [
"metadata" => ["key" => "value"],
]);
Expand Down
2 changes: 1 addition & 1 deletion tests/Stripe/BitcoinReceiverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testIsListable()
'/v1/bitcoin/receivers'
);
$resources = BitcoinReceiver::all();
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
$this->assertSame(\Stripe\BitcoinReceiver::class, get_class($resources->data[0]));
}

Expand Down
10 changes: 4 additions & 6 deletions tests/Stripe/CapabilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ public function testHasCorrectUrl()
);
}

/**
* @expectedException \Stripe\Exception\BadMethodCallException
*/
public function testIsNotDirectlyRetrievable()
{
$this->expectException(\Stripe\Exception\BadMethodCallException::class);

Capability::retrieve(self::TEST_RESOURCE_ID);
}

Expand All @@ -36,11 +35,10 @@ public function testIsSaveable()
$this->assertInstanceOf(\Stripe\Capability::class, $resource);
}

/**
* @expectedException \Stripe\Exception\BadMethodCallException
*/
public function testIsNotDirectlyUpdatable()
{
$this->expectException(\Stripe\Exception\BadMethodCallException::class);

Capability::update(self::TEST_RESOURCE_ID, ["requested" => true]);
}
}
10 changes: 4 additions & 6 deletions tests/Stripe/CardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ public function testHasCorrectUrlForRecipient()
);
}

/**
* @expectedException \Stripe\Exception\BadMethodCallException
*/
public function testIsNotDirectlyRetrievable()
{
$this->expectException(\Stripe\Exception\BadMethodCallException::class);

Card::retrieve(self::TEST_RESOURCE_ID);
}

Expand All @@ -71,11 +70,10 @@ public function testIsSaveable()
$this->assertSame(\Stripe\Card::class, get_class($resource));
}

/**
* @expectedException \Stripe\Exception\BadMethodCallException
*/
public function testIsNotDirectlyUpdatable()
{
$this->expectException(\Stripe\Exception\BadMethodCallException::class);

Card::update(self::TEST_RESOURCE_ID, [
"metadata" => ["key" => "value"],
]);
Expand Down
2 changes: 1 addition & 1 deletion tests/Stripe/ChargeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function testIsListable()
'/v1/charges'
);
$resources = Charge::all();
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
$this->assertInstanceOf(\Stripe\Charge::class, $resources->data[0]);
}

Expand Down
9 changes: 4 additions & 5 deletions tests/Stripe/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ public function setUpFixture()
]);
}

/**
* @expectedException \Stripe\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /You tried to access the \d index/
*/
public function testOffsetGetNumericIndex()
{
$this->expectException(\Stripe\Exception\InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/You tried to access the \\d index/');

$this->fixture[0];
}

Expand All @@ -45,7 +44,7 @@ public function testCanList()
);

$resources = $this->fixture->all();
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
}

public function testCanRetrieve()
Expand Down
2 changes: 1 addition & 1 deletion tests/Stripe/CountrySpecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function testIsListable()
'/v1/country_specs'
);
$resources = CountrySpec::all();
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
$this->assertInstanceOf(\Stripe\CountrySpec::class, $resources->data[0]);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Stripe/CouponTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function testIsListable()
'/v1/coupons'
);
$resources = Coupon::all();
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
$this->assertInstanceOf(\Stripe\Coupon::class, $resources->data[0]);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Stripe/CreditNoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function testIsListable()
'/v1/credit_notes'
);
$resources = CreditNote::all();
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
$this->assertInstanceOf(\Stripe\CreditNote::class, $resources->data[0]);
}

Expand Down Expand Up @@ -97,6 +97,6 @@ public function testCanListLines()
'/v1/credit_notes/' . self::TEST_RESOURCE_ID . '/lines'
);
$resources = CreditNote::allLines(self::TEST_RESOURCE_ID);
$this->assertTrue(is_array($resources->data));
$this->assertInternalType('array', $resources->data);
}
}
Loading