Skip to content

Commit

Permalink
refs vufind-org#2999 add testGetCheckboxWithoutIdAndWithEmptyPrefix
Browse files Browse the repository at this point in the history
  • Loading branch information
RLangeUni committed Oct 18, 2024
1 parent 46b2f01 commit 83f543d
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,56 @@ public function testGetCheckbox(): void
$this->assertEquals('success', $record->getCheckbox('bar', 'foo', 2));
}

/**
* Test getCheckboxWithoutIdAndWithoutPrefix.
*
* @return void
*/
public function testGetCheckboxWithoutIdAndWithEmptyPrefix(): void
{
$driver = $this->loadRecordFixture('testbug1.json');
$tpl = 'record/checkbox.phtml';
$context = $this->getMockContext();

$expectedCalls = [
[
$tpl,
[
'number' => 1,
'id' => 'Solr|000105196',
'checkboxElementId' => '000105196',
'prefix' => '',
'formAttr' => 'foo',
],
],
[
$tpl,
[
'number' => 2,
'id' => 'Solr|000105196',
'checkboxElementId' => '000105196',
'prefix' => '',
'formAttr' => 'foo',
],
],
];

$record = $this->getRecord($driver, [], $context);

$this->expectConsecutiveCalls(
$context,
'renderInContext',
$expectedCalls,
['success', 'success']
);

$record = $this->getRecord($driver, [], $context);

// We run the test twice to ensure that checkbox incrementing works properly:
$this->assertEquals('success', $record->getCheckbox(formAttr: 'foo', number: 1));
$this->assertEquals('success', $record->getCheckbox('', 'foo', 2));
}

/**
* Test getUniqueHtmlElementId.
*
Expand Down

0 comments on commit 83f543d

Please sign in to comment.