Skip to content

Commit

Permalink
#213: add tests for the ListView::beforeItem and `ListView::afterIt…
Browse files Browse the repository at this point in the history
…em` when defined as closures.
  • Loading branch information
glpzzz committed Sep 10, 2024
1 parent 1a20763 commit 00cd8ed
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/ListView/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,36 @@ public function testAfterItemBeforeItem(): void
);
}

public function testAfterItemBeforeItemWithClosure(): void
{
Assert::equalsWithoutLE(
<<<HTML
<div>
<ul>
<span class="testMe" data-item-id="1">
<li>
<div>Id: 1</div><div>Name: John</div><div>Age: 20</div>
</li>
<span data-item-id="1">just for test</span></span>
<span class="testMe" data-item-id="2">
<li>
<div>Id: 2</div><div>Name: Mary</div><div>Age: 21</div>
</li>
<span data-item-id="2">just for test</span></span>
</ul>
<div>Page <b>1</b> of <b>1</b></div>
</div>
HTML,
ListView::widget()
->afterItem(static fn (ListItemContext $context) => '<span data-item-id="' . $context->data['id'] . '">just for test</span></span>')
->beforeItem(static fn (ListItemContext $context) => '<span class="testMe" data-item-id="' . $context->data['id'] . '">')
->itemView(dirname(__DIR__) . '/Support/view/_listview.php')
->dataReader($this->createOffsetPaginator($this->data, 10))
->render(),
);
}


public function testItemViewAttributes(): void
{
Assert::equalsWithoutLE(
Expand Down

0 comments on commit 00cd8ed

Please sign in to comment.