Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ImporterFactoryTest.php
Go to the documentation of this file.
1 <?php
7 
11 
12 class ImporterFactoryTest extends \PHPUnit\Framework\TestCase
13 {
17  private $objectManagerMock;
18 
22  private $importerFactory;
23 
24  protected function setUp()
25  {
26  $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
27  ->getMockForAbstractClass();
28  $this->importerFactory = new ImporterFactory($this->objectManagerMock);
29  }
30 
31  public function testCreate()
32  {
33  $className = 'some/class/name';
34 
36  $importerMock = $this->getMockBuilder(ImporterInterface::class)
37  ->getMockForAbstractClass();
38 
39  $this->objectManagerMock->expects($this->once())
40  ->method('create')
41  ->with($className, [])
42  ->willReturn($importerMock);
43 
44  $this->assertSame($importerMock, $this->importerFactory->create($className));
45  }
46 
53  public function testCreateWithInvalidArgumentException()
54  {
55  $className = 'some/class/name';
56 
58  $importerMock = $this->getMockBuilder(\stdClass::class)
59  ->disableOriginalConstructor()
60  ->getMock();
61 
62  $this->objectManagerMock->expects($this->once())
63  ->method('create')
64  ->with($className, [])
65  ->willReturn($importerMock);
66 
67  $this->importerFactory->create($className);
68  }
69 }
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31