Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/dev/tests/integration/testsuite/Magento/Wishlist/Controller/Index/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/dev/tests/integration/testsuite/Magento/Wishlist/Controller/Index/RemoveTest.php
<?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();
    }
}

Spamworldpro Mini