Skip to content

Commit

Permalink
Merge pull request #968 from Vinai/ui-dataprovider-config-fileresolver
Browse files Browse the repository at this point in the history
Apply pattern matching datasource config files
  • Loading branch information
vpelipenko committed Jan 15, 2015
2 parents 6cd1721 + 181be0d commit 313019d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/code/Magento/Ui/DataProvider/Config/FileResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Magento\Ui\DataProvider\Config;

use Magento\Framework\Filesystem;
use Magento\Ui\DataProvider\Config\FileResolver;
use Magento\Framework\Config\FileIteratorFactory;

class FileResolverTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\Framework\Filesystem\Directory\Read | \PHPUnit_Framework_MockObject_MockObject
*/
private $mockDirectoryRead;

/**
* @var FileResolver
*/
private $fileResolver;

public function setUp()
{
$this->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', '');
}
}

0 comments on commit 313019d

Please sign in to comment.