Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PlaceholderFactoryTest.php
Go to the documentation of this file.
1 <?php
7 
11 
12 class PlaceholderFactoryTest extends \PHPUnit\Framework\TestCase
13 {
17  private $model;
18 
22  private $objectManagerMock;
23 
27  private $environmentMock;
28 
29  protected function setUp()
30  {
31  $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
32  ->getMockForAbstractClass();
33  $this->environmentMock = $this->getMockBuilder(Environment::class)
34  ->disableOriginalConstructor()
35  ->getMock();
36 
37  $this->model = new PlaceholderFactory(
38  $this->objectManagerMock,
39  [
40  PlaceholderFactory::TYPE_ENVIRONMENT => Environment::class,
41  'wrongClass' => \stdClass::class,
42  ]
43  );
44  }
45 
46  public function testCreate()
47  {
48  $this->objectManagerMock->expects($this->once())
49  ->method('create')
50  ->with(Environment::class)
51  ->willReturn($this->environmentMock);
52 
53  $this->assertInstanceOf(
54  Environment::class,
55  $this->model->create(PlaceholderFactory::TYPE_ENVIRONMENT)
56  );
57  }
58 
63  public function testCreateNonExisted()
64  {
65  $this->model->create('dummyClass');
66  }
67 
73  {
74  $this->model->create('wrongClass');
75  }
76 }