From 30ec1bc5e0eaa8b07a7e5dcb019607366f07942a Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 15 Nov 2023 21:43:08 +0300 Subject: [PATCH] tmp --- src/BaseListView.php | 47 +++++++------------ src/GridView.php | 8 ++-- src/ListView.php | 2 +- tests/Column/ActionColumnTest.php | 34 +++++++------- tests/Column/CheckboxColumnTest.php | 20 ++++---- tests/Column/DataColumnFilterTest.php | 36 +++++++------- tests/Column/DataColumnTest.php | 28 +++++------ tests/Column/RadioColumnTest.php | 18 +++---- tests/GridView/BaseTest.php | 30 ++++++------ tests/GridView/ExceptionTest.php | 2 +- tests/GridView/ImmutableTest.php | 2 +- tests/GridView/TranslatorTest.php | 12 ++--- tests/ListView/BaseTest.php | 12 ++--- tests/ListView/ExceptionTest.php | 4 +- tests/Pagination/KeysetPaginationBaseTest.php | 12 ++--- tests/Pagination/OffsetPaginationBaseTest.php | 2 +- 16 files changed, 128 insertions(+), 141 deletions(-) diff --git a/src/BaseListView.php b/src/BaseListView.php index 32a3c57e1..00a7b5308 100644 --- a/src/BaseListView.php +++ b/src/BaseListView.php @@ -7,6 +7,7 @@ use Yiisoft\Data\Paginator\KeysetPaginator; use Yiisoft\Data\Paginator\OffsetPaginator; use Yiisoft\Data\Paginator\PaginatorInterface; +use Yiisoft\Data\Reader\ReadableDataInterface; use Yiisoft\Definitions\Exception\CircularReferenceException; use Yiisoft\Definitions\Exception\InvalidConfigException; use Yiisoft\Definitions\Exception\NotInstantiableException; @@ -28,7 +29,7 @@ abstract class BaseListView extends Widget private string $layout = "{header}\n{toolbar}"; private string $layoutGridTable = "{items}\n{summary}\n{pager}"; private string $pagination = ''; - protected ?PaginatorInterface $paginator = null; + protected ?ReadableDataInterface $dataReader = null; private SimpleMessageFormatter|null $simpleMessageFormatter = null; private array $sortLinkAttributes = []; private string $summary = 'dataview.summary'; @@ -95,13 +96,13 @@ public function emptyTextAttributes(array $values): static return $new; } - public function getPaginator(): PaginatorInterface + public function getDataReader(): PaginatorInterface { - if ($this->paginator === null) { + if ($this->dataReader === null) { throw new Exception\PaginatorNotSetException(); } - return $this->paginator; + return $this->dataReader; } public function getSimpleMessageFormatter(): SimpleMessageFormatter @@ -218,13 +219,12 @@ public function pagination(string $value): static /** * Returns a new instance with the paginator interface of the grid view, detail view, or list view. * - * @param PaginatorInterface $value The paginator interface of the grid view, detail view, or list view. + * @param ReadableDataInterface $dataReader The paginator interface of the grid view, detail view, or list view. */ - public function paginator(PaginatorInterface $value): static + public function dataReader(ReadableDataInterface $dataReader): static { $new = clone $this; - $new->paginator = $value; - + $new->dataReader = $dataReader; return $new; } @@ -332,18 +332,6 @@ public function withContainer(bool $value = true): static return $new; } - protected function getDataReader(): array - { - $dataReader = []; - - /** @var array */ - foreach ($this->getPaginator()->read() as $read) { - $dataReader[] = $read; - } - - return $dataReader; - } - protected function renderEmpty(int $colspan): Td { $emptyTextAttributes = $this->emptyTextAttributes; @@ -367,7 +355,7 @@ protected function renderEmpty(int $colspan): Td protected function renderLinkSorter(string $attribute, string $label): string { $renderLinkSorter = ''; - $paginator = $this->getPaginator(); + $paginator = $this->getDataReader(); $sort = $paginator->getSort(); $linkSorter = LinkSorter::widget(); @@ -384,7 +372,7 @@ protected function renderLinkSorter(string $attribute, string $label): string ->iconDescClass('bi bi-sort-alpha-down') ->label($label) ->linkAttributes($this->sortLinkAttributes) - ->pageSize($this->getPaginator()->getPageSize()) + ->pageSize($this->getDataReader()->getPageSize()) ->urlArguments($this->urlArguments) ->urlQueryParameters($this->urlQueryParameters) ->render(); @@ -395,7 +383,7 @@ protected function renderLinkSorter(string $attribute, string $label): string public function render(): string { - if ($this->paginator === null) { + if ($this->dataReader === null) { throw new Exception\PaginatorNotSetException(); } @@ -404,7 +392,7 @@ public function render(): string private function renderPagination(): string { - return match ($this->getPaginator()->isRequired()) { + return match ($this->getDataReader()->isRequired()) { true => $this->pagination, false => '', }; @@ -412,19 +400,20 @@ private function renderPagination(): string private function renderSummary(): string { - if ($this->getPaginator() instanceof KeysetPaginator) { + if ($this->getDataReader() instanceof KeysetPaginator) { return ''; } - $pageCount = count($this->getDataReader()); + /** @var OffsetPaginator $paginator */ + $paginator = $this->getDataReader(); + + $data = iterator_to_array($paginator->read()); + $pageCount = count($data); if ($pageCount <= 0) { return ''; } - /** @var OffsetPaginator $paginator */ - $paginator = $this->getPaginator(); - $summary = $this->getSimpleMessageFormatter() ->format( $this->summary, diff --git a/src/GridView.php b/src/GridView.php index ef76b239d..c01b1697a 100644 --- a/src/GridView.php +++ b/src/GridView.php @@ -304,7 +304,7 @@ private function guessColumns(): array $columns = []; /** @psalm-var array[] */ - $dataReader = $this->getDataReader(); + $dataReader = iterator_to_array($this->getDataReader()->read()); reset($dataReader); foreach ($dataReader as $data) { @@ -436,13 +436,11 @@ private function renderFilters(array $columns): string */ private function renderTableBody(array $columns): string { - $data = $this->getDataReader(); - $keys = array_keys($data); $rows = []; /** @psalm-var array $data */ - foreach ($data as $index => $value) { - $key = $keys[$index]; + foreach ($this->getDataReader()->read() as $index => $value) { + $key = $index; if ($this->beforeRow !== null) { /** @var array */ diff --git a/src/ListView.php b/src/ListView.php index bc05e729f..38ddc10b4 100644 --- a/src/ListView.php +++ b/src/ListView.php @@ -218,7 +218,7 @@ protected function renderItem(array|object $data, mixed $key, int $index): strin */ protected function renderItems(): string { - $data = $this->getDataReader(); + $data = iterator_to_array($this->getDataReader()->read()); $keys = array_keys($data); $rows = []; diff --git a/tests/Column/ActionColumnTest.php b/tests/Column/ActionColumnTest.php index d1b901f18..2264cf407 100644 --- a/tests/Column/ActionColumnTest.php +++ b/tests/Column/ActionColumnTest.php @@ -68,7 +68,7 @@ public function testContent(): void ), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -117,7 +117,7 @@ public function testContentAttributes(): void ->contentAttributes(['class' => 'text-decoration-none test.class']), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -172,7 +172,7 @@ public function testCustomButton(): void ->visibleButtons(['resend-password' => true]), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -217,7 +217,7 @@ public function testDataLabel(): void GridView::widget() ->columns(ActionColumn::create()->dataLabel('test.label')) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -270,7 +270,7 @@ public function testFooterAttributes(): void ) ->footerEnabled(true) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -315,7 +315,7 @@ public function testLabel(): void GridView::widget() ->columns(ActionColumn::create()->label('test.label')) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -360,7 +360,7 @@ public function testLabelWithMbString(): void GridView::widget() ->columns(ActionColumn::create()->label('Ενέργειες')) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -405,7 +405,7 @@ public function testLabelAttributes(): void GridView::widget() ->columns(ActionColumn::create()->label('test.label')->labelAttributes(['class' => 'test.class'])) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -450,7 +450,7 @@ public function testName(): void GridView::widget() ->columns(ActionColumn::create()->name('test.name')) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -481,7 +481,7 @@ public function testNotVisible(): void GridView::widget() ->columns(ActionColumn::create()->visible(false)) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -526,7 +526,7 @@ public function testPrimaryKey(): void GridView::widget() ->columns(ActionColumn::create()->primaryKey('identity_id')) ->id('w1-grid') - ->paginator( + ->dataReader( $this->createOffsetPaginator( [ ['identity_id' => 1, 'name' => 'John', 'age' => 20], @@ -589,7 +589,7 @@ public function testRender(): void ActionColumn::create(), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -634,7 +634,7 @@ public function testUrlArguments(): void GridView::widget() ->columns(ActionColumn::create()->urlArguments(['test-arguments' => 'test.arguments'])) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -685,7 +685,7 @@ public function testUrlCreator(): void ), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -730,7 +730,7 @@ public function testUrlQueryParameters(): void GridView::widget() ->columns(ActionColumn::create()->urlQueryParameters(['test-param' => 'test.param'])) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -775,7 +775,7 @@ public function testUrlParamsConfig(): void GridView::widget() ->columns(ActionColumn::create()->urlParamsConfig(['test-param' => 'test.param'])) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -823,7 +823,7 @@ public function testVisibleButtonsClosure(): void ), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } diff --git a/tests/Column/CheckboxColumnTest.php b/tests/Column/CheckboxColumnTest.php index aca7cf790..f9c4276f1 100644 --- a/tests/Column/CheckboxColumnTest.php +++ b/tests/Column/CheckboxColumnTest.php @@ -68,7 +68,7 @@ public function testContent(): void ), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -119,7 +119,7 @@ public function testContentAttributes(): void ->contentAttributes(['class' => 'test.class']), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -166,7 +166,7 @@ public function testDataLabel(): void CheckboxColumn::create()->dataLabel('test.label'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -213,7 +213,7 @@ public function testLabel(): void CheckboxColumn::create()->label('test.label'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -260,7 +260,7 @@ public function testLabelMbString(): void CheckboxColumn::create()->label('Πλαίσιο ελέγχου'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -307,7 +307,7 @@ public function testLabelAttributes(): void CheckboxColumn::create()->label('test.label')->labelAttributes(['class' => 'test.class']), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -354,7 +354,7 @@ public function testName(): void CheckboxColumn::create()->name('test.checkbox'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -401,7 +401,7 @@ public function testNotMultiple(): void CheckboxColumn::create()->multiple(false), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -445,7 +445,7 @@ public function testNotVisible(): void CheckboxColumn::create()->visible(false), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -492,7 +492,7 @@ public function testRender(): void CheckboxColumn::create(), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } diff --git a/tests/Column/DataColumnFilterTest.php b/tests/Column/DataColumnFilterTest.php index 8ab348918..f754ca525 100644 --- a/tests/Column/DataColumnFilterTest.php +++ b/tests/Column/DataColumnFilterTest.php @@ -105,7 +105,7 @@ public function testFilter(): void DataColumn::create()->attribute('name')->filter(''), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -157,7 +157,7 @@ public function testFilterDate(): void DataColumn::create()->attribute('birthday')->filterAttribute('birthday')->filterType('date'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->dataWithDate, 10)) + ->dataReader($this->createOffsetPaginator($this->dataWithDate, 10)) ->render() ); } @@ -209,7 +209,7 @@ public function testFilterDateTime(): void DataColumn::create()->attribute('birthday')->filterAttribute('birthday')->filterType('datetime'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->dataWithDateTime, 10)) + ->dataReader($this->createOffsetPaginator($this->dataWithDateTime, 10)) ->render() ); } @@ -261,7 +261,7 @@ public function testFilterEmail(): void DataColumn::create()->attribute('email')->filterAttribute('email')->filterType('email'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->dataWithEmail, 10)) + ->dataReader($this->createOffsetPaginator($this->dataWithEmail, 10)) ->render() ); } @@ -317,7 +317,7 @@ public function testFilterInputAttributes(): void ) ->filterModelName('searchModel') ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -369,7 +369,7 @@ public function testFilterMonth(): void DataColumn::create()->attribute('month')->filterAttribute('month')->filterType('month'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->dataWithMonth, 10)) + ->dataReader($this->createOffsetPaginator($this->dataWithMonth, 10)) ->render() ); } @@ -416,7 +416,7 @@ public function testFilterNumber(): void DataColumn::create()->attribute('name'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -481,7 +481,7 @@ public function testFilterPositionFooter(): void ->filterPosition(GridView::FILTER_POS_FOOTER) ->footerEnabled(true) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -540,7 +540,7 @@ public function testFilterPositionHeader(): void ->filterModelName('searchModel') ->filterPosition(GridView::FILTER_POS_HEADER) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -591,7 +591,7 @@ public function testFilterRange(): void DataColumn::create()->attribute('name'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -650,7 +650,7 @@ public function testFilterRowAttributes(): void ->filterModelName('searchModel') ->filterRowAttributes(['class' => 'text-center']) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -697,7 +697,7 @@ public function testFilterSearch(): void DataColumn::create()->attribute('name')->filterAttribute('name')->filterType('search'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -755,7 +755,7 @@ public function testFilterSelect(): void ->filterModelName('searchModel') ->filterRowAttributes(['class' => 'text-center']) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -809,7 +809,7 @@ public function testFilterTelephone(): void ->filterModelName('searchModel') ->filterRowAttributes(['class' => 'text-center']) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->dataWithTelephone, 10)) + ->dataReader($this->createOffsetPaginator($this->dataWithTelephone, 10)) ->render() ); } @@ -863,7 +863,7 @@ public function testFilterTime(): void ->filterModelName('searchModel') ->filterRowAttributes(['class' => 'text-center']) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->dataWithTime, 10)) + ->dataReader($this->createOffsetPaginator($this->dataWithTime, 10)) ->render() ); } @@ -917,7 +917,7 @@ public function testFilterUrl(): void ->filterModelName('searchModel') ->filterRowAttributes(['class' => 'text-center']) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->dataWithTime, 10)) + ->dataReader($this->createOffsetPaginator($this->dataWithTime, 10)) ->render() ); } @@ -971,7 +971,7 @@ public function testFilterWeek(): void ->filterModelName('searchModel') ->filterRowAttributes(['class' => 'text-center']) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->dataWithWeek, 10)) + ->dataReader($this->createOffsetPaginator($this->dataWithWeek, 10)) ->render() ); } @@ -1029,7 +1029,7 @@ public function testFilters(): void ) ->filterModelName('searchModel') ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } diff --git a/tests/Column/DataColumnTest.php b/tests/Column/DataColumnTest.php index 11f8ae10b..311f81df2 100644 --- a/tests/Column/DataColumnTest.php +++ b/tests/Column/DataColumnTest.php @@ -65,7 +65,7 @@ public function testContent(): void ->content(static fn (array $data): string => (string) $data['name']), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -114,7 +114,7 @@ public function testContentAttributes(): void ->contentAttributes(['class' => 'test.class']), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -161,7 +161,7 @@ public function testContentAttributesClosure(): void ->contentAttributes(['class' => static fn (): string => 'test.class']), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -204,7 +204,7 @@ public function testDataLabel(): void DataColumn::create()->attribute('name')->dataLabel('test.name'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -247,7 +247,7 @@ public function testLabel(): void DataColumn::create()->attribute('name')->label('test.username'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -290,7 +290,7 @@ public function testLabelMbString(): void DataColumn::create()->attribute('name')->label('Όνομα χρήστη'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -339,7 +339,7 @@ public function testLabelAttributes(): void ->labelAttributes(['class' => 'test.class']), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -386,7 +386,7 @@ public function testLinkSorter(): void ->linkSorter('name'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -429,7 +429,7 @@ public function testName(): void DataColumn::create()->attribute('name')->name('test.username'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10, 1, true)) + ->dataReader($this->createOffsetPaginator($this->data, 10, 1, true)) ->render() ); } @@ -472,7 +472,7 @@ public function testNotSorting(): void DataColumn::create()->attribute('name')->value('test'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10, 1, true)) + ->dataReader($this->createOffsetPaginator($this->data, 10, 1, true)) ->render() ); } @@ -512,7 +512,7 @@ public function testNotVisible(): void DataColumn::create()->attribute('name')->visible(false), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -555,7 +555,7 @@ public function testSort(): void DataColumn::create()->attribute('name'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10, 1, true)) + ->dataReader($this->createOffsetPaginator($this->data, 10, 1, true)) ->render() ); } @@ -598,7 +598,7 @@ public function testValue(): void DataColumn::create()->attribute('name')->value('test'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -645,7 +645,7 @@ public function testValueClosure(): void ->value(static fn (array $data): string => (string) $data['name']), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } diff --git a/tests/Column/RadioColumnTest.php b/tests/Column/RadioColumnTest.php index d308357b3..ab03fd184 100644 --- a/tests/Column/RadioColumnTest.php +++ b/tests/Column/RadioColumnTest.php @@ -69,7 +69,7 @@ public function testContent(): void ), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -120,7 +120,7 @@ public function testContentAttributes(): void ->contentAttributes(['class' => 'test-class']), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -167,7 +167,7 @@ public function testDataLabel(): void RadioColumn::create()->dataLabel('test.label'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -214,7 +214,7 @@ public function testLabel(): void RadioColumn::create()->label('test.label'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -261,7 +261,7 @@ public function testLabelMbString(): void RadioColumn::create()->label('Ραδιόφωνο'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -308,7 +308,7 @@ public function testLabelAttributes(): void RadioColumn::create()->label('test.label')->labelAttributes(['class' => 'test-class']), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -355,7 +355,7 @@ public function testName(): void RadioColumn::create()->name('test.radio'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -399,7 +399,7 @@ public function testNotVisible(): void RadioColumn::create()->visible(false), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -446,7 +446,7 @@ public function testRender(): void RadioColumn::create(), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } diff --git a/tests/GridView/BaseTest.php b/tests/GridView/BaseTest.php index 8e75c6909..83948581e 100644 --- a/tests/GridView/BaseTest.php +++ b/tests/GridView/BaseTest.php @@ -76,7 +76,7 @@ public function testAfterItemBeforeItem(): void DataColumn::create()->attribute('age'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -129,7 +129,7 @@ public function testColumnGroupEnabled(): void ) ->columnsGroupEnabled(true) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -187,7 +187,7 @@ public function testColumnGroupEnabledEmpty(): void ) ->columnsGroupEnabled(true) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -240,7 +240,7 @@ public function testColumnGuess(): void HTML, GridView::widget() ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -275,7 +275,7 @@ public function testEmptyCell(): void ->columns(DataColumn::create()->attribute('id')) ->emptyCell('Empty cell') ->id('w1-grid') - ->paginator($this->createOffsetPaginator([['id' => '']], 10)) + ->dataReader($this->createOffsetPaginator([['id' => '']], 10)) ->render() ); } @@ -317,7 +317,7 @@ public function testEmptyText(): void ) ->emptyText('Not found.') ->id('w1-grid') - ->paginator($this->createOffsetPaginator([], 10)) + ->dataReader($this->createOffsetPaginator([], 10)) ->render() ); } @@ -371,7 +371,7 @@ public function testFooterRowAttributes(): void ->footerEnabled(true) ->footerRowAttributes(['class' => 'text-primary']) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -424,7 +424,7 @@ public function testHeader(): void ) ->header('List of users') ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -477,7 +477,7 @@ public function testHeaderIntoGrid(): void ) ->header('List of users') ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->layout('') ->layoutGridTable("{header}\n{items}\n{summary}") ->render() @@ -531,7 +531,7 @@ public function testHeaderRowAttributes(): void ) ->headerRowAttributes(['class' => 'text-primary']) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -575,7 +575,7 @@ public function testHeaderTableEnabledFalse(): void ) ->headerTableEnabled(false) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -616,7 +616,7 @@ public function testRenderEmptyData(): void DataColumn::create()->attribute('age'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator([], 10)) + ->dataReader($this->createOffsetPaginator([], 10)) ->render() ); } @@ -667,7 +667,7 @@ public function testRowAttributes(): void DataColumn::create()->attribute('age'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->rowAttributes(['class' => 'text-primary']) ->render() ); @@ -710,7 +710,7 @@ public function testRowAttributes(): void DataColumn::create()->attribute('age'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->rowAttributes(['class' => 'text-primary']) ->render() ); @@ -762,7 +762,7 @@ public function testTableAttributes(): void DataColumn::create()->attribute('age'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->tableAttributes(['class' => 'table table-striped table-bordered']) ->render() ); diff --git a/tests/GridView/ExceptionTest.php b/tests/GridView/ExceptionTest.php index 5cd9d2bb8..cc83085a3 100644 --- a/tests/GridView/ExceptionTest.php +++ b/tests/GridView/ExceptionTest.php @@ -36,7 +36,7 @@ public function testGetPaginator(): void { $this->expectException(Exception\PaginatorNotSetException::class); $this->expectExceptionMessage('Failed to create widget because "paginator" is not set.'); - DataView\GridView::widget()->getPaginator(); + DataView\GridView::widget()->getDataReader(); } /** diff --git a/tests/GridView/ImmutableTest.php b/tests/GridView/ImmutableTest.php index 9eaa04c48..d321e7749 100644 --- a/tests/GridView/ImmutableTest.php +++ b/tests/GridView/ImmutableTest.php @@ -34,7 +34,7 @@ public function testBaseListView(): void $this->assertNotSame($baseListView, $baseListView->layout('')); $this->assertNotSame($baseListView, $baseListView->layoutGridTable('')); $this->assertNotSame($baseListView, $baseListView->pagination('')); - $this->assertNotSame($baseListView, $baseListView->paginator($this->createOffsetPaginator($this->data, 10))); + $this->assertNotSame($baseListView, $baseListView->dataReader($this->createOffsetPaginator($this->data, 10))); $this->assertNotSame($baseListView, $baseListView->sortLinkAttributes([])); $this->assertNotSame($baseListView, $baseListView->summary('')); $this->assertNotSame($baseListView, $baseListView->summaryAttributes([])); diff --git a/tests/GridView/TranslatorTest.php b/tests/GridView/TranslatorTest.php index 9176b0477..98314bceb 100644 --- a/tests/GridView/TranslatorTest.php +++ b/tests/GridView/TranslatorTest.php @@ -86,7 +86,7 @@ public function testEmptyTextTranslatorWithLocaleDefault(): void DataColumn::create()->attribute('age'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator([], 10)) + ->dataReader($this->createOffsetPaginator([], 10)) ->render() ); } @@ -129,7 +129,7 @@ public function testEmptyTextTranslatorWithLocaleSpanish(): void DataColumn::create()->attribute('age'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator([], 10)) + ->dataReader($this->createOffsetPaginator([], 10)) ->render() ); } @@ -172,7 +172,7 @@ public function testEmptyTextTranslatorWithLocaleRussian(): void DataColumn::create()->attribute('age'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator([], 10)) + ->dataReader($this->createOffsetPaginator([], 10)) ->render() ); } @@ -223,7 +223,7 @@ public function testSummaryTranslatorWithLocaleDefault(): void DataColumn::create()->attribute('age'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -276,7 +276,7 @@ public function testSummaryTranslatorWithLocaleSpanish(): void DataColumn::create()->attribute('age'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } @@ -329,7 +329,7 @@ public function testSummaryTranslatorWithLocaleRussian(): void DataColumn::create()->attribute('age'), ) ->id('w1-grid') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render() ); } diff --git a/tests/ListView/BaseTest.php b/tests/ListView/BaseTest.php index 1724685a1..9e3230d86 100644 --- a/tests/ListView/BaseTest.php +++ b/tests/ListView/BaseTest.php @@ -51,7 +51,7 @@ public function testAfterItemBeforeItem(): void ->afterItem(static fn () => '') ->beforeItem(static fn () => '') ->itemView('//_listview') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->webView(Mock::webView()) ->render(), ); @@ -80,7 +80,7 @@ public function testItemViewAttributes(): void ListView::widget() ->itemView('//_listview') ->itemViewAttributes(['class' => 'testMe']) - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->webView(Mock::webView()) ->render(), ); @@ -108,7 +108,7 @@ public function testItemViewAsString(): void HTML, ListView::widget() ->itemView('//_listview') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->webView(Mock::webView()) ->render(), ); @@ -138,7 +138,7 @@ public function testItemViewAsCallable(): void ->itemView( fn (array $data) => '
' . $data['id'] . '
' . $data['name'] . '
' . PHP_EOL ) - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->webView(Mock::webView()) ->render(), ); @@ -166,7 +166,7 @@ public function testSeparator(): void HTML, ListView::widget() ->itemView('//_listview') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->separator(PHP_EOL) ->webView(Mock::webView()) ->render(), @@ -195,7 +195,7 @@ public function testViewParams(): void HTML, ListView::widget() ->itemView('//_listviewparams') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->separator(PHP_EOL) ->webView(Mock::webView()) ->viewParams(['itemClass' => 'text-success']) diff --git a/tests/ListView/ExceptionTest.php b/tests/ListView/ExceptionTest.php index 092ac3f3f..b4b64151d 100644 --- a/tests/ListView/ExceptionTest.php +++ b/tests/ListView/ExceptionTest.php @@ -50,7 +50,7 @@ public function testGetWebView(): void $this->expectExceptionMessage('Failed to create widget because "webview" is not set.'); ListView::widget() ->itemView('//_listview') - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render(); } @@ -65,7 +65,7 @@ public function testItemViewWithNull(): void $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The "itemView" property must be set.'); ListView::widget() - ->paginator($this->createOffsetPaginator($this->data, 10)) + ->dataReader($this->createOffsetPaginator($this->data, 10)) ->render(); } } diff --git a/tests/Pagination/KeysetPaginationBaseTest.php b/tests/Pagination/KeysetPaginationBaseTest.php index 56971597c..b6734d552 100644 --- a/tests/Pagination/KeysetPaginationBaseTest.php +++ b/tests/Pagination/KeysetPaginationBaseTest.php @@ -61,7 +61,7 @@ public function testRenderPaginatorEmptyData(): void HTML, GridView::widget() ->id('w1-grid') - ->paginator($keysetPaginator) + ->dataReader($keysetPaginator) ->pagination(KeysetPagination::widget()->paginator($keysetPaginator)->render()) ->render(), ); @@ -131,7 +131,7 @@ public function testRenderPaginationLinks(): void DataColumn::create()->attribute('description'), ) ->id('w1-grid') - ->paginator($keysetPaginator) + ->dataReader($keysetPaginator) ->pagination(KeysetPagination::widget()->paginator($keysetPaginator)->urlArguments([])->render()) ->layoutGridTable('{items}' . PHP_EOL . '{pager}') ->render(), @@ -193,7 +193,7 @@ public function testRenderPaginationLinks(): void DataColumn::create()->attribute('description'), ) ->id('w1-grid') - ->paginator($keysetPaginator) + ->dataReader($keysetPaginator) ->pagination(KeysetPagination::widget()->paginator($keysetPaginator)->urlArguments([])->render()) ->layoutGridTable('{items}' . PHP_EOL . '{pager}') ->render(), @@ -240,7 +240,7 @@ public function testRenderPaginationLinks(): void DataColumn::create()->attribute('description'), ) ->id('w1-grid') - ->paginator($keysetPaginator) + ->dataReader($keysetPaginator) ->pagination(KeysetPagination::widget()->paginator($keysetPaginator)->urlArguments([])->render()) ->layoutGridTable('{items}' . PHP_EOL . '{pager}') ->render(), @@ -302,7 +302,7 @@ public function testRenderPaginationLinks(): void DataColumn::create()->attribute('description'), ) ->id('w1-grid') - ->paginator($keysetPaginator) + ->dataReader($keysetPaginator) ->pagination(KeysetPagination::widget()->paginator($keysetPaginator)->urlArguments([])->render()) ->layoutGridTable('{items}' . PHP_EOL . '{pager}') ->render(), @@ -364,7 +364,7 @@ public function testRenderPaginationLinks(): void DataColumn::create()->attribute('description'), ) ->id('w1-grid') - ->paginator($keysetPaginator) + ->dataReader($keysetPaginator) ->pagination(KeysetPagination::widget()->paginator($keysetPaginator)->urlArguments([])->render()) ->layoutGridTable('{items}' . PHP_EOL . '{pager}') ->render(), diff --git a/tests/Pagination/OffsetPaginationBaseTest.php b/tests/Pagination/OffsetPaginationBaseTest.php index a48c9ac41..68ef5e445 100644 --- a/tests/Pagination/OffsetPaginationBaseTest.php +++ b/tests/Pagination/OffsetPaginationBaseTest.php @@ -45,7 +45,7 @@ public function testRenderPaginatorEmptyData(): void HTML, GridView::widget() ->id('w1-grid') - ->paginator($offsetPaginator) + ->dataReader($offsetPaginator) ->pagination(OffsetPagination::widget()->paginator($offsetPaginator)->render()) ->render(), );