Skip to content

Commit

Permalink
refactor:update mongolid and mongolid laravel
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoFerrazfs committed Oct 7, 2024
1 parent 1d45ec8 commit 093d746
Show file tree
Hide file tree
Showing 8 changed files with 1,211 additions and 895 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"illuminate/support": "^9.0|^10.0",
"lcobucci/jwt": "^3.4|^4.0",
"league/oauth2-server": "^8.2",
"leroy-merlin-br/mongolid": "v3.7",
"leroy-merlin-br/mongolid-laravel": "v3.7",
"mongodb/mongodb": "~1.15.0",
"leroy-merlin-br/mongolid": "dev-refactor/change-types-and-annotations-4",
"leroy-merlin-br/mongolid-laravel": "dev-feat/update-mongolid",
"mongodb/mongodb": "^1.20.0",
"nyholm/psr7": "^1.3",
"phpseclib/phpseclib": "^2.0|^3.0",
"symfony/psr-http-message-bridge": "^2.0"
Expand Down
2,071 changes: 1,195 additions & 876 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/AuthCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AuthCode extends Model
/**
* {@inheritdoc}
*/
protected $collection = 'oauth_auth_codes';
protected ?string $collection = 'oauth_auth_codes';

/**
* Get the client that owns the authentication code.
Expand Down
8 changes: 3 additions & 5 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ class Client extends Model
/**
* {@inheritdoc}
*/
protected $collection = 'oauth_clients';
protected ?string $collection = 'oauth_clients';

/**
* The guarded attributes on the model.
*
* @var array
*/
protected $guarded = [];
protected array $guarded = [];

/**
* The attributes excluded from the model's JSON form.
Expand All @@ -38,7 +36,7 @@ class Client extends Model
/**
* {@inheritdoc}
*/
public $mutable = true;
public bool $mutable = true;

/**
* Get the user that the client belongs to.
Expand Down
2 changes: 1 addition & 1 deletion src/PersonalAccessClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PersonalAccessClient extends Model
/**
* {@inheritdoc}
*/
protected $collection = 'oauth_personal_access_clients';
protected ?string $collection = 'oauth_personal_access_clients';

/**
* Get all of the authentication codes for the client.
Expand Down
6 changes: 2 additions & 4 deletions src/RefreshToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ class RefreshToken extends Model
/**
* {@inheritdoc}
*/
protected $collection = 'oauth_refresh_tokens';
protected ?string $collection = 'oauth_refresh_tokens';

/**
* The guarded attributes on the model.
*
* @var array
*/
protected $guarded = [];
protected array $guarded = [];

/**
* Get the access token that the refresh token belongs to.
Expand Down
2 changes: 1 addition & 1 deletion src/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Token extends Model
/**
* {@inheritdoc}
*/
protected $collection = 'oauth_access_tokens';
protected ?string $collection = 'oauth_access_tokens';

/**
* Get the client that the token belongs to.
Expand Down
9 changes: 5 additions & 4 deletions tests/Feature/AccessTokenControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Laravel\Passport\Token;
use Laravel\Passport\TokenRepository;
use Lcobucci\JWT\Configuration;
use MongoDB\BSON\ObjectId;
use MongolidLaravel\LegacyMongolidModel as Model;

class AccessTokenControllerTest extends PassportTestCase
Expand Down Expand Up @@ -64,7 +65,7 @@ public function testGettingAccessTokenWithClientCredentialsGrant()
$this->assertArrayHasKey('expires_in', $decodedResponse);
$this->assertArrayHasKey('access_token', $decodedResponse);
$this->assertSame('Bearer', $decodedResponse['token_type']);
$expiresInSeconds = 31622400;
$expiresInSeconds = 31536000;
$this->assertEqualsWithDelta($expiresInSeconds, $decodedResponse['expires_in'], 5);

$token = $this->app->make(PersonalAccessTokenFactory::class)->findAccessToken($decodedResponse);
Expand Down Expand Up @@ -172,7 +173,7 @@ public function testGettingAccessTokenWithPasswordGrant()
$this->assertArrayHasKey('access_token', $decodedResponse);
$this->assertArrayHasKey('refresh_token', $decodedResponse);
$this->assertSame('Bearer', $decodedResponse['token_type']);
$expiresInSeconds = 31622400;
$expiresInSeconds = 31536000;
$this->assertEqualsWithDelta($expiresInSeconds, $decodedResponse['expires_in'], 5);

$token = $this->app->make(PersonalAccessTokenFactory::class)->findAccessToken($decodedResponse);
Expand Down Expand Up @@ -334,9 +335,9 @@ class User extends Model
{
use HasApiTokens;

protected $collection = 'users';
protected ?string $collection = 'users';

public function getAuthIdentifier()
public function getAuthIdentifier(): ObjectId
{
return $this->_id;
}
Expand Down

0 comments on commit 093d746

Please sign in to comment.