![]() 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-webapi/Test/Unit/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Webapi\Test\Unit\Model; use Magento\Framework\Reflection\DataObjectProcessor; use Magento\Framework\Reflection\FieldNamer; use Magento\Framework\Reflection\MethodsMap; use Magento\Framework\Reflection\Test\Unit\TestDataInterface; use Magento\Framework\Reflection\Test\Unit\TestDataObject; use Magento\Framework\Reflection\TypeCaster; use Magento\Framework\Reflection\TypeProcessor; use Magento\Framework\Serialize\SerializerInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Webapi\Model\Config as ModelConfig; use PHPUnit\Framework\TestCase; class DataObjectProcessorTest extends TestCase { /** * @var DataObjectProcessor */ protected $dataObjectProcessor; /** * @var ModelConfig */ protected $config; protected function setup(): void { $objectManager = new ObjectManager($this); $methodsMapProcessor = $objectManager->getObject( MethodsMap::class, [ 'fieldNamer' => $objectManager->getObject(FieldNamer::class), 'typeProcessor' => $objectManager->getObject(TypeProcessor::class), ] ); $serializerMock = $this->getMockForAbstractClass(SerializerInterface::class); $serializerMock->method('serialize') ->willReturn('serializedData'); $serializerMock->method('unserialize') ->willReturn(['unserializedData']); $objectManager->setBackwardCompatibleProperty( $methodsMapProcessor, 'serializer', $serializerMock ); $this->dataObjectProcessor = $objectManager->getObject( DataObjectProcessor::class, [ 'methodsMapProcessor' => $methodsMapProcessor, 'typeCaster' => $objectManager->getObject(TypeCaster::class), 'fieldNamer' => $objectManager->getObject(FieldNamer::class), ] ); parent::setUp(); } public function testDataObjectProcessor() { $objectManager = new ObjectManager($this); /** @var TestDataObject $testDataObject */ $testDataObject = $objectManager->getObject(TestDataObject::class); $expectedOutputDataArray = [ 'id' => '1', 'address' => 'someAddress', 'default_shipping' => 'true', 'required_billing' => 'false', ]; $testDataObjectType = TestDataInterface::class; $outputData = $this->dataObjectProcessor->buildOutputDataArray($testDataObject, $testDataObjectType); $this->assertEquals($expectedOutputDataArray, $outputData); } }