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

Restore testCoreEventsGet generated test #1805

Merged
merged 2 commits into from
Jan 17, 2025
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 lib/Util/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function convertToStripeObject($resp, $opts, $apiMode = 'v1')
if (\array_key_exists('type', $resp) && \array_key_exists($resp['type'], $eventTypes)) {
$class = $eventTypes[$resp['type']];
} else {
$class = \Stripe\StripeObject::class;
$class = \Stripe\V2\Event::class;
}
}
} elseif (\array_key_exists('data', $resp) && \array_key_exists('next_page_url', $resp)) {
Expand Down
7 changes: 6 additions & 1 deletion lib/V2/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
namespace Stripe\V2;

/**
* Base class for V2 events.
*
* This is concrete for use in our generated tests. Events returned from the \Stripe\V2\Core\EventService
* will be a subtype of \Stripe\V2\Event.
*
* @property string $id Unique identifier for the event.
* @property string $object String representing the object's type. Objects of the same type share the same value of the object field.
* @property int $created Time at which the object was created.
* @property \Stripe\StripeObject $reason Reason for the event.
* @property string $type The type of the event.
* @property null|string $context The Stripe account of the event
*/
abstract class Event extends \Stripe\ApiResource
class Event extends \Stripe\ApiResource
{
const OBJECT_NAME = 'v2.core.event';
}
14 changes: 14 additions & 0 deletions tests/Stripe/GeneratedExamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,20 @@ public function testCheckoutSessionsPost2()
static::assertInstanceOf(\Stripe\Checkout\Session::class, $result);
}

public function testCoreEventsGet()
{
$this->stubRequest(
'get',
'/v2/core/events/ll_123',
[],
[],
false,
['object' => \Stripe\V2\Event::OBJECT_NAME]
);
$result = $this->client->v2->core->events->retrieve('ll_123', []);
static::assertInstanceOf(\Stripe\V2\Event::class, $result);
}

public function testCountrySpecsGet()
{
$this->expectsRequest('get', '/v1/country_specs');
Expand Down