![]() 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-adobe-stock-image/Test/Unit/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\AdobeStockImage\Test\Unit\Model; use Magento\AdobeStockAssetApi\Api\Data\AssetInterface; use Magento\AdobeStockImage\Model\SerializeImage; use Magento\Framework\Api\AttributeInterface; use Magento\Framework\Api\Search\Document; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; /** * Test for SerializeImage Model */ class SerializeImageTest extends TestCase { /** * @var AssetInterface|MockObject */ private $documentMock; /** * @var SerializeImage */ private $serializeImage; /** * @inheritdoc */ protected function setUp(): void { $this->documentMock = $this->createMock(Document::class); $this->serializeImage = new SerializeImage(); } /** * Testing execute method of serialize image class */ public function testExecute(): void { $attributeCategoryMock = $this->createMock(AttributeInterface::class); $attributeCategoryMock->method('getAttributeCode')->willReturn('category'); $attributeCategoryMock->method('getValue')->willReturn(123); $attribute240ThumbMock = $this->createMock(AttributeInterface::class); $attribute240ThumbMock->method('getAttributeCode')->willReturn('thumbnail_240_url'); $attribute240ThumbMock->method('getValue')->willReturn("image-url"); $this->documentMock->expects($this->once()) ->method('getCustomAttributes') ->willReturn([$attribute240ThumbMock, $attributeCategoryMock]); $expectedResult = ['thumbnail_url' => 'image-url', 'category' => 123]; $result = $this->serializeImage->execute($this->documentMock); $this->assertEquals($expectedResult, $result); } }