|
6 | 6 |
|
7 | 7 | namespace Magento\Framework\Test\Unit\DomDocument;
|
8 | 8 |
|
9 |
| -use DOMDocument; |
10 | 9 | use Magento\Framework\DomDocument\DomDocumentFactory;
|
11 |
| -use Magento\Framework\ObjectManagerInterface; |
12 |
| -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; |
13 | 10 |
|
14 | 11 | class DomDocumentFactoryTest extends \PHPUnit\Framework\TestCase
|
15 | 12 | {
|
16 |
| - /** |
17 |
| - * @var ObjectManagerHelper |
18 |
| - */ |
19 |
| - private $objectManagerHelper; |
20 |
| - |
21 |
| - /** |
22 |
| - * @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject |
23 |
| - */ |
24 |
| - private $objectManagerMock; |
25 |
| - |
26 |
| - /** |
27 |
| - * @var DOMDocument|\PHPUnit_Framework_MockObject_MockObject |
28 |
| - */ |
29 |
| - private $domDocumentMock; |
30 |
| - |
31 |
| - /** |
32 |
| - * @var DomDocumentFactory |
33 |
| - */ |
34 |
| - private $domDocumentFactory; |
35 |
| - |
36 |
| - /** |
37 |
| - * @var string |
38 |
| - */ |
39 |
| - private $xmlSample = <<<EOT |
40 |
| -<?xml version="1.0"?> |
41 |
| -<root> |
42 |
| -</root> |
43 |
| -EOT; |
44 |
| - |
45 |
| - /** |
46 |
| - * {@inheritdoc} |
47 |
| - */ |
48 |
| - protected function setUp() |
| 13 | + public function testCreateReturnsDomDocument() |
49 | 14 | {
|
50 |
| - $this->objectManagerHelper = new ObjectManagerHelper($this); |
51 |
| - $this->objectManagerMock = $this->createMock(ObjectManagerInterface::class); |
52 |
| - $this->domDocumentMock = $this->createMock(DOMDocument::class); |
53 |
| - $this->domDocumentFactory = $this->objectManagerHelper->getObject( |
54 |
| - DomDocumentFactory::class, |
55 |
| - [ |
56 |
| - 'objectManager' => $this->objectManagerMock |
57 |
| - ] |
| 15 | + $domDocumentFactory = new DomDocumentFactory(); |
| 16 | + $this->assertInstanceOf( |
| 17 | + \DOMDocument::class, |
| 18 | + $domDocumentFactory->create() |
58 | 19 | );
|
59 | 20 | }
|
60 |
| - |
61 |
| - /** |
62 |
| - * @dataProvider createDataProvider |
63 |
| - */ |
64 |
| - public function testCreate($data = null) |
65 |
| - { |
66 |
| - $this->objectManagerMock->expects($this->once()) |
67 |
| - ->method('create') |
68 |
| - ->with(DOMDocument::class) |
69 |
| - ->willReturn($this->domDocumentMock); |
70 |
| - |
71 |
| - if (!empty($data)) { |
72 |
| - $this->domDocumentMock->expects($this->once()) |
73 |
| - ->method('loadXML') |
74 |
| - ->with($data) |
75 |
| - ->willReturn(true); |
76 |
| - } else { |
77 |
| - $this->domDocumentMock->expects($this->never()) |
78 |
| - ->method('loadXML'); |
79 |
| - } |
80 |
| - |
81 |
| - $this->domDocumentFactory->create($data); |
82 |
| - } |
83 |
| - |
84 |
| - /** |
85 |
| - * @return array |
86 |
| - */ |
87 |
| - public function createDataProvider(): array |
88 |
| - { |
89 |
| - return [ |
90 |
| - [null], |
91 |
| - [''], |
92 |
| - [$this->xmlSample] |
93 |
| - ]; |
94 |
| - } |
95 | 21 | }
|
0 commit comments