9 use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
10 use Magento\Mtf\Client\BrowserInterface;
11 use Magento\Mtf\Constraint\AbstractConstraint;
33 BrowserInterface $browser,
35 CatalogCategoryView $catalogCategoryView,
38 $browser->open($_ENV[
'app_frontend_url'] .
$category->getUrlKey() .
'.html');
39 \PHPUnit\Framework\Assert::assertEquals(
41 $catalogCategoryView->getBottomToolbar()->isVisible(),
42 'Pagination is not visible' 44 \PHPUnit\Framework\Assert::assertEquals(
45 $catalogCategoryView->getBottomToolbar()->getLimitedValueByIndex(0),
46 $catalogCategoryView->getListProductBlock()->getProductsCount(),
47 'Count of products on 1 page does not equivalent with declared in pagination (default value)' 49 $catalogCategoryView->getBottomToolbar()->nextPage();
50 \PHPUnit\Framework\Assert::assertEquals(
51 $this->calculateExpectedProductsCountOnPage(
52 $catalogCategoryView->getBottomToolbar()->getLimitedValueByIndex(0),
56 $catalogCategoryView->getListProductBlock()->getProductsCount(),
57 'Count of products on 2 page does not equivalent with declared in pagination (default value)' 59 $catalogCategoryView->getBottomToolbar()->firstPage();
60 $catalogCategoryView->getBottomToolbar()->setLimiterValueByIndex(1);
61 \PHPUnit\Framework\Assert::assertEquals(
62 $catalogCategoryView->getBottomToolbar()->getLimitedValueByIndex(1),
63 $catalogCategoryView->getListProductBlock()->getProductsCount(),
64 'Count of products on 1 page does not equivalent with declared in pagination(custom value)' 66 $catalogCategoryView->getBottomToolbar()->nextPage();
67 \PHPUnit\Framework\Assert::assertEquals(
68 $this->calculateExpectedProductsCountOnPage(
69 $catalogCategoryView->getBottomToolbar()->getLimitedValueByIndex(1),
73 $catalogCategoryView->getListProductBlock()->getProductsCount(),
74 'Count of products on 2 page does not equivalent with declared in pagination(custom value)' 86 private function calculateExpectedProductsCountOnPage($productsPerPage, $numberOfPage, $totalProductsCount)
88 return min($productsPerPage, $totalProductsCount - $productsPerPage * ($numberOfPage - 1));
98 return 'Pagination is correct on frontend.';