@@ -533,6 +533,7 @@ public function relatedToMustKeepAFluentInterface()
533533 * @covers ::configureClaim
534534 * @covers ::createSignature
535535 * @covers ::convertItems
536+ * @covers ::forwardCallToCorrectClaimMethod
536537 *
537538 * @uses \Lcobucci\JWT\Builder::getToken
538539 */
@@ -553,6 +554,7 @@ public function withClaimMustConfigureTheGivenClaim()
553554 * @covers ::__construct
554555 * @covers ::withClaim
555556 * @covers ::configureClaim
557+ * @covers ::forwardCallToCorrectClaimMethod
556558 */
557559 public function withClaimMustKeepAFluentInterface ()
558560 {
@@ -567,39 +569,37 @@ public function withClaimMustKeepAFluentInterface()
567569 * @param string $name
568570 * @param mixed $value
569571 * @param mixed $expected
572+ * @param null|string $otherMessage
570573 *
571574 * @covers ::__construct
572575 * @covers ::withClaim
573- * @covers \Lcobucci\JWT\Token\RegisteredClaimGiven
576+ * @covers ::canOnlyBeUsedAfter
577+ * @covers ::configureClaim
578+ * @covers ::convertItems
579+ * @covers ::convertToDate
580+ * @covers ::getToken
581+ * @covers ::setRegisteredClaim
582+ * @covers ::createSignature
583+ * @covers ::expiresAt
584+ * @covers ::issuedBy
585+ * @covers ::identifiedBy
586+ * @covers ::permittedFor
587+ * @covers ::forwardCallToCorrectClaimMethod
588+ * @covers ::issuedAt
574589 *
575590 * @dataProvider dataWithClaimDeprecationNotice
576591 */
577- public function withClaimShouldSendDeprecationNoticeWhenTryingToConfigureARegisteredClaim ($ name , $ value , $ expected )
592+ public function withClaimShouldSendDeprecationNoticeWhenTryingToConfigureARegisteredClaim ($ name , $ value , $ expected, $ otherMessage = null )
578593 {
579- $ key = $ this ->createMock (Key::class);
580- $ signature = $ this ->createMock (Signature::class);
581- $ signature
582- ->expects (static ::once ())
583- ->method ('hash ' )
584- ->willReturn ('--hash-- ' )
585- ;
586-
587- $ signer = $ this ->createMock (Signer::class);
588- $ signer
589- ->expects (static ::once ())
590- ->method ('sign ' )
591- ->willReturn ($ signature )
592- ;
593-
594-
595-
596594 $ this ->expectDeprecation ('The use of the method "withClaim" is deprecated for registered claims. Please use dedicated method instead. ' );
597595
598- $ token = $ this
599- ->createBuilder ()
596+ if ($ otherMessage ) {
597+ $ this ->expectDeprecation ($ otherMessage );
598+ }
599+
600+ $ token = $ this ->createBuilder ()
600601 ->withClaim ($ name , $ value )
601- ->getToken ($ signer , $ key )
602- ;
602+ ->getToken (new None (), Key \InMemory::plainText ('' ));
603603
604604 self ::assertEquals ($ expected , $ token ->claims ()->get ($ name ));
605605 }
@@ -615,9 +615,9 @@ public function dataWithClaimDeprecationNotice()
615615 ['aud ' , 'him ' , ['him ' ]],
616616 ['jti ' , '0123456789ABCDEF ' , '0123456789ABCDEF ' ],
617617 ['iss ' , 'you ' , 'you ' ],
618- ['exp ' , $ nowPlus1HourAsDate ->getTimestamp (), $ nowPlus1HourAsDate-> getTimestamp () ],
619- ['iat ' , $ now , $ nowAsDate-> getTimestamp () ],
620- ['nbf ' , $ now , $ nowAsDate-> getTimestamp () ],
618+ ['exp ' , $ nowPlus1HourAsDate ->getTimestamp (), $ nowPlus1HourAsDate, ' Using integers for registered date claims is deprecated, please use DateTimeImmutable objects instead. ' ],
619+ ['iat ' , $ now , $ nowAsDate, ' Using integers for registered date claims is deprecated, please use DateTimeImmutable objects instead. ' ],
620+ ['nbf ' , $ now , $ nowAsDate, ' Using integers for registered date claims is deprecated, please use DateTimeImmutable objects instead. ' ],
621621 ];
622622 }
623623
@@ -733,6 +733,7 @@ public function unsignMustKeepAFluentInterface(Builder $builder)
733733 * @uses \Lcobucci\JWT\Builder::__construct
734734 * @uses \Lcobucci\JWT\Builder::configureClaim
735735 * @uses \Lcobucci\JWT\Builder::withClaim
736+ * @uses \Lcobucci\JWT\Builder::forwardCallToCorrectClaimMethod
736737 */
737738 public function getTokenMustReturnANewTokenWithCurrentConfiguration ()
738739 {
0 commit comments