36716-vm/vendor/stripe/stripe-php/test/Stripe/RequestOptionsTest.php
2025-12-07 05:00:42 +00:00

71 lines
1.6 KiB
PHP

<?php
class Stripe_RequestOptionsTest extends StripeTestCase
{
public function testStringAPIKey()
{
$opts = Stripe_RequestOptions::parse("foo");
$this->assertEqual("foo", $opts->apiKey);
$this->assertEqual(array(), $opts->headers);
}
public function testNull()
{
$opts = Stripe_RequestOptions::parse(null);
$this->assertEqual(null, $opts->apiKey);
$this->assertEqual(array(), $opts->headers);
}
public function testEmptyArray()
{
$opts = Stripe_RequestOptions::parse(array());
$this->assertEqual(null, $opts->apiKey);
$this->assertEqual(array(), $opts->headers);
}
public function testAPIKeyArray()
{
$opts = Stripe_RequestOptions::parse(
array(
'api_key' => 'foo',
)
);
$this->assertEqual('foo', $opts->apiKey);
$this->assertEqual(array(), $opts->headers);
}
public function testIdempotentKeyArray()
{
$opts = Stripe_RequestOptions::parse(
array(
'idempotency_key' => 'foo',
)
);
$this->assertEqual(null, $opts->apiKey);
$this->assertEqual(array('Idempotency-Key' => 'foo'), $opts->headers);
}
public function testKeyArray()
{
$opts = Stripe_RequestOptions::parse(
array(
'idempotency_key' => 'foo',
'api_key' => 'foo'
)
);
$this->assertEqual('foo', $opts->apiKey);
$this->assertEqual(array('Idempotency-Key' => 'foo'), $opts->headers);
}
public function testWrongType()
{
$caught = false;
try {
$opts = Stripe_RequestOptions::parse(5);
} catch (Stripe_Error $e) {
$caught = true;
}
$this->assertTrue($caught);
}
}