Skip to content

Add tests for empty container, page size, and summary tag values; enhance immutability checks. #272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/ListView/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Yiisoft\Yii\DataView\Tests\ListView;

use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Yiisoft\Data\Paginator\InvalidPageException;
use Yiisoft\Definitions\Exception\CircularReferenceException;
Expand Down Expand Up @@ -609,4 +610,28 @@ public function testAddContainerClass(): void
->render(),
);
}

public function testThrowExceptionForContainterTagEmptyValue(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Tag name cannot be empty.');

ListView::widget()->containerTag('');
}

public function testThrowExceptionForPageSizeTagEmptyValue(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Tag name cannot be empty.');

ListView::widget()->pageSizeTag('');
}

public function testThrowExceptionFotSummaryTagEmptyValue(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Tag name cannot be empty.');

ListView::widget()->summaryTag('');
}
}
9 changes: 7 additions & 2 deletions tests/ListView/ImmutableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ public function testImmutable(): void
$listView = ListView::widget();
$this->assertNotSame($listView, $listView->afterItem(fn () => ''));
$this->assertNotSame($listView, $listView->beforeItem(fn () => ''));
$this->assertNotSame($listView, $listView->itemView(''));
$this->assertNotSame($listView, $listView->itemAttributes([]));
$this->assertNotSame($listView, $listView->separator(''));
$this->assertNotSame($listView, $listView->itemView(''));
$this->assertNotSame($listView, $listView->itemViewParameters([]));
$this->assertNotSame($listView, $listView->pageParameterType(1));
$this->assertNotSame($listView, $listView->pageSizeParameterType(1));
$this->assertNotSame($listView, $listView->previousPageParameterType(1));
$this->assertNotSame($listView, $listView->separator(''));
$this->assertNotSame($listView, $listView->sortParameterName(''));
$this->assertNotSame($listView, $listView->sortParameterType(1));
}
}
Loading