/** * @param string $fixtureName * @param string $fixtureDataSet * @param int $itemsCount * @param array $steps * @param string $pageClass * @param string $gridRetriever * @param string $idGetter * @param array $filters * @param string $idColumn * @return array */ public function test($pageClass, $gridRetriever, $idGetter, array $filters, $fixtureName, $itemsCount, array $steps = [], $fixtureDataSet = null, $idColumn = null) { $items = $this->createItems($itemsCount, $fixtureName, $fixtureDataSet, $steps); $page = $this->pageFactory->create($pageClass); // Steps $page->open(); /** @var DataGrid $gridBlock */ $gridBlock = $page->{$gridRetriever}(); $gridBlock->resetFilter(); $filterResults = []; foreach ($filters as $index => $itemFilters) { foreach ($itemFilters as $itemFiltersName => $itemFilterValue) { if (substr($itemFilterValue, 0, 1) === ':') { $value = $items[$index]->getData(substr($itemFilterValue, 1)); } else { $value = $itemFilterValue; } $gridBlock->search([$itemFiltersName => $value]); $idsInGrid = $gridBlock->getAllIds(); if ($idColumn) { $filteredTargetIds = []; foreach ($idsInGrid as $filteredId) { $filteredTargetIds[] = $gridBlock->getColumnValue($filteredId, $idColumn); } $idsInGrid = $filteredTargetIds; } $filteredIds = $this->getActualIds($idsInGrid, $items, $idGetter); $filterResults[$items[$index]->{$idGetter}()][$itemFiltersName] = $filteredIds; } } return ['filterResults' => $filterResults]; }
/** * @param string $fixtureName * @param string $fixtureDataSet * @param int $itemsCount * @param array $steps * @param string $pageClass * @param string $gridRetriever * @param string $idGetter * @param string $fieldGetter * @param string $idColumn * @return array */ public function test($pageClass, $gridRetriever, $idGetter, $fieldGetter, $fixtureName, $itemsCount, array $steps = [], $fixtureDataSet = null, $idColumn = null) { $items = $this->createItems($itemsCount, $fixtureName, $fixtureDataSet, $steps); $page = $this->pageFactory->create($pageClass); // Steps $page->open(); /** @var DataGrid $gridBlock */ $gridBlock = $page->{$gridRetriever}(); $gridBlock->resetFilter(); $filterResults = []; foreach ($items as $item) { $gridBlock->fullTextSearch($item->{$fieldGetter}()); $idsInGrid = $gridBlock->getAllIds(); if ($idColumn) { $filteredTargetIds = []; foreach ($idsInGrid as $filteredId) { $filteredTargetIds[] = $gridBlock->getColumnValue($filteredId, $idColumn); } $idsInGrid = $filteredTargetIds; } $filteredIds = $this->getActualIds($idsInGrid, $items, $idGetter); $filterResults[$item->{$idGetter}()] = $filteredIds; } return ['results' => $filterResults]; }
/** * @param string $fixtureName * @param string $fixtureDataSet * @param int $itemsCount * @param array $steps * @param string $pageClass * @param string $gridRetriever * @param array $columnsForSorting * @return array */ public function test($pageClass, $gridRetriever, array $columnsForSorting, $fixtureName = null, $fixtureDataSet = null, $itemsCount = null, array $steps = []) { // Fill grid before sorting if needed if ($fixtureName && $fixtureDataSet && $itemsCount && $steps) { $this->createItems($itemsCount, $fixtureName, $fixtureDataSet, $steps); } $page = $this->pageFactory->create($pageClass); // Steps $page->open(); /** @var DataGrid $gridBlock */ $gridBlock = $page->{$gridRetriever}(); $gridBlock->resetFilter(); $sortingResults = []; foreach ($columnsForSorting as $columnName) { $gridBlock->sortByColumn($columnName); $sortingResults[$columnName]['firstIdAfterFirstSoring'] = $gridBlock->getFirstItemId(); $gridBlock->sortByColumn($columnName); $sortingResults[$columnName]['firstIdAfterSecondSoring'] = $gridBlock->getFirstItemId(); } return ['sortingResults' => $sortingResults]; }