mirror of
https://github.com/wearepixel/laravel-quickbooks.git
synced 2026-11-14 14:01:46 +00:00
test: add tests for upgrade-sensitive areas
- Token model structure: verify $casts has datetime fields, $fillable is complete, and $table is set correctly (catches $dates→$casts regression) - ClientServiceProvider: verify DeferrableProvider interface is implemented and provides() returns Client::class (catches $defer regression) - Token parseOauthToken: verify stored values and Carbon types, not just that mock methods were called - Client setToken: verify DataService cache is cleared on token change - Client delegation: verify hasValidAccessToken/hasValidRefreshToken delegate to Token correctly
This commit is contained in:
+10
-3
@@ -70,12 +70,19 @@
|
||||
$oauth_token_mock = Mockery::mock(QuickBooksOnline\API\Core\OAuth\OAuth2\OAuth2AccessToken::class);
|
||||
|
||||
$oauth_token_mock->shouldReceive('getAccessToken')->once()->withNoArgs()->andReturn('access_token');
|
||||
$oauth_token_mock->shouldReceive('getAccessTokenExpiresAt')->once()->withNoArgs()->andReturn('now');
|
||||
$oauth_token_mock->shouldReceive('getAccessTokenExpiresAt')->once()->withNoArgs()->andReturn('2025-06-15 12:00:00');
|
||||
$oauth_token_mock->shouldReceive('getRealmID')->once()->withNoArgs()->andReturn('realm_id');
|
||||
$oauth_token_mock->shouldReceive('getRefreshToken')->once()->withNoArgs()->andReturn('refresh_token');
|
||||
$oauth_token_mock->shouldReceive('getRefreshTokenExpiresAt')->once()->withNoArgs()->andReturn('now');
|
||||
$oauth_token_mock->shouldReceive('getRefreshTokenExpiresAt')->once()->withNoArgs()->andReturn('2025-09-24 12:00:00');
|
||||
|
||||
$this->token->parseOauthToken($oauth_token_mock);
|
||||
$result = $this->token->parseOauthToken($oauth_token_mock);
|
||||
|
||||
expect($result)->toBeInstanceOf(Token::class)
|
||||
->and($this->token->access_token)->toBe('access_token')
|
||||
->and($this->token->realm_id)->toBe('realm_id')
|
||||
->and($this->token->refresh_token)->toBe('refresh_token')
|
||||
->and($this->token->access_token_expires_at)->toBeInstanceOf(Carbon::class)
|
||||
->and($this->token->refresh_token_expires_at)->toBeInstanceOf(Carbon::class);
|
||||
});
|
||||
|
||||
it('allows itself to be deleted and returns new token', function () {
|
||||
|
||||
Reference in New Issue
Block a user