![]() 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/cartforge.co/vendor/magento/module-catalog/Test/Unit/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Catalog\Test\Unit\Model; use Magento\Catalog\Model\Factory; use Magento\Catalog\Model\Product\Option; use Magento\Framework\ObjectManagerInterface; use PHPUnit\Framework\TestCase; class FactoryTest extends TestCase { /** * @var ObjectManagerInterface */ protected $objectManager; /** * @var Option */ protected $model; /** * @var Factory */ protected $factory; public function testCreate() { $this->assertInstanceOf(Option::class, $this->factory->create('model', [])); } public function testExceptionCreate() { $this->expectException('Magento\Framework\Exception\LocalizedException'); $this->factory->create('null', []); } protected function setUp(): void { $this->model = $this->createMock(Option::class); $this->setObjectManager(); $this->factory = new Factory($this->objectManager); } protected function setObjectManager() { $this->objectManager = $this->getMockForAbstractClass(ObjectManagerInterface::class); $this->objectManager ->expects($this->any()) ->method('create') ->with($this->logicalOr($this->equalTo('model'), $this->equalTo('null')), []) ->willReturnCallback(function ($className) { $returnValue = null; if ($className == 'model') { $returnValue = $this->model; } return $returnValue; }); } }