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

Add test #1243

Merged
merged 2 commits into from
Feb 14, 2022
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
2 changes: 1 addition & 1 deletion tests/Stripe/BaseStripeClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function testRequestCollectionThrowsForNonList()

public function testRequestWithOptsInParamsWarns()
{
$this->expectException(static::compatWarningClass());
$this->compatExpectWarning(static::compatWarningClass());
$this->expectExceptionMessage('Options found in $params: api_key, stripe_account, api_base. Options should be '
. 'passed in their own array after $params. (HINT: pass an empty array to $params if you do not have any.)');
$client = new BaseStripeClient([
Expand Down
26 changes: 26 additions & 0 deletions tests/Stripe/GeneratedExamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2696,4 +2696,30 @@ public function testRetrievePaymentLink()
$result = $this->client->paymentLinks->retrieve('pl_xyz', []);
static::assertInstanceOf(\Stripe\PaymentLink::class, $result);
}

public function testVerifyMicrodepositsPaymentIntent()
{
$this->expectsRequest(
'post',
'/v1/payment_intents/pi_xxxxxxxxxxxxx/verify_microdeposits'
);
$result = $this->client->paymentIntents->verifyMicrodeposits(
'pi_xxxxxxxxxxxxx',
[]
);
static::assertInstanceOf(\Stripe\PaymentIntent::class, $result);
}

public function testVerifyMicrodepositsSetupIntent()
{
$this->expectsRequest(
'post',
'/v1/setup_intents/seti_xxxxxxxxxxxxx/verify_microdeposits'
);
$result = $this->client->setupIntents->verifyMicrodeposits(
'seti_xxxxxxxxxxxxx',
[]
);
static::assertInstanceOf(\Stripe\SetupIntent::class, $result);
}
}
2 changes: 1 addition & 1 deletion tests/Stripe/StripeObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function testNonexistentProperty()
$s = new StripeObject();
static::assertNull($s->nonexistent);

static::assertRegExp(
static::compatAssertMatchesRegularExpression(
'/Stripe Notice: Undefined property of Stripe\\\\StripeObject instance: nonexistent/',
\stream_get_contents($capture)
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Stripe/Util/DefaultLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testDefaultLogger()
$logger = new DefaultLogger();
$logger->error('This is a test message');

static::assertRegExp('/This is a test message/', \stream_get_contents($capture));
static::compatAssertMatchesRegularExpression('/This is a test message/', \stream_get_contents($capture));
} finally {
\ini_set('error_log', $origErrorLog);
\fclose($capture);
Expand Down
21 changes: 21 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,25 @@ public static function compatWarningClass()
// @phpstan-ignore-next-line
return \PHPUnit_Framework_Error_Warning::class;
}

public function compatExpectWarning($warningClass)
{
if (method_exists($this, 'expectWarning')) {
// @phpstan-ignore-next-line
$this->expectWarning($warningClass);
} else {
// @phpstan-ignore-next-line
$this->expectException($warningClass);
}
}

public static function compatAssertMatchesRegularExpression($text, $regex) {
if (method_exists(static::class, 'assertMatchesRegularExpression')) {
// @phpstan-ignore-next-line
static::assertMatchesRegularExpression($text, $regex);
} else {
// @phpstan-ignore-next-line
static::assertRegExp($text, $regex);
}
}
}