@@ -468,4 +468,78 @@ public function it_should_throw_a_failed_action_exception_when_no_transition_is_
468468 // When
469469 $ jira ->updateIssueStatus ('1 ' , new IssueStatus (['id ' => '999 ' , 'name ' => 'Unavailable Status ' ]));
470470 }
471+
472+ #[Test]
473+ public function it_should_indicate_there_is_a_next_page_when_a_next_page_token_is_present ()
474+ {
475+ // Given
476+ $ jira = new Client (['clientId ' => 1 , 'clientSecret ' => 'secret ' , 'redirectUrl ' => 'none ' ], 'myorg ' , $ this ->token );
477+
478+ $ jira ->setClient ($ service = Mockery::mock ('\GuzzleHttp\Client ' ));
479+
480+ $ service ->shouldReceive ('request ' )
481+ ->withArgs (function ($ verb ) {
482+ return $ verb === 'GET ' ;
483+ })
484+ ->once ()
485+ ->andReturn (new Response (200 , ['Content-Type ' => 'application/json ' ], json_encode ([
486+ 'issues ' => [$ this ->issue ],
487+ 'nextPageToken ' => 'abc123 ' ,
488+ 'isLast ' => false ,
489+ ])));
490+
491+ $ service ->shouldReceive ('request ' )
492+ ->withArgs (function ($ verb , $ uri ) {
493+ return $ verb === 'POST ' && $ uri === 'search/approximate-count ' ;
494+ })
495+ ->once ()
496+ ->andReturn (new Response (200 , ['Content-Type ' => 'application/json ' ], json_encode ([
497+ 'count ' => 10 ,
498+ ])));
499+
500+ // When
501+ $ issues = $ jira ->issues ();
502+
503+ // Then
504+ $ this ->assertEquals ('abc123 ' , $ issues ->nextPageToken ());
505+ $ this ->assertFalse ($ issues ->isLastPage ());
506+ $ this ->assertTrue ($ issues ->hasNextPage ());
507+ }
508+
509+ #[Test]
510+ public function it_should_indicate_the_last_page_when_is_last_is_true_even_with_a_next_page_token_present ()
511+ {
512+ // Given
513+ $ jira = new Client (['clientId ' => 1 , 'clientSecret ' => 'secret ' , 'redirectUrl ' => 'none ' ], 'myorg ' , $ this ->token );
514+
515+ $ jira ->setClient ($ service = Mockery::mock ('\GuzzleHttp\Client ' ));
516+
517+ $ service ->shouldReceive ('request ' )
518+ ->withArgs (function ($ verb ) {
519+ return $ verb === 'GET ' ;
520+ })
521+ ->once ()
522+ ->andReturn (new Response (200 , ['Content-Type ' => 'application/json ' ], json_encode ([
523+ 'issues ' => [$ this ->issue ],
524+ 'nextPageToken ' => 'abc123 ' ,
525+ 'isLast ' => true ,
526+ ])));
527+
528+ $ service ->shouldReceive ('request ' )
529+ ->withArgs (function ($ verb , $ uri ) {
530+ return $ verb === 'POST ' && $ uri === 'search/approximate-count ' ;
531+ })
532+ ->once ()
533+ ->andReturn (new Response (200 , ['Content-Type ' => 'application/json ' ], json_encode ([
534+ 'count ' => 10 ,
535+ ])));
536+
537+ // When
538+ $ issues = $ jira ->issues ();
539+
540+ // Then
541+ $ this ->assertEquals ('abc123 ' , $ issues ->nextPageToken ());
542+ $ this ->assertTrue ($ issues ->isLastPage ());
543+ $ this ->assertFalse ($ issues ->hasNextPage ());
544+ }
471545}
0 commit comments