Skip to content

Commit 4165276

Browse files
authored
Merge pull request #5147 from magento-tsg/2.4-develop-com-pr1
[TSG-Commerce] Tests for 2.4 (pr1) (2.4-develop)
2 parents c3630c9 + 2b15818 commit 4165276

File tree

58 files changed

+4307
-512
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4307
-512
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Block;
9+
10+
use Magento\Catalog\Api\CategoryRepositoryInterface;
11+
use Magento\Framework\ObjectManagerInterface;
12+
use Magento\Framework\Registry;
13+
use Magento\Framework\View\LayoutInterface;
14+
use Magento\TestFramework\Helper\Bootstrap;
15+
use Magento\Theme\Block\Html\Breadcrumbs as ThemeBreadcrumbs;
16+
use PHPUnit\Framework\TestCase;
17+
18+
/**
19+
* Checks the behavior of breadcrumbs on the category view page.
20+
*
21+
* @magentoAppArea frontend
22+
*/
23+
class BreadcrumbsTest extends TestCase
24+
{
25+
/** @var ObjectManagerInterface */
26+
private $objectManager;
27+
28+
/** @var LayoutInterface */
29+
private $layout;
30+
31+
/** @var CategoryRepositoryInterface */
32+
private $categoryRepository;
33+
34+
/** @var Registry */
35+
private $registry;
36+
37+
/**
38+
* @inheritdoc
39+
*/
40+
protected function setUp()
41+
{
42+
parent::setUp();
43+
44+
$this->objectManager = Bootstrap::getObjectManager();
45+
$this->categoryRepository = $this->objectManager->create(CategoryRepositoryInterface::class);
46+
$this->registry = $this->objectManager->get(Registry::class);
47+
$this->layout = $this->objectManager->get(LayoutInterface::class);
48+
}
49+
50+
/**
51+
* Checks the order of categories in breadcrumbs.
52+
*
53+
* @magentoDataFixture Magento/Catalog/_files/category_tree.php
54+
* @return void
55+
*/
56+
public function testCategoriesSequence(): void
57+
{
58+
$category = $this->categoryRepository->get(402);
59+
$this->registry->register('current_category', $category);
60+
$themeBreadcrumbs = $this->layout->createBlock(ThemeBreadcrumbs::class, 'breadcrumbs');
61+
$this->layout->createBlock(Breadcrumbs::class);
62+
$html = $themeBreadcrumbs->toHtml();
63+
64+
$actualCategories = preg_replace('/\s+/', '', strip_tags($html));
65+
$expectedCategories = __('Home') . 'Category1' . 'Category1.1' . 'Category1.1.1';
66+
self::assertEquals(
67+
$expectedCategories,
68+
$actualCategories,
69+
'The order of categories in breadcrumbs is not correct!'
70+
);
71+
}
72+
}

0 commit comments

Comments
 (0)