init
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Block\Account;
|
||||
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Checks My Wish List link displaying in account dashboard
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
* @magentoDbIsolation enabled
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
class LinkTest extends TestCase
|
||||
{
|
||||
/** @var ObjectManagerInterface */
|
||||
private $objectManager;
|
||||
|
||||
/** @var Page */
|
||||
private $page;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->page = $this->objectManager->create(Page::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testNewsletterLink(): void
|
||||
{
|
||||
$this->preparePage();
|
||||
$block = $this->page->getLayout()->getBlock('customer-account-navigation-wish-list-link');
|
||||
$this->assertNotFalse($block);
|
||||
$html = $block->toHtml();
|
||||
$this->assertStringContainsString('wishlist/', $html);
|
||||
$this->assertEquals('My Wish List', strip_tags($html));
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture current_store wishlist/general/active 0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNewsletterLinkDisabled(): void
|
||||
{
|
||||
$this->preparePage();
|
||||
$block = $this->page->getLayout()->getBlock('customer-account-navigation-wish-list-link');
|
||||
$this->assertFalse($block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare page before render
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function preparePage(): void
|
||||
{
|
||||
$this->page->addHandle([
|
||||
'default',
|
||||
'customer_account',
|
||||
]);
|
||||
$this->page->getLayout()->generateXml();
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Block\Catalog\Product\ProductList\Item\AddTo;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\View\LayoutInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Checks add to wishlist button on category page.
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
* @magentoDbIsolation enabled
|
||||
* @magentoAppIsolation disabled
|
||||
*/
|
||||
class WishlistTest extends TestCase
|
||||
{
|
||||
/** @var ObjectManagerInterface */
|
||||
private $objectManager;
|
||||
|
||||
/** @var Wishlist */
|
||||
private $block;
|
||||
|
||||
/** @var ProductRepositoryInterface */
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
|
||||
$this->productRepository->cleanCache();
|
||||
$this->block = $this->objectManager->get(LayoutInterface::class)
|
||||
->createBlock(Wishlist::class)->setTemplate('Magento_Wishlist::catalog/product/list/addto/wishlist.phtml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddToWishListVisible(): void
|
||||
{
|
||||
$product = $this->productRepository->get('simple2');
|
||||
$html = $this->block->setProduct($product)->toHtml();
|
||||
$this->assertEquals('Add to Wish List', trim(strip_tags($html)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture current_store wishlist/general/active 0
|
||||
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddToWishListNotVisible(): void
|
||||
{
|
||||
$product = $this->productRepository->get('simple2');
|
||||
$this->assertEmpty($this->block->setProduct($product)->toHtml());
|
||||
}
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Block\Catalog\Product\View\AddTo;
|
||||
|
||||
use Magento\Catalog\Api\Data\ProductInterface;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\View\LayoutInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Helper\Xpath;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Checks add to wishlist button on product page.
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
* @magentoDbIsolation enabled
|
||||
* @magentoAppIsolation disabled
|
||||
*/
|
||||
class WishlistTest extends TestCase
|
||||
{
|
||||
private const ADD_TO_WISHLIST_XPATH = "//a[@data-action='add-to-wishlist']"
|
||||
. "/span[contains(text(), 'Add to Wish List')]";
|
||||
|
||||
/** @var ObjectManagerInterface */
|
||||
private $objectManager;
|
||||
|
||||
/** @var Registry */
|
||||
private $registry;
|
||||
|
||||
/** @var Wishlist */
|
||||
private $block;
|
||||
|
||||
/** @var ProductRepositoryInterface */
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->registry = $this->objectManager->get(Registry::class);
|
||||
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
|
||||
$this->productRepository->cleanCache();
|
||||
$this->block = $this->objectManager->get(LayoutInterface::class)
|
||||
->createBlock(Wishlist::class)->setTemplate('Magento_Wishlist::catalog/product/view/addto/wishlist.phtml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->registry->unregister('product');
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddToWishListVisible(): void
|
||||
{
|
||||
$product = $this->productRepository->get('simple2');
|
||||
$this->registerProduct($product);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
Xpath::getElementsCountForXpath(self::ADD_TO_WISHLIST_XPATH, $this->block->toHtml())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture current_store wishlist/general/active 0
|
||||
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddToWishListNotVisible(): void
|
||||
{
|
||||
$product = $this->productRepository->get('simple2');
|
||||
$this->registerProduct($product);
|
||||
$this->assertEquals(
|
||||
0,
|
||||
Xpath::getElementsCountForXpath(self::ADD_TO_WISHLIST_XPATH, $this->block->toHtml())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the product.
|
||||
*
|
||||
* @param ProductInterface $product
|
||||
* @return void
|
||||
*/
|
||||
private function registerProduct(ProductInterface $product): void
|
||||
{
|
||||
$this->registry->unregister('product');
|
||||
$this->registry->register('product', $product);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Block\Customer;
|
||||
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\View\LayoutInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Helper\Xpath;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Class test share wish list block.
|
||||
*
|
||||
* @magentoDbIsolation enabled
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class SharingTest extends TestCase
|
||||
{
|
||||
/** @var ObjectManagerInterface */
|
||||
private $objectManager;
|
||||
|
||||
/** @var Sharing */
|
||||
private $block;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Sharing::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testDisplayWishListSharingForm(): void
|
||||
{
|
||||
$elementsXpath = [
|
||||
'Emails input' => "//form[contains(@class, 'share')]//textarea[@name='emails' and @id='email_address']",
|
||||
'Message input' => "//form[contains(@class, 'share')]//textarea[@name='message' and @id='message']",
|
||||
'Share button' => "//form[contains(@class, 'share')]//button[contains(@class, 'submit')]"
|
||||
. "/span[contains(text(), 'Share Wish List')]",
|
||||
];
|
||||
$blockHtml = $this->block->setTemplate('Magento_Wishlist::sharing.phtml')->toHtml();
|
||||
foreach ($elementsXpath as $element => $xpath) {
|
||||
$this->assertEquals(
|
||||
1,
|
||||
Xpath::getElementsCountForXpath($xpath, $blockHtml),
|
||||
sprintf("%s was not found.", $element)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Block\Customer;
|
||||
|
||||
use Magento\Framework\App\ProductMetadata;
|
||||
use Magento\Framework\App\ProductMetadataInterface;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Helper\Xpath;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Class test sidebar wish list block.
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
* @magentoDbIsolation enabled
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
class SidebarTest extends TestCase
|
||||
{
|
||||
private const BLOCK_NAME = 'wishlist_sidebar';
|
||||
|
||||
/** @var ObjectManagerInterface */
|
||||
private $objectManager;
|
||||
|
||||
/** @var Page */
|
||||
private $page;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$productMetadataInterface = $this->objectManager->get(ProductMetadataInterface::class);
|
||||
if ($productMetadataInterface->getEdition() !== ProductMetadata::EDITION_NAME) {
|
||||
$this->markTestSkipped('Skipped, because this logic is rewritten on EE.');
|
||||
}
|
||||
$this->page = $this->objectManager->create(Page::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture current_store wishlist/general/show_in_sidebar 1
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSidebarWishListVisible(): void
|
||||
{
|
||||
$this->preparePageLayout();
|
||||
$block = $this->page->getLayout()->getBlock(self::BLOCK_NAME);
|
||||
$this->assertNotFalse($block);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
Xpath::getElementsCountForXpath(
|
||||
"//div[contains(@class, 'block-wishlist')]//strong[contains(text(), 'My Wish List')]",
|
||||
$block->toHtml()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture current_store wishlist/general/show_in_sidebar 0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSidebarWishListNotVisible(): void
|
||||
{
|
||||
$this->preparePageLayout();
|
||||
$this->assertFalse(
|
||||
$this->page->getLayout()->getBlock(self::BLOCK_NAME),
|
||||
'Sidebar wish list should not be visible.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare category page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function preparePageLayout(): void
|
||||
{
|
||||
$this->page->addHandle([
|
||||
'default',
|
||||
'catalog_category_view',
|
||||
]);
|
||||
$this->page->getLayout()->generateXml();
|
||||
}
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Block\Customer\Wishlist\Item;
|
||||
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\View\Element\Text;
|
||||
use Magento\Framework\View\LayoutInterface;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Helper\Xpath;
|
||||
use Magento\TestFramework\Wishlist\Model\GetWishlistByCustomerId;
|
||||
use Magento\Wishlist\Block\Customer\Wishlist\Items;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test wish list item column.
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
* @magentoAppArea frontend
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class ColumnTest extends TestCase
|
||||
{
|
||||
/** @var ObjectManagerInterface */
|
||||
private $objectManager;
|
||||
|
||||
/** @var Session */
|
||||
private $customerSession;
|
||||
|
||||
/** @var LayoutInterface */
|
||||
private $layout;
|
||||
|
||||
/** @var Column */
|
||||
private $block;
|
||||
|
||||
/** @var GetWishlistByCustomerId */
|
||||
private $getWishlistItemsByCustomerId;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->customerSession = $this->objectManager->get(Session::class);
|
||||
$this->layout = $this->objectManager->get(LayoutInterface::class);
|
||||
$this->block = $this->layout->addBlock(Column::class, 'test');
|
||||
$this->layout->addBlock(Text::class, 'child', 'test');
|
||||
$this->getWishlistItemsByCustomerId = $this->objectManager->get(GetWishlistByCustomerId::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(null);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testToHtml(): void
|
||||
{
|
||||
$item = new \StdClass();
|
||||
$this->block->setItem($item);
|
||||
$this->block->toHtml();
|
||||
$this->assertSame($item, $this->layout->getBlock('child')->getItem());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testGetJs(): void
|
||||
{
|
||||
$expected = uniqid();
|
||||
$this->layout->getBlock('child')->setJs($expected);
|
||||
$this->assertEquals($expected, $this->block->getJs());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testWishListItemButtons(): void
|
||||
{
|
||||
$buttons = [
|
||||
"Add to Cart button" => "//button[contains(@class, 'tocart')]/span[contains(text(), 'Add to Cart')]",
|
||||
"Edit button" => "//a[contains(@class, 'edit')]/span[contains(text(), 'Edit')]",
|
||||
"Remove item button" => "//a[contains(@class, 'delete')]/span[contains(text(), 'Remove item')]",
|
||||
];
|
||||
$item = $this->getWishlistItemsByCustomerId->getItemBySku(1, 'simple');
|
||||
$this->assertNotNull($item);
|
||||
$block = $this->getWishListItemsBlock()->getChildBlock('customer.wishlist.item.inner');
|
||||
$blockHtml = $block->setItem($item)->toHtml();
|
||||
foreach ($buttons as $buttonName => $xpath) {
|
||||
$this->assertEquals(
|
||||
1,
|
||||
Xpath::getElementsCountForXpath($xpath, $blockHtml),
|
||||
sprintf("%s wasn't found.", $buttonName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get wish list items block.
|
||||
*
|
||||
* @return Items
|
||||
*/
|
||||
private function getWishListItemsBlock(): Items
|
||||
{
|
||||
$page = $this->objectManager->create(PageFactory::class)->create();
|
||||
$page->addHandle([
|
||||
'default',
|
||||
'wishlist_index_index',
|
||||
]);
|
||||
$page->getLayout()->generateXml();
|
||||
|
||||
return $page->getLayout()->getBlock('customer.wishlist.items');
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test class for \Magento\Wishlist\Block\Customer\Wishlist\Item\Options.
|
||||
*/
|
||||
namespace Magento\Wishlist\Block\Customer\Wishlist\Item;
|
||||
|
||||
class OptionsTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testGetTemplate()
|
||||
{
|
||||
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
|
||||
\Magento\Framework\View\LayoutInterface::class
|
||||
)->createBlock(
|
||||
\Magento\Wishlist\Block\Customer\Wishlist\Item\Options::class
|
||||
);
|
||||
$this->assertEmpty($block->getTemplate());
|
||||
$product = new \Magento\Framework\DataObject(['type_id' => 'test']);
|
||||
$item = new \Magento\Framework\DataObject(['product' => $product]);
|
||||
$block->setItem($item);
|
||||
$this->assertNotEmpty($block->getTemplate());
|
||||
$block->setTemplate('template');
|
||||
$this->assertEquals('template', $block->getTemplate());
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Wishlist\Block\Customer\Wishlist;
|
||||
|
||||
class ItemsTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testGetColumns()
|
||||
{
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$layout = $objectManager->get(
|
||||
\Magento\Framework\View\LayoutInterface::class
|
||||
);
|
||||
$block = $layout->addBlock(\Magento\Wishlist\Block\Customer\Wishlist\Items::class, 'test');
|
||||
$child = $this->getMockBuilder(\Magento\Wishlist\Block\Customer\Wishlist\Item\Column::class)
|
||||
->setMethods(['isEnabled'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$child->expects($this->any())->method('isEnabled')->willReturn(true);
|
||||
$layout->addBlock($child, 'child', 'test');
|
||||
$expected = $child->getType();
|
||||
$columns = $block->getColumns();
|
||||
$this->assertNotEmpty($columns);
|
||||
foreach ($columns as $column) {
|
||||
$this->assertSame($expected, $column->getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Block\Customer;
|
||||
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Helper\Xpath;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Class test block wish list on customer account page.
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
* @magentoDbIsolation disabled
|
||||
* @magentoAppIsolation disabled
|
||||
*/
|
||||
class WishlistTest extends TestCase
|
||||
{
|
||||
private const ITEMS_COUNT_XPATH = "//div[contains(@class, 'pager')]//span[contains(@class, 'toolbar-number')"
|
||||
. " and contains(text(), '%s Item')]";
|
||||
|
||||
/** @var ObjectManagerInterface */
|
||||
private $objectManager;
|
||||
|
||||
/** @var Page */
|
||||
private $page;
|
||||
|
||||
/** @var Session */
|
||||
private $customerSession;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->page = $this->objectManager->create(Page::class);
|
||||
$this->customerSession = $this->objectManager->get(Session::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(null);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture current_store wishlist/wishlist_link/use_qty 0
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_product_qty_three.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDisplayNumberOfItemsInWishList(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$pagerBlockHtml = $this->getWishListBlock()->getChildBlock('wishlist_item_pager')->toHtml();
|
||||
$this->assertEquals(
|
||||
1,
|
||||
Xpath::getElementsCountForXpath(sprintf(self::ITEMS_COUNT_XPATH, 1), $pagerBlockHtml),
|
||||
"Element items count wasn't found."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture current_store wishlist/wishlist_link/use_qty 1
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_product_qty_three.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDisplayItemQuantitiesInWishList(): void
|
||||
{
|
||||
$this->markTestSkipped('Test is blocked by issue MC-31595');
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$pagerBlockHtml = $this->getWishListBlock()->getChildBlock('wishlist_item_pager')->toHtml();
|
||||
$this->assertEquals(
|
||||
1,
|
||||
Xpath::getElementsCountForXpath(sprintf(self::ITEMS_COUNT_XPATH, 3), $pagerBlockHtml),
|
||||
"Element items count wasn't found."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDisplayActionButtonsInWishList(): void
|
||||
{
|
||||
$buttonsXpath = [
|
||||
"//button[contains(@class, 'update') and @type='submit']/span[contains(text(), 'Update Wish List')]",
|
||||
"//button[contains(@class, 'share') and @type='submit']/span[contains(text(), 'Share Wish List')]",
|
||||
"//button[contains(@class, 'tocart') and @type='button']/span[contains(text(), 'Add All to Cart')]",
|
||||
];
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$blockHtml = $this->getWishListBlock()->toHtml();
|
||||
foreach ($buttonsXpath as $xpath) {
|
||||
$this->assertEquals(1, Xpath::getElementsCountForXpath($xpath, $blockHtml));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get wish list block.
|
||||
*
|
||||
* @return Wishlist
|
||||
*/
|
||||
private function getWishListBlock(): Wishlist
|
||||
{
|
||||
$this->page->addHandle([
|
||||
'default',
|
||||
'wishlist_index_index',
|
||||
]);
|
||||
$this->page->getLayout()->generateXml();
|
||||
|
||||
return $this->page->getLayout()->getBlock('customer.wishlist');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Block;
|
||||
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\View\LayoutInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Class test link my wish list in customer menu.
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
* @magentoDbIsolation enabled
|
||||
* @magentoAppIsolation disabled
|
||||
*/
|
||||
class LinkTest extends TestCase
|
||||
{
|
||||
/** @var ObjectManagerInterface */
|
||||
private $objectManager;
|
||||
|
||||
/** @var Link */
|
||||
private $block;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Link::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testWishListLinkVisible(): void
|
||||
{
|
||||
$this->assertStringContainsString('My Wish List', strip_tags($this->block->toHtml()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture current_store wishlist/general/active 0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testWishListLinkNotVisible(): void
|
||||
{
|
||||
$this->assertEmpty($this->block->toHtml());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\Wishlist\Block\Share;
|
||||
|
||||
class WishlistTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Magento\TestFramework\ObjectManager
|
||||
*/
|
||||
protected $_objectManager;
|
||||
|
||||
/**
|
||||
* @var \Magento\Wishlist\Block\Share\Wishlist
|
||||
*/
|
||||
protected $_block;
|
||||
|
||||
/**
|
||||
* @var \Magento\Customer\Model\Session
|
||||
*/
|
||||
protected $_customerSession;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$this->_customerSession = $this->_objectManager->get(\Magento\Customer\Model\Session::class);
|
||||
$this->_block = $this->_objectManager->create(\Magento\Wishlist\Block\Share\Wishlist::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*/
|
||||
public function testGetWishlistCustomer()
|
||||
{
|
||||
$this->_customerSession->loginById(1);
|
||||
$expectedCustomer = $this->_customerSession->getCustomerDataObject();
|
||||
$actualCustomer = $this->_block->getWishlistCustomer();
|
||||
$this->assertInstanceOf(\Magento\Customer\Api\Data\CustomerInterface::class, $actualCustomer);
|
||||
$this->assertEquals((int)$expectedCustomer->getId(), (int)$actualCustomer->getId());
|
||||
$this->assertEquals((int)$expectedCustomer->getWebsiteId(), (int)$actualCustomer->getWebsiteId());
|
||||
$this->assertEquals((int)$expectedCustomer->getStoreId(), (int)$actualCustomer->getStoreId());
|
||||
$this->assertEquals((int)$expectedCustomer->getGroupId(), (int)$actualCustomer->getGroupId());
|
||||
$this->assertEquals($expectedCustomer->getCustomAttributes(), $actualCustomer->getCustomAttributes());
|
||||
$this->assertEquals($expectedCustomer->getFirstname(), $actualCustomer->getFirstname());
|
||||
$this->assertEquals($expectedCustomer->getLastname(), $actualCustomer->getLastname());
|
||||
$this->assertEquals($expectedCustomer->getEmail(), $actualCustomer->getEmail());
|
||||
$this->assertEquals($expectedCustomer->getEmail(), $actualCustomer->getEmail());
|
||||
$this->assertEquals((int)$expectedCustomer->getDefaultBilling(), (int)$actualCustomer->getDefaultBilling());
|
||||
$this->assertEquals((int)$expectedCustomer->getDefaultShipping(), (int)$actualCustomer->getDefaultShipping());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Controller\Index;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\Framework\App\Request\Http as HttpRequest;
|
||||
use Magento\Framework\App\ResponseInterface;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Framework\Message\MessageInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\TestCase\AbstractController;
|
||||
use Magento\TestFramework\Wishlist\Model\GetWishlistByCustomerId;
|
||||
use Laminas\Stdlib\Parameters;
|
||||
use Magento\Customer\Api\CustomerRepositoryInterface;
|
||||
use Magento\Customer\Api\Data\CustomerInterface;
|
||||
use Magento\TestFramework\Mail\Template\TransportBuilderMock;
|
||||
use Magento\Wishlist\Model\DataSerializer;
|
||||
use Magento\Framework\UrlInterface;
|
||||
|
||||
/**
|
||||
* Test for add product to wish list.
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
* @magentoAppArea frontend
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class AddTest extends AbstractController
|
||||
{
|
||||
/** @var Session */
|
||||
private $customerSession;
|
||||
|
||||
/** @var GetWishlistByCustomerId */
|
||||
private $getWishlistByCustomerId;
|
||||
|
||||
/** @var ProductRepositoryInterface */
|
||||
private $productRepository;
|
||||
|
||||
/** @var Escaper */
|
||||
private $escaper;
|
||||
|
||||
/** @var CustomerRepositoryInterface */
|
||||
private $customerRepository;
|
||||
|
||||
/**
|
||||
* @var TransportBuilderMock
|
||||
*/
|
||||
private $transportBuilder;
|
||||
|
||||
/**
|
||||
* @var UrlInterface
|
||||
*/
|
||||
private $urlBuilder;
|
||||
|
||||
/**
|
||||
* @var DataSerializer
|
||||
*/
|
||||
private $dataSerializer;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->customerSession = $this->_objectManager->get(Session::class);
|
||||
$this->getWishlistByCustomerId = $this->_objectManager->get(GetWishlistByCustomerId::class);
|
||||
$this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
|
||||
$this->productRepository->cleanCache();
|
||||
$this->escaper = $this->_objectManager->get(Escaper::class);
|
||||
$this->customerRepository = $this->_objectManager->get(CustomerRepositoryInterface::class);
|
||||
$this->transportBuilder = $this->_objectManager->get(TransportBuilderMock::class);
|
||||
$this->urlBuilder = $this->_objectManager->get(UrlInterface::class);
|
||||
$this->dataSerializer = $this->_objectManager->get(DataSerializer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(null);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/product_simple_xss.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddActionProductNameXss(): void
|
||||
{
|
||||
$this->prepareReferer();
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$product = $this->productRepository->get('product-with-xss');
|
||||
$escapedProductName = $this->escaper->escapeHtml($product->getName());
|
||||
$this->performAddToWishListRequest(['product' => $product->getId()]);
|
||||
$this->assertSuccess(1, 1, $escapedProductName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_configurable_product.php
|
||||
* @magentoDbIsolation disabled
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddConfigurableProductToWishList(): void
|
||||
{
|
||||
$this->prepareReferer();
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$product = $this->productRepository->get('Configurable product');
|
||||
$this->performAddToWishListRequest(['product' => $product->getId()]);
|
||||
$this->assertSuccess(1, 1, $product->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/multiple_products.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddDisabledProductToWishList(): void
|
||||
{
|
||||
$expectedMessage = $this->escaper->escapeHtml("We can't specify a product.");
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$product = $this->productRepository->get('simple3');
|
||||
$this->performAddToWishListRequest(['product' => $product->getId()]);
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($expectedMessage)]), MessageInterface::TYPE_ERROR);
|
||||
$this->assertRedirect($this->stringContains('wishlist/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testAddToWishListWithoutParams(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$this->performAddToWishListRequest([]);
|
||||
$this->assertSessionMessages($this->isEmpty(), MessageInterface::TYPE_ERROR);
|
||||
$this->assertSessionMessages($this->isEmpty(), MessageInterface::TYPE_SUCCESS);
|
||||
$this->assertRedirect($this->stringContains('wishlist/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testAddNotExistingProductToWishList(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$expectedMessage = $this->escaper->escapeHtml("We can't specify a product.");
|
||||
$this->performAddToWishListRequest(['product' => 989]);
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($expectedMessage)]), MessageInterface::TYPE_ERROR);
|
||||
$this->assertRedirect($this->stringContains('wishlist/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testAddToNotExistingWishList(): void
|
||||
{
|
||||
$expectedMessage = $this->escaper->escapeHtml("The requested Wish List doesn't exist.");
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$this->performAddToWishListRequest(['wishlist_id' => 989]);
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($expectedMessage)]), MessageInterface::TYPE_ERROR);
|
||||
$this->assert404NotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Product to Wishlist Before Login, Create Customer & Send Confirmation Email
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
|
||||
* @magentoConfigFixture current_website customer/create_account/confirm 1
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreateCustomerWithEmailConfirmationAfterAddToWishlist(): void
|
||||
{
|
||||
$product = $this->productRepository->get('simple');
|
||||
$data = [];
|
||||
$data['product'] = (int)$product->getId();
|
||||
$this->customerSession->setBeforeWishlistRequest($data);
|
||||
$this->customerSession->setBeforeAuthUrl($this->urlBuilder->getUrl('wishlist/index/add'));
|
||||
$email = 'test_example_new@email.com';
|
||||
$this->fillRequestWithCustomerData($email);
|
||||
$this->dispatch('customer/account/createPost');
|
||||
$this->assertRedirect($this->stringContains('customer/account/index'));
|
||||
$message = 'You must confirm your account.'
|
||||
. ' Please check your email for the confirmation link or <a href="%1">click here</a> for a new link.';
|
||||
$url = $this->urlBuilder->getUrl('customer/account/confirmation', ['_query' => ['email' => $email]]);
|
||||
$this->assertSessionMessages($this->containsEqual((string)__($message, $url)), MessageInterface::TYPE_SUCCESS);
|
||||
/** @var CustomerInterface $customer */
|
||||
$customer = $this->customerRepository->get($email);
|
||||
$confirmation = $customer->getConfirmation();
|
||||
$sendMessage = $this->transportBuilder->getSentMessage();
|
||||
$this->assertNotNull($sendMessage);
|
||||
$rawMessage = $sendMessage->getBody()->getParts()[0]->getRawContent();
|
||||
$this->assertStringContainsString(
|
||||
(string)__(
|
||||
'You must confirm your %customer_email email before you can sign in (link is only valid once):',
|
||||
['customer_email' => $email]
|
||||
),
|
||||
$rawMessage
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
sprintf('token'),
|
||||
$rawMessage
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
sprintf('id=%s&key=%s', $customer->getId(), $confirmation),
|
||||
$rawMessage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Wishlist Product Data into Cache.
|
||||
* Also Add Product To Wishlist based on the data retrieved from Cache Token
|
||||
*
|
||||
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
|
||||
* @magentoDataFixture Magento/Customer/_files/customer_confirmation_config_enable.php
|
||||
* @magentoDataFixture Magento/Customer/_files/unconfirmed_customer.php
|
||||
* @magentoDbIsolation disabled
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddToWishlistOnCustomerConfirmation(): void
|
||||
{
|
||||
$this->prepareReferer();
|
||||
$product = $this->productRepository->get('simple');
|
||||
$data = [];
|
||||
$data['product'] = (int)$product->getId();
|
||||
$token = $this->dataSerializer->serialize($data);//Save into Cache
|
||||
$customer = $this->customerRepository->get('unconfirmedcustomer@example.com');
|
||||
$customer->setConfirmation(null);
|
||||
$this->customerRepository->save($customer);
|
||||
$this->assertEquals(null, $customer->getConfirmation());
|
||||
$this->customerSession->setCustomerId((int)$customer->getId());
|
||||
$this->getRequest()->setParams(['token' => $token])->setMethod(HttpRequest::METHOD_GET);
|
||||
$this->dispatch('wishlist/index/add');
|
||||
$this->assertSuccess((int)$customer->getId(), 1, $product->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture current_store customer/captcha/enable 0
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
|
||||
*/
|
||||
public function testAddToWishlistBeforeLogin(): void
|
||||
{
|
||||
$this->prepareReferer();
|
||||
$product = $this->productRepository->get('simple');
|
||||
$this->performAddToWishListRequest(['product' => $product->getId()]);
|
||||
$this->assertSessionMessages(
|
||||
$this->equalTo([(string)__('You must login or register to add items to your wishlist.')]),
|
||||
MessageInterface::TYPE_ERROR
|
||||
);
|
||||
|
||||
// re-initialize the application to make a second request
|
||||
Bootstrap::getInstance()->getBootstrap()->getApplication()->reinitialize();
|
||||
$this->_objectManager = Bootstrap::getObjectManager();
|
||||
$this->customerSession = $this->_objectManager->get(Session::class);
|
||||
$this->_request = null;
|
||||
$this->_response = null;
|
||||
|
||||
// login
|
||||
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
|
||||
$this->getRequest()->setPostValue([
|
||||
'login' => [
|
||||
'username' => 'customer@example.com',
|
||||
'password' => 'password',
|
||||
],
|
||||
]);
|
||||
$this->dispatch('customer/account/loginPost');
|
||||
$this->assertTrue($this->customerSession->isLoggedIn());
|
||||
$this->assertSuccess(1, 1, $product->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform request add item to wish list.
|
||||
*
|
||||
* @param array $params
|
||||
* @return void
|
||||
*/
|
||||
private function performAddToWishListRequest(array $params): void
|
||||
{
|
||||
$this->getRequest()->setParams($params)->setMethod(HttpRequest::METHOD_POST);
|
||||
$this->dispatch('wishlist/index/add');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert success response and items count.
|
||||
*
|
||||
* @param int $customerId
|
||||
* @param int $itemsCount
|
||||
* @param string $productName
|
||||
* @return void
|
||||
*/
|
||||
private function assertSuccess(int $customerId, int $itemsCount, string $productName): void
|
||||
{
|
||||
$expectedMessage = sprintf("\n%s has been added to your Wish List.", $productName)
|
||||
. " Click <a href=\"http://localhost/test\">here</a> to continue shopping.";
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($expectedMessage)]), MessageInterface::TYPE_SUCCESS);
|
||||
$wishlist = $this->getWishlistByCustomerId->execute($customerId);
|
||||
$this->assertCount($itemsCount, $wishlist->getItemCollection());
|
||||
$this->assertRedirect($this->stringContains('wishlist/index/index/wishlist_id/' . $wishlist->getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare referer to test.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function prepareReferer(): void
|
||||
{
|
||||
$parameters = $this->_objectManager->create(Parameters::class);
|
||||
$parameters->set('HTTP_REFERER', 'http://localhost/test');
|
||||
$this->getRequest()->setServer($parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills request with customer data.
|
||||
*
|
||||
* @param string $email
|
||||
* @return void
|
||||
*/
|
||||
private function fillRequestWithCustomerData(string $email): void
|
||||
{
|
||||
$this->getRequest()
|
||||
->setMethod(HttpRequest::METHOD_POST)
|
||||
->setParam(CustomerInterface::FIRSTNAME, 'firstname1')
|
||||
->setParam(CustomerInterface::LASTNAME, 'lastname1')
|
||||
->setParam(CustomerInterface::EMAIL, $email)
|
||||
->setParam('password', '_Password1')
|
||||
->setParam('password_confirmation', '_Password1');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Controller\Index;
|
||||
|
||||
use Magento\Checkout\Model\CartFactory;
|
||||
use Magento\Checkout\Model\Cart as CartModel;
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\Framework\App\Request\Http as HttpRequest;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Framework\Message\MessageInterface;
|
||||
use Magento\TestFramework\TestCase\AbstractController;
|
||||
use Magento\TestFramework\Wishlist\Model\GetWishlistByCustomerId;
|
||||
|
||||
/**
|
||||
* Test for add all products to cart from wish list.
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class AllcartTest extends AbstractController
|
||||
{
|
||||
/** @var Session */
|
||||
private $customerSession;
|
||||
|
||||
/** @var CartModel */
|
||||
private $cart;
|
||||
|
||||
/** @var Escaper */
|
||||
private $escaper;
|
||||
|
||||
/** @var GetWishlistByCustomerId */
|
||||
private $getWishlistByCustomerId;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->customerSession = $this->_objectManager->get(Session::class);
|
||||
$this->cart = $this->_objectManager->get(CartFactory::class)->create();
|
||||
$this->escaper = $this->_objectManager->get(Escaper::class);
|
||||
$this->getWishlistByCustomerId = $this->_objectManager->get(GetWishlistByCustomerId::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(null);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_product_qty_increments.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddProductQtyIncrementToCartFromWishList(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$this->performAddAllToCartRequest();
|
||||
$wishlistCollection = $this->getWishlistByCustomerId->execute(1)->getItemCollection();
|
||||
$this->assertCount(1, $wishlistCollection);
|
||||
$this->assertCount(0, $this->cart->getQuote()->getItemsCollection());
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'simple');
|
||||
$this->assertNotNull($item);
|
||||
$expectedMessage = $this->escaper->escapeHtml(
|
||||
sprintf('You can buy this product only in quantities of 5 at a time for "%s".', $item->getName())
|
||||
);
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($expectedMessage)]), MessageInterface::TYPE_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_simple_product.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddAllProductToCartFromWishList(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$this->performAddAllToCartRequest();
|
||||
$quoteCollection = $this->cart->getQuote()->getItemsCollection();
|
||||
$this->assertCount(1, $quoteCollection);
|
||||
$item = $quoteCollection->getFirstItem();
|
||||
$expectedMessage = $this->escaper->escapeHtml(
|
||||
sprintf('1 product(s) have been added to shopping cart: "%s".', $item->getName())
|
||||
);
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($expectedMessage)]), MessageInterface::TYPE_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform add all products to cart from wish list request.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function performAddAllToCartRequest(): void
|
||||
{
|
||||
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
|
||||
$this->dispatch('wishlist/index/allcart');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Controller\Index;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
|
||||
use Magento\Checkout\Model\CartFactory;
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\Framework\App\Request\Http as HttpRequest;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Framework\Message\MessageInterface;
|
||||
use Magento\TestFramework\Fixture\DataFixture;
|
||||
use Magento\TestFramework\TestCase\AbstractController;
|
||||
use Magento\TestFramework\Wishlist\Model\GetWishlistByCustomerId;
|
||||
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
|
||||
|
||||
/**
|
||||
* Test for add product to cart from wish list.
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class CartTest extends AbstractController
|
||||
{
|
||||
/** @var Session */
|
||||
private $customerSession;
|
||||
|
||||
/** @var GetWishlistByCustomerId */
|
||||
private $getWishlistByCustomerId;
|
||||
|
||||
/** @var CartFactory */
|
||||
private $cartFactory;
|
||||
|
||||
/** @var Escaper */
|
||||
private $escaper;
|
||||
|
||||
/** @var ProductRepositoryInterface */
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @var \Magento\TestFramework\Fixture\DataFixtureStorage
|
||||
*/
|
||||
private $fixtures;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->customerSession = $this->_objectManager->get(Session::class);
|
||||
$this->getWishlistByCustomerId = $this->_objectManager->get(GetWishlistByCustomerId::class);
|
||||
$this->cartFactory = $this->_objectManager->get(CartFactory::class);
|
||||
$this->escaper = $this->_objectManager->get(Escaper::class);
|
||||
$this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
|
||||
$this->fixtures = $this->_objectManager->get(DataFixtureStorageManager::class)->getStorage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(null);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_simple_product.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddSimpleProductToCart(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'simple-1');
|
||||
$this->assertNotNull($item);
|
||||
$this->performAddToCartRequest(['item' => $item->getId(), 'qty' => 3]);
|
||||
$message = sprintf("\n" . 'You added %s to your ' .
|
||||
'<a href="http://localhost/index.php/checkout/cart/">shopping cart</a>.', $item->getName());
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($message)]), MessageInterface::TYPE_SUCCESS);
|
||||
$this->assertCount(0, $this->getWishlistByCustomerId->execute(1)->getItemCollection());
|
||||
$cart = $this->cartFactory->create();
|
||||
$this->assertEquals(1, $cart->getItemsCount());
|
||||
$this->assertEquals(3, $cart->getItemsQty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_configurable_product.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddItemWithNotChosenOptionToCart(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'Configurable product');
|
||||
$this->assertNotNull($item);
|
||||
$this->performAddToCartRequest(['item' => $item->getId(), 'qty' => 1]);
|
||||
$redirectUrl = sprintf("wishlist/index/configure/id/%s/product_id/%s", $item->getId(), $item->getProductId());
|
||||
$this->assertRedirect($this->stringContains($redirectUrl));
|
||||
$message = 'You need to choose options for your item.';
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($message)]), MessageInterface::TYPE_NOTICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddNotExistingItemToCart(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$this->performAddToCartRequest(['item' => 989]);
|
||||
$this->assertRedirect($this->stringContains('wishlist/index/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add wishlist item with related Products to Cart.
|
||||
*
|
||||
* @return void
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_simple_product.php
|
||||
*/
|
||||
#[
|
||||
DataFixture(ProductFixture::class, as: 'product1'),
|
||||
DataFixture(ProductFixture::class, as: 'product2'),
|
||||
]
|
||||
public function testAddItemWithRelatedProducts(): void
|
||||
{
|
||||
$firstProductId = $this->fixtures->get('product1')->getId();
|
||||
$secondProductID = $this->fixtures->get('product2')->getId();
|
||||
$relatedIds = $expectedAddedIds = [$firstProductId, $secondProductID];
|
||||
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'simple-1');
|
||||
$this->assertNotNull($item);
|
||||
|
||||
$this->performAddToCartRequest([
|
||||
'item' => $item->getId(),
|
||||
'qty' => 1,
|
||||
'related_product' => implode(',', $relatedIds),
|
||||
]);
|
||||
|
||||
$this->assertCount(0, $this->getWishlistByCustomerId->execute(1)->getItemCollection());
|
||||
$cart = $this->cartFactory->create();
|
||||
$this->assertEquals(3, $cart->getItemsCount());
|
||||
$expectedAddedIds[] = $item->getProductId();
|
||||
foreach ($expectedAddedIds as $addedId) {
|
||||
$this->assertContains($addedId, $cart->getProductIds());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform request add to cart from wish list.
|
||||
*
|
||||
* @param array $params
|
||||
* @return void
|
||||
*/
|
||||
private function performAddToCartRequest(array $params): void
|
||||
{
|
||||
$this->getRequest()->setParams($params)->setMethod(HttpRequest::METHOD_POST);
|
||||
$this->dispatch('wishlist/index/cart');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Controller\Index;
|
||||
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\TestFramework\Helper\Xpath;
|
||||
use Magento\TestFramework\TestCase\AbstractController;
|
||||
|
||||
/**
|
||||
* Test wish list on customer account page.
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class IndexTest extends AbstractController
|
||||
{
|
||||
/** @var Session */
|
||||
private $customerSession;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->customerSession = $this->_objectManager->get(Session::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(null);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify wishlist view action
|
||||
*
|
||||
* The following is verified:
|
||||
* - \Magento\Wishlist\Model\ResourceModel\Item\Collection
|
||||
* - \Magento\Wishlist\Block\Customer\Wishlist
|
||||
* - \Magento\Wishlist\Block\Customer\Wishlist\Items
|
||||
* - \Magento\Wishlist\Block\Customer\Wishlist\Item\Column
|
||||
* - \Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Cart
|
||||
* - \Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Comment
|
||||
* - \Magento\Wishlist\Block\Customer\Wishlist\Button
|
||||
* - that \Magento\Wishlist\Block\Customer\Wishlist\Item\Options doesn't throw a fatal error
|
||||
*
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testItemColumnBlock(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$this->dispatch('wishlist/index/index');
|
||||
$body = $this->getResponse()->getBody();
|
||||
$this->assertEquals(
|
||||
1,
|
||||
Xpath::getElementsCountForXpath(
|
||||
'//img[contains(@src, "small_image.jpg") and @alt = "Simple Product"]',
|
||||
$body
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
Xpath::getElementsCountForXpath(
|
||||
'//textarea[contains(@name, "description")]',
|
||||
$body
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Controller\Index;
|
||||
|
||||
use Magento\Framework\App\Request\Http as HttpRequest;
|
||||
use Magento\Framework\Message\MessageInterface;
|
||||
use Magento\TestFramework\TestCase\AbstractController;
|
||||
use Magento\Customer\Model\Session as CustomerSession;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Test for wishlist plugin before dispatch
|
||||
*
|
||||
* @magentoDbIsolation enabled
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class PluginTest extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @var CustomerSession
|
||||
*/
|
||||
private $customerSession;
|
||||
|
||||
/**
|
||||
* @var ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->customerSession = $this->_objectManager->get(CustomerSession::class);
|
||||
$this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->customerSession->logout();
|
||||
$this->customerSession = null;
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for adding product to wishlist with invalidate credentials
|
||||
*
|
||||
* @magentoDataFixture Magento/Catalog/_files/product_simple_xss.php
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddActionProductWithInvalidCredentials(): void
|
||||
{
|
||||
$product = $this->productRepository->get('product-with-xss');
|
||||
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
|
||||
$this->getRequest()->setPostValue(
|
||||
[
|
||||
'login' => [
|
||||
'username' => 'invalidCustomer@example.com',
|
||||
'password' => 'invalidPassword',
|
||||
],
|
||||
]
|
||||
);
|
||||
$this->getRequest()->setParams(['product' => $product->getId(), 'nocookie' => 1]);
|
||||
$this->dispatch('wishlist/index/add');
|
||||
$this->assertArrayNotHasKey('login', $this->customerSession->getBeforeWishlistRequest());
|
||||
$expectedMessage = 'You must login or register to add items to your wishlist.';
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($expectedMessage)]), MessageInterface::TYPE_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture current_store wishlist/general/active 0
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testWithDisabledWishList(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$this->dispatch('wishlist/index/index');
|
||||
$this->assert404NotFound();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Controller\Index;
|
||||
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\Framework\App\Request\Http as HttpRequest;
|
||||
use Magento\Framework\Message\MessageInterface;
|
||||
use Magento\TestFramework\TestCase\AbstractController;
|
||||
use Magento\TestFramework\Wishlist\Model\GetWishlistByCustomerId;
|
||||
|
||||
/**
|
||||
* Test for remove product from wish list.
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
* @magentoAppArea frontend
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*/
|
||||
class RemoveTest extends AbstractController
|
||||
{
|
||||
/** @var Session */
|
||||
private $customerSession;
|
||||
|
||||
/** @var GetWishlistByCustomerId */
|
||||
private $getWishlistByCustomerId;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->customerSession = $this->_objectManager->get(Session::class);
|
||||
$this->getWishlistByCustomerId = $this->_objectManager->get(GetWishlistByCustomerId::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(null);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testRemoveProductFromWishList(): void
|
||||
{
|
||||
$customerId = 1;
|
||||
$this->customerSession->setCustomerId($customerId);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku($customerId, 'simple');
|
||||
$this->assertNotNull($item);
|
||||
$productName = $item->getProduct()->getName();
|
||||
$this->getRequest()->setParam('item', $item->getId())->setMethod(HttpRequest::METHOD_POST);
|
||||
$this->dispatch('wishlist/index/remove');
|
||||
$message = sprintf("\n%s has been removed from your Wish List.\n", $productName);
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($message)]), MessageInterface::TYPE_SUCCESS);
|
||||
$this->assertCount(0, $this->getWishlistByCustomerId->execute($customerId)->getItemCollection());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testRemoveNotExistingItemFromWishList(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$this->getRequest()->setParams(['item' => 989])->setMethod(HttpRequest::METHOD_POST);
|
||||
$this->dispatch('wishlist/index/remove');
|
||||
$this->assert404NotFound();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Controller\Index;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Customer\Api\CustomerNameGenerationInterface;
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\Framework\App\Request\Http as HttpRequest;
|
||||
use Magento\Framework\Message\MessageInterface;
|
||||
use Magento\TestFramework\Helper\Xpath;
|
||||
use Magento\TestFramework\Mail\Template\TransportBuilderMock;
|
||||
use Magento\TestFramework\TestCase\AbstractController;
|
||||
|
||||
/**
|
||||
* Test sending wish list.
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
* @magentoAppArea frontend
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*/
|
||||
class SendTest extends AbstractController
|
||||
{
|
||||
/** @var Session */
|
||||
private $customerSession;
|
||||
|
||||
/** @var CustomerNameGenerationInterface */
|
||||
private $customerNameGeneration;
|
||||
|
||||
/** @var ProductRepositoryInterface */
|
||||
private $productRepository;
|
||||
|
||||
/** @var TransportBuilderMock */
|
||||
private $transportBuilder;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->customerSession = $this->_objectManager->get(Session::class);
|
||||
$this->customerNameGeneration = $this->_objectManager->get(CustomerNameGenerationInterface::class);
|
||||
$this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
|
||||
$this->productRepository->cleanCache();
|
||||
$this->transportBuilder = $this->_objectManager->get(TransportBuilderMock::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(null);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testSendWishList(): void
|
||||
{
|
||||
$product = $this->productRepository->get('simple');
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$shareMessage = 'Here\'s what I want for my birthday.';
|
||||
$postValues = ['emails' => 'test@example.com', 'message' => $shareMessage];
|
||||
$this->dispatchSendWishListRequest($postValues);
|
||||
$this->assertSessionMessages(
|
||||
$this->equalTo([(string)__('Your wish list has been shared.')]),
|
||||
MessageInterface::TYPE_SUCCESS
|
||||
);
|
||||
$this->assertNotNull($this->transportBuilder->getSentMessage());
|
||||
$messageContent = $this->transportBuilder->getSentMessage()->getBody()->getParts()[0]->getRawContent();
|
||||
$this->assertStringContainsString($shareMessage, $messageContent);
|
||||
$this->assertStringContainsString(
|
||||
sprintf(
|
||||
'%s wants to share this Wish List',
|
||||
$this->customerNameGeneration->getCustomerName($this->customerSession->getCustomerDataObject())
|
||||
),
|
||||
$messageContent
|
||||
);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
Xpath::getElementsCountForXpath(
|
||||
sprintf(
|
||||
"//a[contains(@href, '%s')]/strong[contains(text(), '%s')]",
|
||||
$product->getProductUrl(),
|
||||
$product->getName()
|
||||
),
|
||||
$messageContent
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
Xpath::getElementsCountForXpath(
|
||||
"//a[contains(@href, 'wishlist/shared/index/code/fixture_unique_code/')"
|
||||
. " and contains(text(), 'View all Wish List')]",
|
||||
$messageContent
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture current_store wishlist/email/number_limit 2
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSendWishListWithEmailsLimit(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$postValues = ['emails' => 'test@example.com, test2@example.com, test3@example.com'];
|
||||
$this->dispatchSendWishListRequest($postValues);
|
||||
$this->assertResponseWithError('Maximum of 2 emails can be sent.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture current_store wishlist/email/text_limit 10
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSendWishListWithTextLimit(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$postValues = ['emails' => 'test@example.com', 'message' => 'Test message'];
|
||||
$this->dispatchSendWishListRequest($postValues);
|
||||
$this->assertResponseWithError('Message length must not exceed 10 symbols');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testSendWishListWithoutEmails(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$postValues = ['emails' => ''];
|
||||
$this->dispatchSendWishListRequest($postValues);
|
||||
$this->assertResponseWithError('Please enter an email address.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testSendWishListWithInvalidEmail(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$postValues = ['emails' => 'test @example.com'];
|
||||
$this->dispatchSendWishListRequest($postValues);
|
||||
$this->assertResponseWithError('Please enter a valid email address.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch send wish list request.
|
||||
*
|
||||
* @param array $postValues
|
||||
* @return void
|
||||
*/
|
||||
private function dispatchSendWishListRequest(array $postValues): void
|
||||
{
|
||||
$this->getRequest()->setPostValue($postValues)->setMethod(HttpRequest::METHOD_POST);
|
||||
$this->dispatch('wishlist/index/send');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert error message and redirect.
|
||||
*
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
private function assertResponseWithError(string $message): void
|
||||
{
|
||||
$this->assertSessionMessages($this->equalTo([__($message)]), MessageInterface::TYPE_ERROR);
|
||||
$this->assertRedirect($this->stringContains('wishlist/index/share'));
|
||||
}
|
||||
}
|
||||
+241
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Controller\Index;
|
||||
|
||||
use Magento\Catalog\Api\Data\ProductInterface;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\Framework\App\Request\Http as HttpRequest;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Framework\Message\MessageInterface;
|
||||
use Magento\Framework\Serialize\SerializerInterface;
|
||||
use Magento\TestFramework\TestCase\AbstractController;
|
||||
use Magento\TestFramework\Wishlist\Model\GetWishlistByCustomerId;
|
||||
use Magento\Wishlist\Model\Item;
|
||||
|
||||
/**
|
||||
* Test for update wish list item.
|
||||
*
|
||||
* @magentoDbIsolation enabled
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class UpdateItemOptionsTest extends AbstractController
|
||||
{
|
||||
/** @var Session */
|
||||
private $customerSession;
|
||||
|
||||
/** @var ProductRepositoryInterface */
|
||||
private $productRepository;
|
||||
|
||||
/** @var Escaper */
|
||||
private $escaper;
|
||||
|
||||
/** @var SerializerInterface */
|
||||
private $json;
|
||||
|
||||
/** @var GetWishlistByCustomerId */
|
||||
private $getWishlistByCustomerId;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->customerSession = $this->_objectManager->get(Session::class);
|
||||
$this->getWishlistByCustomerId = $this->_objectManager->get(GetWishlistByCustomerId::class);
|
||||
$this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
|
||||
$this->productRepository->cleanCache();
|
||||
$this->escaper = $this->_objectManager->get(Escaper::class);
|
||||
$this->json = $this->_objectManager->get(SerializerInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(null);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_configurable_product.php
|
||||
* @magentoDbIsolation disabled
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateItemOptions(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'Configurable product');
|
||||
$this->assertNotNull($item);
|
||||
$params = [
|
||||
'id' => $item->getId(),
|
||||
'product' => $item->getProductId(),
|
||||
'super_attribute' => $this->performConfigurableOption($item->getProduct()),
|
||||
'qty' => 5,
|
||||
];
|
||||
$this->performUpdateWishListItemRequest($params);
|
||||
$message = sprintf("%s has been updated in your Wish List.", $item->getProduct()->getName());
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($message)]), MessageInterface::TYPE_SUCCESS);
|
||||
$this->assertRedirect($this->stringContains('wishlist/index/index/wishlist_id/' . $item->getWishlistId()));
|
||||
$this->assertUpdatedItem(
|
||||
$this->getWishlistByCustomerId->getItemBySku(1, 'Configurable product'),
|
||||
$params
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateItemOptionsWithoutParams(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$this->performUpdateWishListItemRequest([]);
|
||||
$this->assertSessionMessages($this->isEmpty(), MessageInterface::TYPE_ERROR);
|
||||
$this->assertSessionMessages($this->isEmpty(), MessageInterface::TYPE_SUCCESS);
|
||||
$this->assertRedirect($this->stringContains('wishlist/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateNotExistingItem(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$this->performUpdateWishListItemRequest(['product' => 989]);
|
||||
$message = $this->escaper->escapeHtml("We can't specify a product.");
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($message)]), MessageInterface::TYPE_ERROR);
|
||||
$this->assertRedirect($this->stringContains('wishlist/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/multiple_products.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateOutOfStockItem(): void
|
||||
{
|
||||
$product = $this->productRepository->get('simple3');
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$this->performUpdateWishListItemRequest(['product' => $product->getId()]);
|
||||
$message = $this->escaper->escapeHtml("We can't specify a product.");
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($message)]), MessageInterface::TYPE_ERROR);
|
||||
$this->assertRedirect($this->stringContains('wishlist/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/product_out_of_stock_with_multiselect_attribute.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateItemNotSpecifyAsWishListItem(): void
|
||||
{
|
||||
$product = $this->productRepository->get('simple_ms_out_of_stock');
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$this->performUpdateWishListItemRequest(['product' => $product->getId()]);
|
||||
$message = $this->escaper->escapeHtml("We can't specify a wish list item.");
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($message)]), MessageInterface::TYPE_ERROR);
|
||||
$this->assertRedirect($this->stringContains('wishlist/index/index/wishlist_id/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_grouped_product.php
|
||||
* @magentoDbIsolation disabled
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateItemOptionsForGroupedProduct(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'grouped');
|
||||
$this->assertNotNull($item);
|
||||
$params = [
|
||||
'id' => $item->getId(),
|
||||
'product' => $item->getProductId(),
|
||||
'super_group' => $this->performGroupedOption(),
|
||||
'qty' => 1,
|
||||
];
|
||||
$this->performUpdateWishListItemRequest($params);
|
||||
$message = sprintf("%s has been updated in your Wish List.", $item->getProduct()->getName());
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($message)]), MessageInterface::TYPE_SUCCESS);
|
||||
$this->assertRedirect($this->stringContains('wishlist/index/index/wishlist_id/' . $item->getWishlistId()));
|
||||
$this->assertUpdatedItem(
|
||||
$this->getWishlistByCustomerId->getItemBySku(1, 'grouped'),
|
||||
$params
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform request update wish list item.
|
||||
*
|
||||
* @param array $params
|
||||
* @return void
|
||||
*/
|
||||
private function performUpdateWishListItemRequest(array $params): void
|
||||
{
|
||||
$this->getRequest()->setParams($params)->setMethod(HttpRequest::METHOD_POST);
|
||||
$this->dispatch('wishlist/index/updateItemOptions');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert updated item in wish list.
|
||||
*
|
||||
* @param Item $item
|
||||
* @param array $expectedData
|
||||
* @return void
|
||||
*/
|
||||
private function assertUpdatedItem(Item $item, array $expectedData): void
|
||||
{
|
||||
$this->assertEquals($expectedData['qty'], $item->getQty());
|
||||
$buyRequestOption = $this->json->unserialize($item->getOptionByCode('info_buyRequest')->getValue());
|
||||
foreach ($expectedData as $key => $value) {
|
||||
$this->assertEquals($value, $buyRequestOption[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform configurable option to select.
|
||||
*
|
||||
* @param ProductInterface $product
|
||||
* @return array
|
||||
*/
|
||||
private function performConfigurableOption(ProductInterface $product): array
|
||||
{
|
||||
$configurableOptions = $product->getTypeInstance()->getConfigurableOptions($product);
|
||||
$attributeId = key($configurableOptions);
|
||||
$option = reset($configurableOptions[$attributeId]);
|
||||
|
||||
return [$attributeId => $option['value_index']];
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform group option to select.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function performGroupedOption(): array
|
||||
{
|
||||
$simple1 = $this->productRepository->get('simple_11');
|
||||
$simple2 = $this->productRepository->get('simple_22');
|
||||
|
||||
return [
|
||||
$simple1->getId() => '3',
|
||||
$simple2->getId() => '3',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Controller\Index;
|
||||
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\Framework\App\Request\Http as HttpRequest;
|
||||
use Magento\Framework\Message\MessageInterface;
|
||||
use Magento\TestFramework\TestCase\AbstractController;
|
||||
use Magento\TestFramework\Wishlist\Model\GetWishlistByCustomerId;
|
||||
|
||||
/**
|
||||
* Test for update wish list item.
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
* @magentoAppArea frontend
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*/
|
||||
class UpdateTest extends AbstractController
|
||||
{
|
||||
/** @var Session */
|
||||
private $customerSession;
|
||||
|
||||
/** @var GetWishlistByCustomerId */
|
||||
private $getWishlistByCustomerId;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->customerSession = $this->_objectManager->get(Session::class);
|
||||
$this->getWishlistByCustomerId = $this->_objectManager->get(GetWishlistByCustomerId::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(null);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateWishListItem(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'simple');
|
||||
$this->assertNotNull($item);
|
||||
$params = ['description' => [$item->getId() => 'Some description.'], 'qty' => [$item->getId() => 5]];
|
||||
$this->performUpdateWishListItemRequest($params);
|
||||
$message = sprintf("%s has been updated in your Wish List.", $item->getProduct()->getName());
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($message)]), MessageInterface::TYPE_SUCCESS);
|
||||
$this->assertRedirect($this->stringContains('wishlist/index/index/wishlist_id/' . $item->getWishlistId()));
|
||||
$updatedItem = $this->getWishlistByCustomerId->getItemBySku(1, 'simple');
|
||||
$this->assertNotNull($updatedItem);
|
||||
$this->assertEquals(5, $updatedItem->getQty());
|
||||
$this->assertEquals('Some description.', $updatedItem->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateWishListItemZeroQty(): void
|
||||
{
|
||||
$this->customerSession->setCustomerId(1);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'simple');
|
||||
$this->assertNotNull($item);
|
||||
$params = ['description' => [$item->getId() => ''], 'qty' => [$item->getId() => 0]];
|
||||
$this->performUpdateWishListItemRequest($params);
|
||||
$message = sprintf("%s has been updated in your Wish List.", $item->getProduct()->getName());
|
||||
$this->assertSessionMessages($this->equalTo([(string)__($message)]), MessageInterface::TYPE_SUCCESS);
|
||||
$this->assertRedirect($this->stringContains('wishlist/index/index/wishlist_id/' . $item->getWishlistId()));
|
||||
$this->assertCount(0, $this->getWishlistByCustomerId->execute(1)->getItemCollection());
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform update wish list item request.
|
||||
*
|
||||
* @param array $params
|
||||
* @return void
|
||||
*/
|
||||
private function performUpdateWishListItemRequest(array $params): void
|
||||
{
|
||||
$this->getRequest()->setPostValue($params)->setMethod(HttpRequest::METHOD_POST);
|
||||
$this->dispatch('wishlist/index/update');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Controller;
|
||||
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\Framework\App\Area;
|
||||
use Magento\Framework\Data\Form\FormKey;
|
||||
use Magento\Framework\Message\MessageInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Request;
|
||||
use Magento\TestFramework\TestCase\AbstractController;
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
class ShareTest extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Test share wishlist with correct data
|
||||
*
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*/
|
||||
public function testSuccessfullyShareWishlist()
|
||||
{
|
||||
$this->login(1);
|
||||
$this->prepareRequestData();
|
||||
$this->dispatch('wishlist/index/send/');
|
||||
|
||||
$this->assertSessionMessages(
|
||||
$this->equalTo(['Your wish list has been shared.']),
|
||||
MessageInterface::TYPE_SUCCESS
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test share wishlist with incorrect data
|
||||
*
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*/
|
||||
public function testShareWishlistWithoutEmails()
|
||||
{
|
||||
$this->login(1);
|
||||
$this->prepareRequestData(true);
|
||||
$this->dispatch('wishlist/index/send/');
|
||||
|
||||
$this->assertSessionMessages(
|
||||
$this->equalTo(['Please enter an email address.']),
|
||||
MessageInterface::TYPE_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Login the user
|
||||
*
|
||||
* @param string $customerId Customer to mark as logged in for the session
|
||||
* @return void
|
||||
*/
|
||||
protected function login($customerId)
|
||||
{
|
||||
/** @var Session $session */
|
||||
$session = $this->_objectManager->get(Session::class);
|
||||
$session->loginById($customerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the request with data
|
||||
*
|
||||
* @param bool $invalidData
|
||||
* @return void
|
||||
*/
|
||||
private function prepareRequestData($invalidData = false)
|
||||
{
|
||||
Bootstrap::getInstance()->loadArea(Area::AREA_FRONTEND);
|
||||
$emails = !$invalidData ? 'email-1@example.com,email-2@example.com' : '';
|
||||
|
||||
/** @var FormKey $formKey */
|
||||
$formKey = $this->_objectManager->get(FormKey::class);
|
||||
$post = [
|
||||
'emails' => $emails,
|
||||
'message' => '',
|
||||
'form_key' => $formKey->getFormKey(),
|
||||
];
|
||||
|
||||
$this->getRequest()->setMethod(Request::METHOD_POST);
|
||||
$this->getRequest()->setPostValue($post);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\Wishlist\Controller;
|
||||
|
||||
use Magento\Framework\App\Request\Http as HttpRequest;
|
||||
|
||||
class SharedTest extends \Magento\TestFramework\TestCase\AbstractController
|
||||
{
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_shared.php
|
||||
* @magentoDbIsolation disabled
|
||||
* @return void
|
||||
*/
|
||||
public function testAllcartAction()
|
||||
{
|
||||
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
|
||||
$this->getRequest()->setParam('code', 'fixture_unique_code');
|
||||
$this->dispatch('wishlist/shared/allcart');
|
||||
|
||||
/** @var \Magento\Checkout\Model\Cart $cart */
|
||||
$cart = $this->_objectManager->get(\Magento\Checkout\Model\Cart::class);
|
||||
$quoteCount = $cart->getQuote()->getItemsCollection()->count();
|
||||
|
||||
$this->assertEquals(1, $quoteCount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Wishlist\Helper;
|
||||
|
||||
class DataTest extends \Magento\TestFramework\TestCase\AbstractController
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
private $_wishlistHelper;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\ObjectManagerInterface
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var \Magento\Customer\Model\Session
|
||||
*/
|
||||
protected $_customerSession;
|
||||
|
||||
/**
|
||||
* Get required instance
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$this->_wishlistHelper = $this->objectManager->get(\Magento\Wishlist\Helper\Data::class);
|
||||
$this->_customerSession = $this->objectManager->get(\Magento\Customer\Model\Session::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear wishlist helper property
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->_wishlistHelper = null;
|
||||
if ($this->_customerSession->isLoggedIn()) {
|
||||
$this->_customerSession->logout();
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetAddParams()
|
||||
{
|
||||
$product = $this->objectManager->get(\Magento\Catalog\Model\Product::class);
|
||||
$product->setId(11);
|
||||
$json = $this->_wishlistHelper->getAddParams($product);
|
||||
$params = (array)json_decode($json);
|
||||
$data = (array)$params['data'];
|
||||
$this->assertEquals('11', $data['product']);
|
||||
$this->assertArrayHasKey('uenc', $data);
|
||||
$this->assertStringEndsWith('wishlist/index/add/', $params['action']);
|
||||
}
|
||||
|
||||
public function testGetMoveFromCartParams()
|
||||
{
|
||||
$json = $this->_wishlistHelper->getMoveFromCartParams(11);
|
||||
$params = (array)json_decode($json);
|
||||
$data = (array)$params['data'];
|
||||
$this->assertEquals('11', $data['item']);
|
||||
$this->assertArrayHasKey('uenc', $data);
|
||||
$this->assertStringEndsWith('wishlist/index/fromcart/', $params['action']);
|
||||
}
|
||||
|
||||
public function testGetUpdateParams()
|
||||
{
|
||||
$product = $this->objectManager->get(\Magento\Catalog\Model\Product::class);
|
||||
$product->setId(11);
|
||||
$product->setWishlistItemId(15);
|
||||
$json = $this->_wishlistHelper->getUpdateParams($product);
|
||||
$params = (array)json_decode($json);
|
||||
$data = (array)$params['data'];
|
||||
$this->assertEquals('11', $data['product']);
|
||||
$this->assertEquals('15', $data['id']);
|
||||
$this->assertArrayHasKey('uenc', $data);
|
||||
$this->assertStringEndsWith('wishlist/index/updateItemOptions/', $params['action']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
*/
|
||||
public function testWishlistCustomer()
|
||||
{
|
||||
/** @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */
|
||||
$customerRepository = $this->objectManager->create(
|
||||
\Magento\Customer\Api\CustomerRepositoryInterface::class
|
||||
);
|
||||
$customer = $customerRepository->getById(1);
|
||||
|
||||
$this->_wishlistHelper->setCustomer($customer);
|
||||
$this->assertSame($customer, $this->_wishlistHelper->getCustomer());
|
||||
|
||||
$this->_wishlistHelper = null;
|
||||
/** @var \Magento\Wishlist\Helper\Data wishlistHelper */
|
||||
$this->_wishlistHelper = $this->objectManager->get(\Magento\Wishlist\Helper\Data::class);
|
||||
|
||||
$this->_customerSession->loginById(1);
|
||||
$this->assertEquals($customer, $this->_wishlistHelper->getCustomer());
|
||||
|
||||
/** @var \Magento\Customer\Helper\View $customerViewHelper */
|
||||
$customerViewHelper = $this->objectManager->create(\Magento\Customer\Helper\View::class);
|
||||
$this->assertEquals($customerViewHelper->getCustomerName($customer), $this->_wishlistHelper->getCustomerName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Model;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\Product\Exception as ProductException;
|
||||
use Magento\Checkout\Model\CartFactory;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\DataObjectFactory;
|
||||
use Magento\TestFramework\Wishlist\Model\GetWishlistByCustomerId;
|
||||
use Magento\Wishlist\Model\Item\OptionFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Tests for wish list item model.
|
||||
*
|
||||
* @magentoDbIsolation enabled
|
||||
* @magentoAppIsolation disabled
|
||||
*/
|
||||
class ItemTest extends TestCase
|
||||
{
|
||||
/** @var ObjectManager */
|
||||
private $objectManager;
|
||||
|
||||
/** @var Item */
|
||||
private $model;
|
||||
|
||||
/** @var DataObjectFactory */
|
||||
private $dataObjectFactory;
|
||||
|
||||
/** @var OptionFactory */
|
||||
private $optionFactory;
|
||||
|
||||
/** @var GetWishlistByCustomerId */
|
||||
private $getWishlistByCustomerId;
|
||||
|
||||
/** @var CartFactory */
|
||||
private $cartFactory;
|
||||
|
||||
/** @var ProductRepositoryInterface */
|
||||
private $productRepository;
|
||||
|
||||
/** @var ItemFactory */
|
||||
private $itemFactory;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->objectManager = ObjectManager::getInstance();
|
||||
$this->dataObjectFactory = $this->objectManager->get(DataObjectFactory::class);
|
||||
$this->model = $this->objectManager->get(Item::class);
|
||||
$this->itemFactory = $this->objectManager->get(ItemFactory::class);
|
||||
$this->optionFactory = $this->objectManager->get(OptionFactory::class);
|
||||
$this->getWishlistByCustomerId = $this->objectManager->get(GetWishlistByCustomerId::class);
|
||||
$this->cartFactory = $this->objectManager->get(CartFactory::class);
|
||||
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
|
||||
$this->productRepository->cleanCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->cartFactory->create()->truncate();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBuyRequest(): void
|
||||
{
|
||||
$product = $this->productRepository->get('simple');
|
||||
$option = $this->optionFactory->create(
|
||||
['data' => ['code' => 'info_buyRequest', 'value' => '{"qty":23}']]
|
||||
);
|
||||
$option->setProduct($product);
|
||||
$this->model->addOption($option);
|
||||
$buyRequest = $this->model->getBuyRequest();
|
||||
$this->assertEquals($buyRequest->getOriginalQty(), 23);
|
||||
$this->model->mergeBuyRequest(['qty' => 11, 'additional_data' => 'some value']);
|
||||
$buyRequest = $this->model->getBuyRequest();
|
||||
$this->assertEquals(
|
||||
['additional_data' => 'some value', 'qty' => 0, 'original_qty' => 11],
|
||||
$buyRequest->getData()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testSetBuyRequest(): void
|
||||
{
|
||||
$buyRequest = $this->dataObjectFactory->create(
|
||||
['data' => ['field_1' => 'some data', 'field_2' => 234]]
|
||||
);
|
||||
$this->model->setBuyRequest($buyRequest);
|
||||
$this->assertJsonStringEqualsJsonString(
|
||||
'{"field_1":"some data","field_2":234,"id":null}',
|
||||
$this->model->getData('buy_request')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_simple_product.php
|
||||
* @magentoDbIsolation disabled
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddItemToCart(): void
|
||||
{
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'simple-1');
|
||||
$this->assertNotNull($item);
|
||||
$cart = $this->cartFactory->create();
|
||||
$this->assertTrue($item->addToCart($cart));
|
||||
$this->assertCount(1, $cart->getQuote()->getItemsCollection());
|
||||
$this->assertCount(1, $this->getWishlistByCustomerId->execute(1)->getItemCollection());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_simple_product.php
|
||||
* @magentoDbIsolation disabled
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddItemToCartAndDeleteFromWishList(): void
|
||||
{
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'simple-1');
|
||||
$this->assertNotNull($item);
|
||||
$cart = $this->cartFactory->create();
|
||||
$item->addToCart($cart, true);
|
||||
$this->assertCount(1, $cart->getQuote()->getItemsCollection());
|
||||
$this->assertCount(0, $this->getWishlistByCustomerId->execute(1)->getItemCollection());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Catalog/_files/product_simple_out_of_stock.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddOutOfStockItemToCart(): void
|
||||
{
|
||||
$product = $this->productRepository->get('simple-out-of-stock');
|
||||
$item = $this->itemFactory->create()->setProduct($product);
|
||||
$this->expectExceptionObject(new ProductException(__('Product is not salable.')));
|
||||
$item->addToCart($this->cartFactory->create());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Catalog/_files/multiple_products.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddDisabledItemToCart(): void
|
||||
{
|
||||
$product = $this->productRepository->get('simple3');
|
||||
$item = $this->itemFactory->create()->setProduct($product);
|
||||
$this->assertFalse($item->addToCart($this->cartFactory->create()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Catalog/_files/simple_products_not_visible_individually.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddNotVisibleItemToCart(): void
|
||||
{
|
||||
$product = $this->productRepository->get('simple_not_visible_1');
|
||||
$item = $this->itemFactory->create()->setProduct($product)->setStoreId($product->getStoreId());
|
||||
$this->assertFalse($item->addToCart($this->cartFactory->create()));
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Model\ResourceModel\Item\Collection;
|
||||
|
||||
use Magento\Customer\Controller\RegistryConstants;
|
||||
use Magento\Customer\Model\Customer;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Store\Model\Website;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Class to test wishlist collection by customer functionality
|
||||
*
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class GridTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var Registry
|
||||
*/
|
||||
private $registryManager;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = ObjectManager::getInstance();
|
||||
$this->registryManager = $this->objectManager->get(Registry::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to load wishlist collection by customer on second website
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_on_second_website.php
|
||||
*/
|
||||
public function testLoadOnSecondWebsite()
|
||||
{
|
||||
$customer = $this->loadCustomer();
|
||||
$this->registryManager->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customer->getId());
|
||||
|
||||
$gridCollection = $this->objectManager->get(Grid::class);
|
||||
$this->assertNotEmpty($gridCollection->getItems());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load customer in second website
|
||||
*
|
||||
* @return Customer
|
||||
*/
|
||||
private function loadCustomer(): Customer
|
||||
{
|
||||
/** @var $website Website */
|
||||
$website = $this->objectManager->get(Website::class);
|
||||
$website->load('newwebsite', 'code');
|
||||
|
||||
/** @var Customer $customer */
|
||||
$customer = $this->objectManager->get(Customer::class);
|
||||
$customer->setWebsiteId($website->getId());
|
||||
$customer->loadByEmail('customer2@example.com');
|
||||
|
||||
return $customer;
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\Wishlist\Model\ResourceModel\Item;
|
||||
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Wishlist\Model\Wishlist;
|
||||
use Magento\Catalog\Model\Attribute\Config;
|
||||
|
||||
class CollectionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
private $itemCollection;
|
||||
|
||||
/**
|
||||
* @var Wishlist
|
||||
*/
|
||||
private $wishlist;
|
||||
|
||||
/**
|
||||
* @var Config\Data
|
||||
*/
|
||||
private $attributeConfig;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = ObjectManager::getInstance();
|
||||
$this->wishlist = $this->objectManager->create(Wishlist::class);
|
||||
$this->itemCollection = $this->objectManager->get(Collection::class);
|
||||
$this->attributeConfig = $this->objectManager->get(Config\Data::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that Wishlist Item Collection uses Catalog Attributes defined in the configuration.
|
||||
*
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_shared.php
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation disabled
|
||||
*/
|
||||
public function testLoadedProductAttributes()
|
||||
{
|
||||
$this->addAttributesToWishlistConfig([
|
||||
'short_description',
|
||||
]);
|
||||
$this->wishlist->loadByCode('fixture_unique_code');
|
||||
$this->itemCollection->addWishlistFilter($this->wishlist);
|
||||
|
||||
/** @var Product $productOnWishlist */
|
||||
$productOnWishlist = $this->itemCollection->getFirstItem()->getProduct();
|
||||
$this->assertEquals('Simple Product', $productOnWishlist->getName());
|
||||
$this->assertEquals('Short description', $productOnWishlist->getData('short_description'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests collection load.
|
||||
* Tests collection load method when product salable filter flag is setted to true
|
||||
* and few products are present.
|
||||
*
|
||||
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
* @magentoDbIsolation disabled
|
||||
*/
|
||||
public function testLoadWhenFewProductsPresent()
|
||||
{
|
||||
$this->itemCollection->setSalableFilter(true);
|
||||
$this->itemCollection->addCustomerIdFilter(1);
|
||||
$this->itemCollection->load();
|
||||
$this->assertCount(1, $this->itemCollection->getItems());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $attributes
|
||||
*/
|
||||
private function addAttributesToWishlistConfig($attributes)
|
||||
{
|
||||
$this->attributeConfig->merge([
|
||||
'wishlist_item' => $attributes
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Model;
|
||||
|
||||
use Magento\Bundle\Model\Product\OptionList;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
|
||||
use Magento\CatalogInventory\Model\StockStateException;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\DataObjectFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Serialize\SerializerInterface;
|
||||
use Magento\TestFramework\Wishlist\Model\GetWishlistByCustomerId;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Tests for wish list model.
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
* @magentoAppIsolation disabled
|
||||
*/
|
||||
class WishlistTest extends TestCase
|
||||
{
|
||||
/** @var ObjectManager */
|
||||
private $objectManager;
|
||||
|
||||
/** @var WishlistFactory */
|
||||
private $wishlistFactory;
|
||||
|
||||
/** @var GetWishlistByCustomerId */
|
||||
private $getWishlistByCustomerId;
|
||||
|
||||
/** @var ProductRepositoryInterface */
|
||||
private $productRepository;
|
||||
|
||||
/** @var DataObjectFactory */
|
||||
private $dataObjectFactory;
|
||||
|
||||
/** @var SerializerInterface */
|
||||
private $json;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = ObjectManager::getInstance();
|
||||
$this->wishlistFactory = $this->objectManager->get(WishlistFactory::class);
|
||||
$this->getWishlistByCustomerId = $this->objectManager->get(GetWishlistByCustomerId::class);
|
||||
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
|
||||
$this->productRepository->cleanCache();
|
||||
$this->dataObjectFactory = $this->objectManager->get(DataObjectFactory::class);
|
||||
$this->json = $this->objectManager->get(SerializerInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddNewItem(): void
|
||||
{
|
||||
$productSku = 'simple';
|
||||
$customerId = 1;
|
||||
$product = $this->productRepository->get($productSku);
|
||||
$wishlist = $this->getWishlistByCustomerId->execute($customerId);
|
||||
$wishlist->addNewItem(
|
||||
$product,
|
||||
'{"qty":2}'
|
||||
);
|
||||
$wishlist->addNewItem(
|
||||
$product,
|
||||
['qty' => 3]
|
||||
);
|
||||
$wishlist->addNewItem(
|
||||
$product,
|
||||
$this->dataObjectFactory->create(['data' => ['qty' => 4]])
|
||||
);
|
||||
$wishlist->addNewItem($product);
|
||||
$wishlistItem = $this->getWishlistByCustomerId->getItemBySku(1, $productSku);
|
||||
$this->assertInstanceOf(Item::class, $wishlistItem);
|
||||
$this->assertEquals($wishlistItem->getQty(), 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddNewItemInvalidWishlistItemConfiguration(): void
|
||||
{
|
||||
$productSku = 'simple';
|
||||
$customerId = 1;
|
||||
$product = $this->productRepository->get($productSku);
|
||||
$wishlist = $this->getWishlistByCustomerId->execute($customerId);
|
||||
$this->expectExceptionObject(new \InvalidArgumentException('Invalid wishlist item configuration.'));
|
||||
$wishlist->addNewItem($product, '{"qty":2');
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetItemCollection(): void
|
||||
{
|
||||
$productSku = 'simple';
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, $productSku);
|
||||
$this->assertNotNull($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_disabled_simple_product.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetItemCollectionWithDisabledProduct(): void
|
||||
{
|
||||
$customerId = 1;
|
||||
$this->assertEmpty($this->getWishlistByCustomerId->execute($customerId)->getItemCollection()->getItems());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_product_with_two_child_products.php
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
* @magentoDbIsolation disabled
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddConfigurableProductToWishList(): void
|
||||
{
|
||||
$configurableProduct = $this->productRepository->get('Configurable product');
|
||||
$configurableOptions = $configurableProduct->getTypeInstance()->getConfigurableOptions($configurableProduct);
|
||||
$attributeId = key($configurableOptions);
|
||||
$option = reset($configurableOptions[$attributeId]);
|
||||
$buyRequest = [
|
||||
'super_attribute' => [
|
||||
$attributeId => $option['value_index']
|
||||
],
|
||||
'action' => 'add',
|
||||
];
|
||||
$wishlist = $this->getWishlistByCustomerId->execute(1);
|
||||
$wishlist->addNewItem($configurableProduct, $buyRequest);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'Configurable product');
|
||||
$this->assertNotNull($item);
|
||||
$this->assertWishListItem($item, $option['sku'], $buyRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Bundle/_files/fixed_bundle_product_without_discounts.php
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
* @magentoDbIsolation disabled
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddBundleProductToWishList(): void
|
||||
{
|
||||
$bundleProduct = $this->productRepository->get('fixed_bundle_product_without_discounts');
|
||||
$bundleOptionList = $this->objectManager->create(OptionList::class);
|
||||
$bundleOptions = $bundleOptionList->getItems($bundleProduct);
|
||||
$option = reset($bundleOptions);
|
||||
$productLinks = $option->getProductLinks();
|
||||
$this->assertNotNull($productLinks[0]);
|
||||
$buyRequest = [
|
||||
'bundle_option' => [
|
||||
$option->getOptionId() => $productLinks[0]->getId()
|
||||
],
|
||||
'action' => 'add',
|
||||
];
|
||||
$skuWithChosenOption = implode('-', [$bundleProduct->getSku(), $productLinks[0]->getSku()]);
|
||||
$wishlist = $this->getWishlistByCustomerId->execute(1);
|
||||
$wishlist->addNewItem($bundleProduct, $buyRequest);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'fixed_bundle_product_without_discounts');
|
||||
$this->assertNotNull($item);
|
||||
$this->assertWishListItem($item, $skuWithChosenOption, $buyRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddNotExistingItemToWishList(): void
|
||||
{
|
||||
$wishlist = $this->getWishlistByCustomerId->execute(1);
|
||||
$this->expectExceptionObject(new LocalizedException(__('Cannot specify product.')));
|
||||
$wishlist->addNewItem(989);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/product_out_of_stock_with_multiselect_attribute.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddOutOfStockItemToWishList(): void
|
||||
{
|
||||
$product = $this->productRepository->get('simple_ms_out_of_stock');
|
||||
$wishlist = $this->getWishlistByCustomerId->execute(1);
|
||||
$this->expectExceptionObject(new StockStateException(__('Cannot add product without stock to wishlist.')));
|
||||
$wishlist->addNewItem($product);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateItemQtyInWishList(): void
|
||||
{
|
||||
$wishlist = $this->getWishlistByCustomerId->execute(1);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'simple');
|
||||
$this->assertNotNull($item);
|
||||
$buyRequest = $this->dataObjectFactory->create(['data' => ['qty' => 55]]);
|
||||
$wishlist->updateItem($item->getId(), $buyRequest);
|
||||
$updatedItem = $this->getWishlistByCustomerId->getItemBySku(1, 'simple');
|
||||
$this->assertEquals(55, $updatedItem->getQty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update description of wishlist item
|
||||
*
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateItemDescriptionInWishList(): void
|
||||
{
|
||||
$itemDescription = 'Test Description';
|
||||
$wishlist = $this->getWishlistByCustomerId->execute(1);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'simple');
|
||||
$item->setDescription($itemDescription);
|
||||
$this->assertNotNull($item);
|
||||
$buyRequest = $this->dataObjectFactory->create(['data' => ['qty' => 55]]);
|
||||
$wishlist->updateItem($item, $buyRequest);
|
||||
$updatedItem = $this->getWishlistByCustomerId->getItemBySku(1, 'simple');
|
||||
$this->assertEquals(55, $updatedItem->getQty());
|
||||
$this->assertEquals($itemDescription, $updatedItem->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateNotExistingItemInWishList(): void
|
||||
{
|
||||
$this->expectExceptionObject(new LocalizedException(__('We can\'t specify a wish list item.')));
|
||||
$this->wishlistFactory->create()->updateItem(989, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateNotExistingProductInWishList(): void
|
||||
{
|
||||
$wishlist = $this->getWishlistByCustomerId->execute(1);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'simple');
|
||||
$this->assertNotNull($item);
|
||||
$item->getProduct()->setId(null);
|
||||
$this->expectExceptionObject(new LocalizedException(__('The product does not exist.')));
|
||||
$wishlist->updateItem($item, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that admin user should be able to update wishlist on second website
|
||||
*
|
||||
* @magentoAppArea adminhtml
|
||||
* @magentoDbIsolation disabled
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist_on_second_website.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateWishListItemOnSecondWebsite(): void
|
||||
{
|
||||
$wishlist = $this->getWishlistByCustomerId->execute(1);
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'simple-2');
|
||||
$this->assertNotNull($item);
|
||||
$this->assertEquals(1, $item->getQty());
|
||||
$buyRequest = $this->dataObjectFactory->create(['data' => ['qty' => 2]]);
|
||||
$wishlist->updateItem($item->getId(), $buyRequest);
|
||||
$updatedItem = $this->getWishlistByCustomerId->getItemBySku(1, 'simple-2');
|
||||
$this->assertEquals(2, $updatedItem->getQty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert item in wish list.
|
||||
*
|
||||
* @param Item $item
|
||||
* @param string $itemSku
|
||||
* @param array $buyRequest
|
||||
* @return void
|
||||
*/
|
||||
private function assertWishListItem(Item $item, string $itemSku, array $buyRequest): void
|
||||
{
|
||||
$this->assertEquals($itemSku, $item->getProduct()->getSku());
|
||||
$buyRequestOption = $item->getOptionByCode('info_buyRequest');
|
||||
$this->assertEquals($buyRequest, $this->json->unserialize($buyRequestOption->getValue()));
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Wishlist\Plugin\Model\ResourceModel;
|
||||
|
||||
use Magento\Catalog\Model\ResourceModel\Product as ProductResourceModel;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Interception\PluginList;
|
||||
use Magento\TestFramework\Wishlist\Model\GetWishlistByCustomerId;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Tests for remove quote items plugin.
|
||||
*
|
||||
* @see \Magento\Wishlist\Plugin\Model\ResourceModel\Product
|
||||
* @magentoAppArea adminhtml
|
||||
* @magentoDbIsolation disabled
|
||||
*/
|
||||
class ProductTest extends TestCase
|
||||
{
|
||||
/** @var ObjectManagerInterface */
|
||||
private $objectManager;
|
||||
|
||||
/** @var ProductResourceModel */
|
||||
private $productResoure;
|
||||
|
||||
/** @var GetWishlistByCustomerId */
|
||||
private $getWishlistByCustomerId;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->productResoure = $this->objectManager->get(ProductResourceModel::class);
|
||||
$this->getWishlistByCustomerId = $this->objectManager->get(GetWishlistByCustomerId::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testPluginIsRegistered(): void
|
||||
{
|
||||
$pluginInfo = $this->objectManager->get(PluginList::class)->get(ProductResourceModel::class);
|
||||
$this->assertSame(
|
||||
Product::class,
|
||||
$pluginInfo['cleanups_wishlist_item_after_product_delete']['instance']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Wishlist/_files/wishlist.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDeleteProduct(): void
|
||||
{
|
||||
$item = $this->getWishlistByCustomerId->getItemBySku(1, 'simple');
|
||||
$this->assertNotNull($item);
|
||||
$this->productResoure->delete($item->getProduct());
|
||||
$this->assertNull($this->getWishlistByCustomerId->getItemBySku(1, 'simple'));
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/two_customers.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple.php');
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
|
||||
$product = $productRepository->get('simple');
|
||||
$firstCustomerIdFromFixture = 1;
|
||||
$wishlistForFirstCustomer = $objectManager->create(
|
||||
\Magento\Wishlist\Model\Wishlist::class
|
||||
);
|
||||
$wishlistForFirstCustomer->loadByCustomerId($firstCustomerIdFromFixture, true);
|
||||
$item = $wishlistForFirstCustomer->addNewItem($product, new \Magento\Framework\DataObject([]));
|
||||
$wishlistForFirstCustomer->save();
|
||||
|
||||
$secondCustomerIdFromFixture = 2;
|
||||
$wishlistForSecondCustomer = $objectManager->create(
|
||||
\Magento\Wishlist\Model\Wishlist::class
|
||||
);
|
||||
$wishlistForSecondCustomer->loadByCustomerId($secondCustomerIdFromFixture, true);
|
||||
$item = $wishlistForSecondCustomer->addNewItem($product, new \Magento\Framework\DataObject([]));
|
||||
$wishlistForSecondCustomer->save();
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
/** @var \Magento\Framework\ObjectManagerInterface $objectManager */
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
|
||||
/** @var \Magento\Wishlist\Model\Wishlist $wishlist */
|
||||
$wishlist = $objectManager->create(\Magento\Wishlist\Model\Wishlist::class);
|
||||
$wishlist->loadByCustomerId(1);
|
||||
$wishlist->delete();
|
||||
$wishlist->loadByCustomerId(2);
|
||||
$wishlist->delete();
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/two_customers_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_rollback.php');
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Customer\Model\CustomerRegistry;
|
||||
use Magento\Framework\DataObject;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
use Magento\Wishlist\Model\Wishlist;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple.php');
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var CustomerRegistry $customerRegistry */
|
||||
$customerRegistry = Bootstrap::getObjectManager()->create(CustomerRegistry::class);
|
||||
$customer = $customerRegistry->retrieve(1);
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
|
||||
$product = $productRepository->get('simple');
|
||||
$wishlist = Bootstrap::getObjectManager()->create(Wishlist::class);
|
||||
$wishlist->loadByCustomerId($customer->getId(), true);
|
||||
$item = $wishlist->addNewItem($product, new DataObject([]));
|
||||
$wishlist->setSharingCode('fixture_unique_code')->save();
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Customer\Model\CustomerRegistry;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Wishlist\Model\Wishlist;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/products_with_websites_and_stores.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_non_default_website_id.php');
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var CustomerRegistry $customerRegistry */
|
||||
$customerRegistry = Bootstrap::getObjectManager()->create(CustomerRegistry::class);
|
||||
$customer = $customerRegistry->retrieve(1);
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
|
||||
$simpleProduct = $productRepository->get('simple-2');
|
||||
|
||||
/* @var $wishlist Wishlist */
|
||||
$wishlist = Bootstrap::getObjectManager()->create(Wishlist::class);
|
||||
$wishlist->loadByCustomerId($customer->getId(), true);
|
||||
$wishlist->addNewItem($simpleProduct);
|
||||
$wishlist->setSharingCode('fixture_unique_code')
|
||||
->setShared(1)
|
||||
->save();
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/products_with_websites_and_stores_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_non_default_website_id_rollback.php');
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php');
|
||||
|
||||
/** @var \Magento\Framework\ObjectManagerInterface $objectManager */
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
|
||||
/** @var \Magento\Framework\Registry $registry */
|
||||
$registry = $objectManager->get(\Magento\Framework\Registry::class);
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
|
||||
/** @var \Magento\Wishlist\Model\Wishlist $wishlist */
|
||||
$wishlist = $objectManager->create(\Magento\Wishlist\Model\Wishlist::class);
|
||||
$wishlist->loadByCustomerId(1);
|
||||
$wishlist->delete();
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php');
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Customer\Model\CustomerRegistry;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple.php');
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var CustomerRegistry $customerRegistry */
|
||||
$customerRegistry = Bootstrap::getObjectManager()->create(CustomerRegistry::class);
|
||||
$customer = $customerRegistry->retrieve(1);
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
|
||||
$simpleProduct = $productRepository->get('simple');
|
||||
|
||||
$options = [];
|
||||
foreach ($simpleProduct->getOptions() as $option) {
|
||||
/* @var $option \Magento\Catalog\Model\Product\Option */
|
||||
switch ($option->getType()) {
|
||||
case 'field':
|
||||
$options[$option->getId()] = '1-text';
|
||||
break;
|
||||
case 'date_time':
|
||||
$options[$option->getId()] = ['month' => 1, 'day' => 1, 'year' => 2001, 'hour' => 1, 'minute' => 1];
|
||||
break;
|
||||
case 'drop_down':
|
||||
$options[$option->getId()] = current($option->getValues())->getOptionTypeId();
|
||||
break;
|
||||
case 'radio':
|
||||
$options[$option->getId()] = current($option->getValues())->getOptionTypeId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* @var $wishlist \Magento\Wishlist\Model\Wishlist */
|
||||
$wishlist = Bootstrap::getObjectManager()->create(
|
||||
\Magento\Wishlist\Model\Wishlist::class
|
||||
);
|
||||
$wishlist->loadByCustomerId($customer->getId(), true);
|
||||
$wishlist->addNewItem($simpleProduct, new \Magento\Framework\DataObject(['options' => $options]));
|
||||
$wishlist->setSharingCode('fixture_unique_code')
|
||||
->setShared(1)
|
||||
->save();
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_rollback.php');
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Customer\Model\CustomerRegistry;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Wishlist\Model\WishlistFactory;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer.php');
|
||||
Resolver::getInstance()->requireDataFixture(
|
||||
'Magento/ConfigurableProduct/_files/configurable_product_with_two_child_products.php'
|
||||
);
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var CustomerRegistry $customerRegistry */
|
||||
$customerRegistry = $objectManager->create(CustomerRegistry::class);
|
||||
$customer = $customerRegistry->retrieve(1);
|
||||
$wishlistFactory = $objectManager->get(WishlistFactory::class);
|
||||
$wishlist = $wishlistFactory->create();
|
||||
$wishlist->loadByCustomerId($customer->getId(), true);
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
|
||||
$product = $productRepository->get('Configurable product');
|
||||
$wishlist->addNewItem($product);
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture(
|
||||
'Magento/ConfigurableProduct/_files/configurable_product_with_two_child_products_rollback.php'
|
||||
);
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Customer\Api\CustomerRepositoryInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Wishlist\Model\ResourceModel\Wishlist as WishlistResource;
|
||||
use Magento\Wishlist\Model\Wishlist;
|
||||
use Magento\Wishlist\Model\WishlistFactory;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/simple_product_disabled.php');
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var WishlistResource $wishListResource */
|
||||
$wishListResource = $objectManager->get(WishlistResource::class);
|
||||
/** @var Wishlist $wishlist */
|
||||
$wishlist = $objectManager->get(WishlistFactory::class)->create();
|
||||
/** @var CustomerRepositoryInterface $customerRepository */
|
||||
$customerRepository = $objectManager->get(CustomerRepositoryInterface::class);
|
||||
$customer = $customerRepository->get('customer@example.com');
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
|
||||
$productRepository->cleanCache();
|
||||
$product = $productRepository->get('product_disabled');
|
||||
$wishlist->loadByCustomerId($customer->getId(), true);
|
||||
/** @var \Magento\Catalog\Helper\Product $productHelper */
|
||||
$productHelper = $objectManager->get(\Magento\Catalog\Helper\Product::class);
|
||||
$isSkipSaleableCheck = $productHelper->getSkipSaleableCheck();
|
||||
$productHelper->setSkipSaleableCheck(true);
|
||||
$item = $wishlist->addNewItem($product);
|
||||
$productHelper->setSkipSaleableCheck($isSkipSaleableCheck);
|
||||
$wishlist->setSharingCode('wishlist_disabled_item');
|
||||
$wishListResource->save($wishlist);
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Wishlist\Model\ResourceModel\Wishlist as WishlistResource;
|
||||
use Magento\Wishlist\Model\Wishlist;
|
||||
use Magento\Wishlist\Model\WishlistFactory;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/simple_product_disabled_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php');
|
||||
|
||||
/** @var Registry $registry */
|
||||
$registry = $objectManager->get(Registry::class);
|
||||
/** @var WishlistResource $wishListResource */
|
||||
$wishListResource = $objectManager->get(WishlistResource::class);
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
/** @var Wishlist $wishlist */
|
||||
$wishlist = $objectManager->get(WishlistFactory::class)->create();
|
||||
$wishlist->loadByCustomerId(1);
|
||||
if ($wishlist->getId()) {
|
||||
$wishListResource->delete($wishlist);
|
||||
}
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Wishlist/_files/wishlist.php');
|
||||
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
|
||||
|
||||
$productSku = 'simple';
|
||||
$product = $productRepository->get($productSku);
|
||||
$product->setStatus(ProductStatus::STATUS_DISABLED);
|
||||
$productRepository->save($product);
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Wishlist/_files/wishlist_rollback.php');
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Customer\Model\CustomerRegistry;
|
||||
use Magento\Framework\DataObject;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Wishlist\Model\WishlistFactory;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer.php');
|
||||
Resolver::getInstance()->requireDataFixture(
|
||||
'Magento/GroupedProduct/_files/product_grouped_with_simple.php'
|
||||
);
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var CustomerRegistry $customerRegistry */
|
||||
$customerRegistry = $objectManager->get(CustomerRegistry::class);
|
||||
$customer = $customerRegistry->retrieve(1);
|
||||
$wishlistFactory = $objectManager->get(WishlistFactory::class);
|
||||
$wishlist = $wishlistFactory->create();
|
||||
$wishlist->loadByCustomerId($customer->getId(), true);
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
|
||||
$product = $productRepository->get('grouped');
|
||||
$simple1 = $productRepository->get('simple_11');
|
||||
$simple2 = $productRepository->get('simple_22');
|
||||
$buyRequest = new DataObject([
|
||||
'product' => $product->getId(),
|
||||
'super_group' =>
|
||||
[
|
||||
$simple1->getId() => '1',
|
||||
$simple2->getId() => '1',
|
||||
],
|
||||
'action' => 'add',
|
||||
]);
|
||||
$wishlist->addNewItem($product, $buyRequest);
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture(
|
||||
'Magento/GroupedProduct/_files/product_grouped_with_simple_rollback.php'
|
||||
);
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Customer\Model\CustomerRegistry;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Wishlist\Model\WishlistFactory;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/multiple_products.php');
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var CustomerRegistry $customerRegistry */
|
||||
$customerRegistry = Bootstrap::getObjectManager()->create(CustomerRegistry::class);
|
||||
$customer = $customerRegistry->retrieve(1);
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
|
||||
$product = $productRepository->get('simple1');
|
||||
$product2 = $productRepository->get('simple2');
|
||||
|
||||
$wishlistFactory = $objectManager->get(WishlistFactory::class);
|
||||
$wishlist = $wishlistFactory->create();
|
||||
$wishlist->loadByCustomerId($customer->getId(), true);
|
||||
/** @var \Magento\Catalog\Helper\Product $productHelper */
|
||||
$productHelper = $objectManager->get(\Magento\Catalog\Helper\Product::class);
|
||||
$isSkipSaleableCheck = $productHelper->getSkipSaleableCheck();
|
||||
$productHelper->setSkipSaleableCheck(true);
|
||||
$wishlist->addNewItem($product);
|
||||
$wishlist->addNewItem($product2);
|
||||
$productHelper->setSkipSaleableCheck($isSkipSaleableCheck);
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/multiple_products_rollback.php');
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Customer\Api\CustomerRepositoryInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Wishlist\Model\ResourceModel\Wishlist as WishlistResource;
|
||||
use Magento\Wishlist\Model\Wishlist;
|
||||
use Magento\Wishlist\Model\WishlistFactory;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/simple_products_not_visible_individually.php');
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var WishlistResource $wishListResource */
|
||||
$wishListResource = $objectManager->get(WishlistResource::class);
|
||||
/** @var Wishlist $wishList */
|
||||
$wishList = $objectManager->get(WishlistFactory::class)->create();
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
|
||||
$productRepository->cleanCache();
|
||||
/** @var CustomerRepositoryInterface $customerRepository */
|
||||
$customerRepository = $objectManager->get(CustomerRepositoryInterface::class);
|
||||
$customer = $customerRepository->get('customer@example.com');
|
||||
$product = $productRepository->get('simple_not_visible_1');
|
||||
$wishList->loadByCustomerId($customer->getId(), true);
|
||||
$item = $wishList->addNewItem($product);
|
||||
$wishList->setSharingCode('fixture_unique_code');
|
||||
$wishListResource->save($wishList);
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Wishlist\Model\ResourceModel\Wishlist as WishlistResource;
|
||||
use Magento\Wishlist\Model\Wishlist;
|
||||
use Magento\Wishlist\Model\WishlistFactory;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var Registry $registry */
|
||||
$registry = $objectManager->get(Registry::class);
|
||||
/** @var WishlistResource $wishListResource */
|
||||
$wishListResource = $objectManager->get(WishlistResource::class);
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
/** @var Wishlist $wishlist */
|
||||
$wishlist = $objectManager->get(WishlistFactory::class)->create();
|
||||
$wishlist->loadByCustomerId(1);
|
||||
if ($wishlist->getId()) {
|
||||
$wishListResource->delete($wishlist);
|
||||
}
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
|
||||
Resolver::getInstance()
|
||||
->requireDataFixture('Magento/Catalog/_files/simple_products_not_visible_individually_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php');
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Customer\Model\CustomerRegistry;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_special_price.php');
|
||||
|
||||
/** @var \Magento\Framework\ObjectManagerInterface $objectManager */
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var CustomerRegistry $customerRegistry */
|
||||
$customerRegistry = Bootstrap::getObjectManager()->create(CustomerRegistry::class);
|
||||
$customer = $customerRegistry->retrieve(1);
|
||||
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
|
||||
|
||||
$product = $productRepository->get('simple');
|
||||
$product->setStockData(['enable_qty_increments' => 1, 'qty_increments' => 5])->save();
|
||||
|
||||
/** @var \Magento\Wishlist\Model\Wishlist $wishlist */
|
||||
$wishlist = $objectManager->create(\Magento\Wishlist\Model\Wishlist::class);
|
||||
$wishlist->loadByCustomerId($customer->getId(), true);
|
||||
$wishlist->addNewItem($product);
|
||||
$wishlist->save();
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
/** @var \Magento\Framework\ObjectManagerInterface $objectManager */
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
|
||||
/** @var \Magento\Framework\Registry $registry */
|
||||
$registry = $objectManager->get(\Magento\Framework\Registry::class);
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', true);
|
||||
|
||||
/** @var \Magento\Wishlist\Model\Wishlist $wishlist */
|
||||
$wishlist = $objectManager->create(\Magento\Wishlist\Model\Wishlist::class);
|
||||
$wishlist->loadByCustomerId(1);
|
||||
$wishlist->delete();
|
||||
|
||||
$registry->unregister('isSecureArea');
|
||||
$registry->register('isSecureArea', false);
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_special_price_rollback.php');
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Framework\Serialize\SerializerInterface;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
use Magento\Wishlist\Model\WishlistFactory;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Customer\Model\CustomerRegistry;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple.php');
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var CustomerRegistry $customerRegistry */
|
||||
$customerRegistry = Bootstrap::getObjectManager()->create(CustomerRegistry::class);
|
||||
$customer = $customerRegistry->retrieve(1);
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
|
||||
$product = $productRepository->get('simple');
|
||||
$json = $objectManager->get(SerializerInterface::class);
|
||||
$wishlistFactory = $objectManager->get(WishlistFactory::class);
|
||||
$wishlist = $wishlistFactory->create();
|
||||
$wishlist->loadByCustomerId($customer->getId(), true);
|
||||
$wishlist->addNewItem($product, $json->serialize(['qty' => 3]));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_rollback.php');
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Customer\Model\CustomerRegistry;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Wishlist\Model\WishlistFactory;
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_duplicated.php');
|
||||
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var CustomerRegistry $customerRegistry */
|
||||
$customerRegistry = Bootstrap::getObjectManager()->create(CustomerRegistry::class);
|
||||
$customer = $customerRegistry->retrieve(1);
|
||||
/** @var ProductRepositoryInterface $productRepository */
|
||||
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
|
||||
$product = $productRepository->get('simple-1');
|
||||
|
||||
$wishlistFactory = $objectManager->get(WishlistFactory::class);
|
||||
$wishlist = $wishlistFactory->create();
|
||||
$wishlist->loadByCustomerId($customer->getId(), true);
|
||||
/** @var \Magento\Catalog\Helper\Product $productHelper */
|
||||
$productHelper = $objectManager->get(\Magento\Catalog\Helper\Product::class);
|
||||
$isSkipSaleableCheck = $productHelper->getSkipSaleableCheck();
|
||||
$productHelper->setSkipSaleableCheck(true);
|
||||
$wishlist->addNewItem($product);
|
||||
$productHelper->setSkipSaleableCheck($isSkipSaleableCheck);
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
||||
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php');
|
||||
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_duplicated_rollback.php');
|
||||
Reference in New Issue
Block a user