-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 2.3-develop into ENGCOM-4636-magento-magento2-21932
- Loading branch information
Showing
17 changed files
with
229 additions
and
2,813 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
dev/tests/integration/testsuite/Magento/Config/Model/Config/Structure/Reader/ReaderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Config\Model\Config\Structure\Reader; | ||
|
||
use Magento\Config\Model\Config\SchemaLocator; | ||
use Magento\Framework\App\Utility\Files; | ||
use Magento\Framework\Config\Dom; | ||
use Magento\Framework\Config\FileResolverInterface; | ||
use Magento\Framework\Config\ValidationStateInterface; | ||
use Magento\Framework\ObjectManagerInterface; | ||
use Magento\Framework\View\TemplateEngine\Xhtml\CompilerInterface; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
|
||
/** | ||
* Class ReaderTest check Magento\Config\Model\Config\Structure\Reader::_readFiles() method. | ||
*/ | ||
class ReaderTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* Test config location. | ||
* | ||
* @string | ||
*/ | ||
const CONFIG = '/dev/tests/integration/testsuite/Magento/Config/Model/Config/Structure/Reader/_files/'; | ||
|
||
/** | ||
* @var ObjectManagerInterface | ||
*/ | ||
private $objectManager; | ||
|
||
/** | ||
* @var Files | ||
*/ | ||
private $fileUtility; | ||
|
||
/** | ||
* @var ValidationStateInterface | ||
*/ | ||
private $validationStateMock; | ||
|
||
/** | ||
* @var \Magento\Framework\Config\SchemaLocatorInterface | ||
*/ | ||
private $schemaLocatorMock; | ||
|
||
/** | ||
* @var FileResolverInterface | ||
*/ | ||
private $fileResolverMock; | ||
|
||
/** | ||
* @var ReaderStub | ||
*/ | ||
private $reader; | ||
|
||
/** | ||
* @var ConverterStub | ||
*/ | ||
private $converter; | ||
|
||
/** | ||
* @var CompilerInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $compiler; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->objectManager = Bootstrap::getObjectManager(); | ||
$this->fileUtility = Files::init(); | ||
|
||
$this->validationStateMock = $this->getMockBuilder(ValidationStateInterface::class) | ||
->setMethods(['isValidationRequired']) | ||
->getMockForAbstractClass(); | ||
$this->schemaLocatorMock = $this->getMockBuilder(SchemaLocator::class) | ||
->disableOriginalConstructor() | ||
->setMethods(['getPerFileSchema']) | ||
->getMock(); | ||
$this->fileResolverMock = $this->getMockBuilder(FileResolverInterface::class) | ||
->getMockForAbstractClass(); | ||
|
||
$this->validationStateMock->expects($this->atLeastOnce()) | ||
->method('isValidationRequired') | ||
->willReturn(false); | ||
$this->schemaLocatorMock->expects($this->atLeastOnce()) | ||
->method('getPerFileSchema') | ||
->willReturn(false); | ||
|
||
$this->converter = $this->objectManager->create(ConverterStub::class); | ||
|
||
//Isolate test from actual configuration, and leave only sample data. | ||
$this->compiler = $this->getMockBuilder(CompilerInterface::class) | ||
->disableOriginalConstructor() | ||
->setMethods(['compile']) | ||
->getMockForAbstractClass(); | ||
|
||
$this->reader = $this->objectManager->create( | ||
ReaderStub::class, | ||
[ | ||
'fileResolver' => $this->fileResolverMock, | ||
'converter' => $this->converter, | ||
'schemaLocator' => $this->schemaLocatorMock, | ||
'validationState' => $this->validationStateMock, | ||
'fileName' => 'no_existing_file.xml', | ||
'compiler' => $this->compiler, | ||
'domDocumentClass' => Dom::class | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* The test checks the file structure after processing the nodes responsible for inserting content. | ||
* | ||
* @return void | ||
*/ | ||
public function testXmlConvertedConfigurationAndCompereStructure() | ||
{ | ||
$actual = $this->reader->readFiles(['actual' => $this->getContent()]); | ||
|
||
$document = new \DOMDocument(); | ||
$document->loadXML($this->getContent()); | ||
|
||
$expected = $this->converter->getArrayData($document); | ||
|
||
$this->assertEquals($expected, $actual); | ||
} | ||
|
||
/** | ||
* Get config sample data for test. | ||
* | ||
* @return string | ||
*/ | ||
protected function getContent() | ||
{ | ||
$files = $this->fileUtility->getFiles([BP . static::CONFIG], 'config.xml'); | ||
|
||
return file_get_contents(reset($files)); | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.