Skip to content

Commit b85b91e

Browse files
committed
#5188: Update DomDocumentFactoryTest to check that create returns the expected type of object
1 parent b552dd1 commit b85b91e

File tree

1 file changed

+5
-79
lines changed

1 file changed

+5
-79
lines changed

lib/internal/Magento/Framework/Test/Unit/DomDocument/DomDocumentFactoryTest.php

Lines changed: 5 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -6,90 +6,16 @@
66

77
namespace Magento\Framework\Test\Unit\DomDocument;
88

9-
use DOMDocument;
109
use Magento\Framework\DomDocument\DomDocumentFactory;
11-
use Magento\Framework\ObjectManagerInterface;
12-
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1310

1411
class DomDocumentFactoryTest extends \PHPUnit\Framework\TestCase
1512
{
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()
4914
{
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()
5819
);
5920
}
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-
}
9521
}

0 commit comments

Comments
 (0)