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/vendor/magento/module-cms/Test/Unit/Model/Plugin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-cms/Test/Unit/Model/Plugin/ProductTest.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Cms\Test\Unit\Model\Plugin;

use Magento\Catalog\Model\Product as CatalogProduct;
use Magento\Cms\Model\Page;
use Magento\Cms\Model\Plugin\Product;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
 * Product plugin test
 */
class ProductTest extends TestCase
{
    /**
     * @var Product
     */
    private $plugin;

    /**
     * @var MockObject|CatalogProduct
     */
    private $product;

    /**
     * @var MockObject|Page
     */
    private $page;

    /**
     * @inheritdoc
     */
    protected function setUp(): void
    {
        $objectManager = new ObjectManager($this);

        $this->product = $this->getMockBuilder(CatalogProduct::class)
            ->disableOriginalConstructor()
            ->setMethods(['getEntityId', 'getOrigData', 'getData', 'getCategoryIds'])
            ->getMock();

        $this->page = $this->getMockBuilder(Page::class)
            ->disableOriginalConstructor()
            ->setMethods(['getId', 'load'])
            ->getMock();

        $this->plugin = $objectManager->getObject(
            Product::class,
            [
                'page' => $this->page
            ]
        );
    }

    public function testAfterGetIdentities()
    {
        $baseIdentities = [
            'SomeCacheId',
            'AnotherCacheId',
        ];
        $id = 12345;
        $pageId = 1;
        $expectedIdentities = [
            'SomeCacheId',
            'AnotherCacheId',
            Page::CACHE_TAG . '_' . $pageId,
        ];

        $this->product->method('getEntityId')
            ->willReturn($id);
        $this->product->method('getOrigData')
            ->with('status')
            ->willReturn(2);
        $this->product->method('getData')
            ->with('status')
            ->willReturn(1);
        $this->page->method('getId')
            ->willReturn(1);
        $this->page->method('load')
            ->willReturnSelf();

        $identities = $this->plugin->afterGetIdentities($this->product, $baseIdentities);

        $this->assertEquals($expectedIdentities, $identities);
    }
}

Spamworldpro Mini