![]() 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/Translate/Test/Unit/Inline/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Framework\Translate\Test\Unit\Inline; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Translate\Inline; use Magento\Framework\Translate\Inline\Proxy; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class ProxyTest extends TestCase { /** * @var ObjectManagerInterface|MockObject */ protected $objectManagerMock; /** * @var Inline|MockObject */ protected $translateMock; protected function setUp(): void { $this->objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class); $this->translateMock = $this->createMock(Inline::class); } public function testIsAllowed() { $this->objectManagerMock->expects( $this->once() )->method( 'get' )->with( Inline::class )->willReturn( $this->translateMock ); $this->objectManagerMock->expects($this->never())->method('create'); $this->translateMock->expects($this->once())->method('isAllowed')->willReturn(false); $model = new Proxy( $this->objectManagerMock, Inline::class, true ); $this->assertFalse($model->isAllowed()); } public function testGetParser() { $parser = new \stdClass(); $this->objectManagerMock->expects( $this->once() )->method( 'create' )->with( Inline::class )->willReturn( $this->translateMock ); $this->objectManagerMock->expects($this->never())->method('get'); $this->translateMock->expects($this->once())->method('getParser')->willReturn($parser); $model = new Proxy( $this->objectManagerMock, Inline::class, false ); $this->assertEquals($parser, $model->getParser()); } public function testProcessResponseBody() { $isJson = true; $this->objectManagerMock->expects( $this->once() )->method( 'get' )->with( Inline::class )->willReturn( $this->translateMock ); $this->objectManagerMock->expects($this->never())->method('create'); $this->translateMock->expects($this->once()) ->method('processResponseBody') ->with('', $isJson)->willReturnSelf(); $model = new Proxy( $this->objectManagerMock, Inline::class, true ); $body = ''; $this->assertEquals($this->translateMock, $model->processResponseBody($body, $isJson)); } public function testGetAdditionalHtmlAttribute() { $this->objectManagerMock->expects( $this->once() )->method( 'create' )->with( Inline::class )->willReturn( $this->translateMock ); $this->objectManagerMock->expects($this->never())->method('get'); $this->translateMock->expects($this->exactly(2)) ->method('getAdditionalHtmlAttribute') ->with($this->logicalOr('some_value', null)) ->willReturnArgument(0); $model = new Proxy( $this->objectManagerMock, Inline::class, false ); $this->assertEquals('some_value', $model->getAdditionalHtmlAttribute('some_value')); $this->assertNull($model->getAdditionalHtmlAttribute()); } }