Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigSetProcessorFactoryTest.php
Go to the documentation of this file.
1 <?php
8 
14 use PHPUnit_Framework_MockObject_MockObject as Mock;
15 
21 class ConfigSetProcessorFactoryTest extends \PHPUnit\Framework\TestCase
22 {
26  private $model;
27 
31  private $objectManagerMock;
32 
36  protected function setUp()
37  {
38  $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
39  ->getMockForAbstractClass();
40 
41  $this->model = new ConfigSetProcessorFactory(
42  $this->objectManagerMock,
43  [
44  ConfigSetProcessorFactory::TYPE_LOCK_ENV => LockProcessor::class,
45  ConfigSetProcessorFactory::TYPE_DEFAULT => DefaultProcessor::class,
46  'wrongType' => \stdClass::class,
47  ]
48  );
49  }
50 
51  public function testCreate()
52  {
53  $processorMock = $this->getMockBuilder(ConfigSetProcessorInterface::class)
54  ->getMockForAbstractClass();
55  $this->objectManagerMock->expects($this->once())
56  ->method('create')
57  ->with(LockProcessor::class)
58  ->willReturn($processorMock);
59 
60  $this->assertInstanceOf(
61  ConfigSetProcessorInterface::class,
62  $this->model->create(ConfigSetProcessorFactory::TYPE_LOCK_ENV)
63  );
64  }
65 
70  public function testCreateNonExisted()
71  {
72  $this->model->create('dummyType');
73  }
74 
80  {
81  $type = 'wrongType';
82  $this->objectManagerMock->expects($this->once())
83  ->method('create')
84  ->with(\stdClass::class)
85  ->willReturn(new \stdClass());
86 
87  $this->model->create($type);
88  }
89 }
$type
Definition: item.phtml:13