Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FixtureConfigTest.php
Go to the documentation of this file.
1 <?php
8 
11 
12 class FixtureConfigTest extends \PHPUnit\Framework\TestCase
13 {
17  private $model;
18 
22  private $fileParserMock;
23 
24  public function setUp()
25  {
26  $this->fileParserMock = $this->createPartialMock(Parser::class, ['getDom', 'xmlToArray']);
27 
28  $this->model = new FixtureConfig($this->fileParserMock);
29  }
30 
35  public function testLoadConfigException()
36  {
37  $this->model->loadConfig('exception.file');
38  }
39 
40  public function testLoadConfig()
41  {
42  $this->fileParserMock->expects($this->exactly(2))->method('xmlToArray')->willReturn(
43  ['config' => [ 'profile' => ['some_key' => 'some_value']]]
44  );
45 
46  $domMock = $this->createPartialMock(\DOMDocument::class, ['load', 'xinclude']);
47  $domMock->expects($this->once())->method('load')->with('config.file')->willReturn(
48  $this->fileParserMock->xmlToArray()
49  );
50  $domMock->expects($this->once())->method('xinclude');
51  $this->fileParserMock->expects($this->exactly(2))->method('getDom')->willReturn($domMock);
52 
53  $this->model->loadConfig('config.file');
54  $this->assertSame('some_value', $this->model->getValue('some_key'));
55  }
56 
57  public function testGetValue()
58  {
59  $this->assertSame(null, $this->model->getValue('null_key'));
60  }
61 }
62 
63 namespace Magento\Setup\Fixtures;
64 
74 function is_readable($filename)
75 {
76  if (strpos($filename, 'exception') !== false) {
77  return false;
78  }
79  return true;
80 }