Skip to content

Commit

Permalink
Merge pull request #5147 from magento-tsg/2.4-develop-com-pr1
Browse files Browse the repository at this point in the history
[TSG-Commerce] Tests for 2.4 (pr1) (2.4-develop)
  • Loading branch information
zakdma authored Dec 20, 2019
2 parents c3630c9 + 2b15818 commit 4165276
Show file tree
Hide file tree
Showing 58 changed files with 4,307 additions and 512 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Block;

use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Registry;
use Magento\Framework\View\LayoutInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Theme\Block\Html\Breadcrumbs as ThemeBreadcrumbs;
use PHPUnit\Framework\TestCase;

/**
* Checks the behavior of breadcrumbs on the category view page.
*
* @magentoAppArea frontend
*/
class BreadcrumbsTest extends TestCase
{
/** @var ObjectManagerInterface */
private $objectManager;

/** @var LayoutInterface */
private $layout;

/** @var CategoryRepositoryInterface */
private $categoryRepository;

/** @var Registry */
private $registry;

/**
* @inheritdoc
*/
protected function setUp()
{
parent::setUp();

$this->objectManager = Bootstrap::getObjectManager();
$this->categoryRepository = $this->objectManager->create(CategoryRepositoryInterface::class);
$this->registry = $this->objectManager->get(Registry::class);
$this->layout = $this->objectManager->get(LayoutInterface::class);
}

/**
* Checks the order of categories in breadcrumbs.
*
* @magentoDataFixture Magento/Catalog/_files/category_tree.php
* @return void
*/
public function testCategoriesSequence(): void
{
$category = $this->categoryRepository->get(402);
$this->registry->register('current_category', $category);
$themeBreadcrumbs = $this->layout->createBlock(ThemeBreadcrumbs::class, 'breadcrumbs');
$this->layout->createBlock(Breadcrumbs::class);
$html = $themeBreadcrumbs->toHtml();

$actualCategories = preg_replace('/\s+/', '', strip_tags($html));
$expectedCategories = __('Home') . 'Category1' . 'Category1.1' . 'Category1.1.1';
self::assertEquals(
$expectedCategories,
$actualCategories,
'The order of categories in breadcrumbs is not correct!'
);
}
}
Loading

0 comments on commit 4165276

Please sign in to comment.