Skip to content

Commit d1db14c

Browse files
committed
MC-31251: Wishlist configurations enabled/disabled
1 parent 7a39867 commit d1db14c

File tree

7 files changed

+31
-17
lines changed

7 files changed

+31
-17
lines changed

dev/tests/integration/testsuite/Magento/Customer/Controller/Section/LoadTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\App\Request\Http as HttpRequest;
1212
use Magento\Framework\Serialize\SerializerInterface;
1313
use Magento\TestFramework\TestCase\AbstractController;
14+
use Magento\Framework\Escaper;
1415

1516
/**
1617
* Load customer data test class.
@@ -26,6 +27,9 @@ class LoadTest extends AbstractController
2627
/** @var SerializerInterface */
2728
private $json;
2829

30+
/** @var Escaper */
31+
private $escaper;
32+
2933
/**
3034
* @inheritdoc
3135
*/
@@ -35,6 +39,7 @@ protected function setUp()
3539

3640
$this->customerSession = $this->_objectManager->get(Session::class);
3741
$this->json = $this->_objectManager->get(SerializerInterface::class);
42+
$this->escaper = $this->_objectManager->get(Escaper::class);
3843
}
3944

4045
/**
@@ -52,9 +57,8 @@ protected function tearDown()
5257
*/
5358
public function testLoadInvalidSection(): void
5459
{
55-
$expected = [
56-
'message' => 'The "section<invalid" section source isn't supported.',
57-
];
60+
$message = $this->escaper->escapeHtml('The "section<invalid" section source isn\'t supported.');
61+
$expected = ['message' => $message];
5862
$this->dispatch(
5963
'/customer/section/load/?sections=section<invalid&force_new_section_timestamp=false&_=147066166394'
6064
);

dev/tests/integration/testsuite/Magento/Wishlist/Block/Catalog/Product/ProductList/Item/AddTo/WishlistTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515

1616
/**
17-
* Test button add to wish list link on category page.
17+
* Checks add to wishlist button on category page.
1818
*
1919
* @magentoAppArea frontend
2020
* @magentoDbIsolation enabled
@@ -40,7 +40,7 @@ protected function setUp()
4040
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
4141
$this->productRepository->cleanCache();
4242
$this->block = $this->objectManager->get(LayoutInterface::class)
43-
->addBlock(Wishlist::class)->setTemplate('Magento_Wishlist::catalog/product/list/addto/wishlist.phtml');
43+
->createBlock(Wishlist::class)->setTemplate('Magento_Wishlist::catalog/product/list/addto/wishlist.phtml');
4444
}
4545

4646
/**
@@ -51,7 +51,8 @@ protected function setUp()
5151
public function testAddToWishListVisible(): void
5252
{
5353
$product = $this->productRepository->get('simple2');
54-
$this->assertContains('Add to Wish List', strip_tags($this->block->setProduct($product)->toHtml()));
54+
$html = $this->block->setProduct($product)->toHtml();
55+
$this->assertEquals('Add to Wish List', trim(strip_tags($html)));
5556
}
5657

5758
/**

dev/tests/integration/testsuite/Magento/Wishlist/Block/Catalog/Product/View/AddTo/WishlistTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@
1313
use Magento\Framework\Registry;
1414
use Magento\Framework\View\LayoutInterface;
1515
use Magento\TestFramework\Helper\Bootstrap;
16+
use Magento\TestFramework\Helper\Xpath;
1617
use PHPUnit\Framework\TestCase;
1718

1819
/**
19-
* Test button add to wish list link on product page.
20+
* Checks add to wishlist button on product page.
2021
*
2122
* @magentoAppArea frontend
2223
* @magentoDbIsolation enabled
2324
* @magentoAppIsolation disabled
2425
*/
2526
class WishlistTest extends TestCase
2627
{
28+
private const ADD_TO_WISHLIST_XPATH = "//a[@data-action='add-to-wishlist']"
29+
. "/span[contains(text(), 'Add to Wish List')]";
30+
2731
/** @var ObjectManagerInterface */
2832
private $objectManager;
2933

@@ -46,7 +50,7 @@ protected function setUp()
4650
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
4751
$this->productRepository->cleanCache();
4852
$this->block = $this->objectManager->get(LayoutInterface::class)
49-
->addBlock(Wishlist::class)->setTemplate('Magento_Wishlist::catalog/product/view/addto/wishlist.phtml');
53+
->createBlock(Wishlist::class)->setTemplate('Magento_Wishlist::catalog/product/view/addto/wishlist.phtml');
5054
}
5155

5256
/**
@@ -68,7 +72,10 @@ public function testAddToWishListVisible(): void
6872
{
6973
$product = $this->productRepository->get('simple2');
7074
$this->registerProduct($product);
71-
$this->assertContains('Add to Wish List', strip_tags($this->block->toHtml()));
75+
$this->assertEquals(
76+
1,
77+
Xpath::getElementsCountForXpath(self::ADD_TO_WISHLIST_XPATH, $this->block->toHtml())
78+
);
7279
}
7380

7481
/**
@@ -81,7 +88,10 @@ public function testAddToWishListNotVisible(): void
8188
{
8289
$product = $this->productRepository->get('simple2');
8390
$this->registerProduct($product);
84-
$this->assertNotContains('Add to Wish List', strip_tags($this->block->toHtml()));
91+
$this->assertEquals(
92+
0,
93+
Xpath::getElementsCountForXpath(self::ADD_TO_WISHLIST_XPATH, $this->block->toHtml())
94+
);
8595
}
8696

8797
/**

dev/tests/integration/testsuite/Magento/Wishlist/Block/Customer/SidebarTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ protected function setUp()
4040
$this->objectManager = Bootstrap::getObjectManager();
4141
$productMetadataInterface = $this->objectManager->get(ProductMetadataInterface::class);
4242
if ($productMetadataInterface->getEdition() !== ProductMetadata::EDITION_NAME) {
43-
$this->markTestSkipped('Skipped, because this logic is rewritten on Enterprise edition.');
43+
$this->markTestSkipped('Skipped, because this logic is rewritten on EE.');
4444
}
45-
$this->page = $this->objectManager->get(Page::class);
45+
$this->page = $this->objectManager->create(Page::class);
4646
}
4747

4848
/**

dev/tests/integration/testsuite/Magento/Wishlist/Block/Customer/WishlistTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424
class WishlistTest extends TestCase
2525
{
26-
2726
private const ITEMS_COUNT_XPATH = "//div[contains(@class, 'pager')]//span[contains(@class, 'toolbar-number')"
2827
. " and contains(text(), '%s Item')]";
2928

@@ -44,7 +43,7 @@ protected function setUp()
4443
parent::setUp();
4544

4645
$this->objectManager = Bootstrap::getObjectManager();
47-
$this->page = $this->objectManager->get(Page::class);
46+
$this->page = $this->objectManager->create(Page::class);
4847
$this->customerSession = $this->objectManager->get(Session::class);
4948
}
5049

dev/tests/integration/testsuite/Magento/Wishlist/Block/LinkTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LinkTest extends TestCase
3333
protected function setUp()
3434
{
3535
$this->objectManager = Bootstrap::getObjectManager();
36-
$this->block = $this->objectManager->get(LayoutInterface::class)->addBlock(Link::class);
36+
$this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Link::class);
3737
}
3838

3939
/**

dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_product_qty_three.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
declare(strict_types=1);
77

88
use Magento\Wishlist\Model\WishlistFactory;
9-
use Magento\Framework\Serialize\Serializer\Json;
9+
use Magento\Framework\Serialize\SerializerInterface;
1010

1111
require __DIR__ . '/../../../Magento/Customer/_files/customer.php';
1212
require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php';
1313

14-
$json = $objectManager->get(Json::class);
14+
$json = $objectManager->get(SerializerInterface::class);
1515
$wishlistFactory = $objectManager->get(WishlistFactory::class);
1616
$wishlist = $wishlistFactory->create();
1717
$wishlist->loadByCustomerId($customer->getId(), true);

0 commit comments

Comments
 (0)