diff --git a/app/code/Magento/Ui/DataProvider/Config/FileResolver.php b/app/code/Magento/Ui/DataProvider/Config/FileResolver.php index 9a5c7f1ca4d1a..97a90ce4c6bc8 100644 --- a/app/code/Magento/Ui/DataProvider/Config/FileResolver.php +++ b/app/code/Magento/Ui/DataProvider/Config/FileResolver.php @@ -45,7 +45,7 @@ public function get($filename, $scope) { $iterator = $this->iteratorFactory->create( $this->directoryRead, - $this->directoryRead->search('/*/*/etc/data_source/*') + $this->directoryRead->search('/*/*/etc/data_source/' . $filename) ); return $iterator; } diff --git a/dev/tests/unit/testsuite/Magento/Ui/DataProvider/Config/FileResolverTest.php b/dev/tests/unit/testsuite/Magento/Ui/DataProvider/Config/FileResolverTest.php new file mode 100644 index 0000000000000..7131ec8c5302f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Ui/DataProvider/Config/FileResolverTest.php @@ -0,0 +1,47 @@ +mockDirectoryRead = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\Read') + ->disableOriginalConstructor() + ->getMock(); + $stubFileIteratorFactory = $this->getMockBuilder('Magento\Framework\Config\FileIteratorFactory') + ->disableOriginalConstructor() + ->getMock(); + $stubFilesystem = $this->getMockBuilder('Magento\Framework\Filesystem') + ->disableOriginalConstructor() + ->getMock(); + $stubFilesystem->expects($this->any()) + ->method('getDirectoryRead') + ->willReturn($this->mockDirectoryRead); + $this->fileResolver = new FileResolver($stubFilesystem, $stubFileIteratorFactory); + } + + public function testItAppliesTheFilenamePattern() + { + $this->mockDirectoryRead->expects($this->once()) + ->method('search') + ->with($this->matchesRegularExpression('#\*\.xml$#')) + ->willReturn([]); + + $this->fileResolver->get('*.xml', ''); + } +}