Skip to content

Commit 0542295

Browse files
committed
Apply type guards also on old Builder#set()
1 parent 317e4c9 commit 0542295

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ private function forwardCallToCorrectClaimMethod($name, $value)
451451
*/
452452
public function set($name, $value)
453453
{
454-
return $this->configureClaim($name, $value);
454+
return $this->forwardCallToCorrectClaimMethod($name, $value);
455455
}
456456

457457
/**

test/unit/BuilderTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,46 @@ public function withClaimShouldSendDeprecationNoticeWhenTryingToConfigureARegist
604604
self::assertEquals($expected, $token->claims()->get($name));
605605
}
606606

607+
608+
/**
609+
* @test
610+
*
611+
* @param string $name
612+
* @param mixed $value
613+
* @param mixed $expected
614+
* @param null|string $otherMessage
615+
*
616+
* @covers ::__construct
617+
* @covers ::set
618+
* @covers ::canOnlyBeUsedAfter
619+
* @covers ::configureClaim
620+
* @covers ::convertItems
621+
* @covers ::convertToDate
622+
* @covers ::getToken
623+
* @covers ::setRegisteredClaim
624+
* @covers ::createSignature
625+
* @covers ::expiresAt
626+
* @covers ::issuedBy
627+
* @covers ::identifiedBy
628+
* @covers ::permittedFor
629+
* @covers ::forwardCallToCorrectClaimMethod
630+
* @covers ::issuedAt
631+
*
632+
* @dataProvider dataWithClaimDeprecationNotice
633+
*/
634+
public function setShouldSendDeprecationNoticeWhenTryingToConfigureARegisteredClaim($name, $value, $expected, $otherMessage = null)
635+
{
636+
if ($otherMessage) {
637+
$this->expectDeprecation($otherMessage);
638+
}
639+
640+
$token = $this->createBuilder()
641+
->set($name, $value)
642+
->getToken(new None(), Key\InMemory::plainText(''));
643+
644+
self::assertEquals($expected, $token->claims()->get($name));
645+
}
646+
607647
public function dataWithClaimDeprecationNotice()
608648
{
609649
$now = time();

0 commit comments

Comments
 (0)