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/framework/View/Test/Unit/Element/UiComponent/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/framework/View/Test/Unit/Element/UiComponent/ProcessorTest.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

/**
 * Test for view Messages model
 */
namespace Magento\Framework\View\Test\Unit\Element\UiComponent;

use Magento\Framework\View\Element\UiComponent\ObserverInterface;
use Magento\Framework\View\Element\UiComponent\Processor;
use Magento\Framework\View\Element\UiComponentInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class ProcessorTest extends TestCase
{
    /**
     * @var UiComponentInterface|MockObject
     */
    protected $component;

    /**
     * @var ObserverInterface|MockObject
     */
    protected $observer;

    /**
     * @var Processor
     */
    protected $processor;

    protected function setUp(): void
    {
        $this->component = $this->getMockBuilder(UiComponentInterface::class)
            ->getMockForAbstractClass();
        $this->observer = $this->getMockBuilder(ObserverInterface::class)
            ->getMockForAbstractClass();
        $this->processor = new Processor();
    }

    public function testRegisterGetComponents()
    {
        $this->assertCount(0, $this->processor->getComponents());
        $this->processor->register($this->component);
        $this->assertCount(1, $this->processor->getComponents());
    }

    public function testAttachAndNotify()
    {
        $type = 'test_type';
        $this->component->expects($this->any())
            ->method('getComponentName')
            ->willReturn($type);
        $this->observer->expects($this->any())
            ->method('update')
            ->with($this->component);
        /** @var UiComponentInterface $component2 */
        $component2 = $this->getMockBuilder(UiComponentInterface::class)
            ->getMockForAbstractClass();
        $component2->expects($this->any())
            ->method('getComponentName')
            ->willReturn('other_type');

        $this->processor->register($this->component);
        $this->processor->register($component2);
        $this->processor->attach($type, $this->observer);
        $this->processor->notify($type);
    }

    public function testDetach()
    {
        $this->processor->detach('unexists_type', $this->observer);
        $this->processor->attach('some_type', $this->observer);
        $this->processor->notify('unexists_type');
        $this->processor->detach('some_type', $this->observer);
    }
}

Spamworldpro Mini