Skip to content

Commit

Permalink
More progress on withConsecutive().
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Jan 24, 2024
1 parent 8d035c5 commit c82e0c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
*/
class MapTest extends \PHPUnit\Framework\TestCase
{
use \VuFindTest\Feature\WithConsecutiveTrait;

/**
* Get a Map object
*
Expand Down Expand Up @@ -183,9 +185,12 @@ public function testGetMapTabData(): void
$recordDriver = $this->getMockBuilder(\VuFind\RecordDriver\SolrDefault::class)
->disableOriginalConstructor()
->getMock();
$recordDriver->expects($this->exactly(2))->method('tryMethod')
->withConsecutive(['getGeoLocation'], ['getDisplayCoordinates'])
->willReturnOnConsecutiveCalls($coordinates, $displayCoord);
$this->expectConsecutiveCalls(
$recordDriver,
'tryMethod',
[['getGeoLocation'], ['getDisplayCoordinates']],
[$coordinates, $displayCoord]
);

$obj->setRecordDriver($recordDriver);
$expected = [[25.8,4.6,43.9,5.0,'','89 87 45 56']];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
*/
class TOCTest extends \PHPUnit\Framework\TestCase
{
use \VuFindTest\Feature\WithConsecutiveTrait;

/**
* Test getting Description.
*
Expand Down Expand Up @@ -79,9 +81,13 @@ public function testIsActive(string $toc, bool $expectedResult): void
$recordDriver = $this->getMockBuilder(\VuFind\RecordDriver\SolrDefault::class)
->disableOriginalConstructor()
->getMock();
$recordDriver->expects($this->any())->method('tryMethod')
->withConsecutive([$this->equalTo('getTOC')], [$this->equalTo('getCleanISBN')])
->willReturnOnConsecutiveCalls($this->returnValue($toc), $this->returnValue('bar'));
$this->expectConsecutiveCalls(
$recordDriver,
'tryMethod',
// We'll only do an ISBN lookup if the initial TOC is empty:
!empty($toc) ? [['getTOC']] : [['getTOC'], ['getCleanISBN']],
[$toc, 'bar']
);
$obj = new TOC();
$obj->setRecordDriver($recordDriver);
$this->assertSame($expectedResult, $obj->isActive());
Expand Down

0 comments on commit c82e0c8

Please sign in to comment.