Skip to content

Commit

Permalink
Apply type guards also on old Builder#set()
Browse files Browse the repository at this point in the history
  • Loading branch information
lcobucci committed Nov 27, 2020
1 parent 317e4c9 commit 0542295
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ private function forwardCallToCorrectClaimMethod($name, $value)
*/
public function set($name, $value)
{
return $this->configureClaim($name, $value);
return $this->forwardCallToCorrectClaimMethod($name, $value);
}

/**
Expand Down
40 changes: 40 additions & 0 deletions test/unit/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,46 @@ public function withClaimShouldSendDeprecationNoticeWhenTryingToConfigureARegist
self::assertEquals($expected, $token->claims()->get($name));
}


/**
* @test
*
* @param string $name
* @param mixed $value
* @param mixed $expected
* @param null|string $otherMessage
*
* @covers ::__construct
* @covers ::set
* @covers ::canOnlyBeUsedAfter
* @covers ::configureClaim
* @covers ::convertItems
* @covers ::convertToDate
* @covers ::getToken
* @covers ::setRegisteredClaim
* @covers ::createSignature
* @covers ::expiresAt
* @covers ::issuedBy
* @covers ::identifiedBy
* @covers ::permittedFor
* @covers ::forwardCallToCorrectClaimMethod
* @covers ::issuedAt
*
* @dataProvider dataWithClaimDeprecationNotice
*/
public function setShouldSendDeprecationNoticeWhenTryingToConfigureARegisteredClaim($name, $value, $expected, $otherMessage = null)
{
if ($otherMessage) {
$this->expectDeprecation($otherMessage);
}

$token = $this->createBuilder()
->set($name, $value)
->getToken(new None(), Key\InMemory::plainText(''));

self::assertEquals($expected, $token->claims()->get($name));
}

public function dataWithClaimDeprecationNotice()
{
$now = time();
Expand Down

0 comments on commit 0542295

Please sign in to comment.