diff --git a/app/code/Magento/Ui/DataProvider/Config/FileResolver.php b/app/code/Magento/Ui/DataProvider/Config/FileResolver.php index fd643d2cac32d..fbd093b8c1acd 100644 --- a/app/code/Magento/Ui/DataProvider/Config/FileResolver.php +++ b/app/code/Magento/Ui/DataProvider/Config/FileResolver.php @@ -46,7 +46,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/shell/cache.php b/dev/shell/cache.php index 4aebbda7a1121..9c44a5914daa6 100644 --- a/dev/shell/cache.php +++ b/dev/shell/cache.php @@ -15,17 +15,20 @@ $usage = 'Usage: php -f cache.php -- [--' . ManagerApp::KEY_SET . '=1|0]' . ' [--' . ManagerApp::KEY_CLEAN . ']' + . ' [--' . ManagerApp::KEY_STATUS . ']' . ' [--' . ManagerApp::KEY_FLUSH . ']' . ' [--' . ManagerApp::KEY_TYPES . '=,,...]' . ' [--bootstrap=' . escapeshellarg('INIT_PARAM=foo&ANOTHER_PARAM[key]=bar') . '] --' . ManagerApp::KEY_TYPES . ' - list of cache types, comma-separated. If omitted, all caches will be affected --' . ManagerApp::KEY_SET . ' - enable or disable the specified cache types --' . ManagerApp::KEY_CLEAN . ' - clean data of the specified cache types + --' . ManagerApp::KEY_STATUS . ' - display current status for each cache type --' . ManagerApp::KEY_FLUSH . ' - destroy all data in storage that the specified cache types reside on --bootstrap - add or override parameters of the bootstrap' . PHP_EOL; $longOpts = [ ManagerApp::KEY_SET . '::', ManagerApp::KEY_CLEAN, + ManagerApp::KEY_STATUS, ManagerApp::KEY_FLUSH, ManagerApp::KEY_TYPES . '::', 'bootstrap::', diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Cache/ManagerAppTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Cache/ManagerAppTest.php index 0fb3c1c84d2a9..e382ad0ebc5ff 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Cache/ManagerAppTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Cache/ManagerAppTest.php @@ -32,13 +32,17 @@ protected function setUp() public function testLaunchStatus() { + $requestArgs = [ + ManagerApp::KEY_STATUS => true + ]; + $this->response->expects($this->once()) ->method('setBody') ->with( $this->matches("Current status:%afoo: 1%abar: 1%abaz: 0") ); - $model = new ManagerApp($this->cacheManager, $this->response, []); + $model = new ManagerApp($this->cacheManager, $this->response, $requestArgs); $model->launch(); } @@ -58,7 +62,7 @@ public function testLaunchEnable() $this->response->expects($this->once()) ->method('setBody') ->with( - $this->matches("Changed cache status:%abaz: 0 -> 1%aCleaned cache types: baz%a") + $this->matches("Changed cache status:\n%abaz: 0 -> 1\nCleaned cache types:\nbaz") ); $model = new ManagerApp($this->cacheManager, $this->response, $requestArgs); @@ -80,7 +84,7 @@ public function testLaunchDisable() $this->response->expects($this->once()) ->method('setBody') ->with( - $this->matches("Changed cache status:%abaz: 1 -> 0%a%a") + $this->matches("Changed cache status:\n%abaz: 1 -> 0\n") ); $model = new ManagerApp($this->cacheManager, $this->response, $requestArgs); @@ -103,7 +107,7 @@ public function testLaunchFlush() $this->response->expects($this->once()) ->method('setBody') ->with( - $this->matches("Flushed cache types: foo, bar%a") + $this->matches("Flushed cache types:\nfoo\nbar") ); $model = new ManagerApp($this->cacheManager, $this->response, $requestArgs); @@ -126,7 +130,7 @@ public function testLaunchClean() $this->response->expects($this->once()) ->method('setBody') ->with( - $this->matches("Cleaned cache types: foo, bar%a") + $this->matches("Cleaned cache types:\nfoo\nbar") ); $model = new ManagerApp($this->cacheManager, $this->response, $requestArgs); @@ -152,7 +156,7 @@ public function testLaunchSetAndClean() $this->response->expects($this->once()) ->method('setBody') ->with( - $this->matches("Changed cache status:%afoo: 0 -> 1%aCleaned cache types: foo, bar%a") + $this->matches("Changed cache status:\n%afoo: 0 -> 1\nCleaned cache types:\nfoo\nbar") ); $model = new ManagerApp($this->cacheManager, $this->response, $requestArgs); @@ -179,7 +183,7 @@ public function testLaunchAll() $this->response->expects($this->once()) ->method('setBody') ->with( - $this->matches("Changed cache status:%abaz: 0 -> 1%aFlushed cache types: foo, baz%a") + $this->matches("Changed cache status:\n%abaz: 0 -> 1%aFlushed cache types:\nfoo\nbaz") ); $model = new ManagerApp($this->cacheManager, $this->response, $requestArgs); 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', ''); + } +} diff --git a/lib/internal/Magento/Framework/App/Cache/ManagerApp.php b/lib/internal/Magento/Framework/App/Cache/ManagerApp.php index 19ec0976a14ca..3733c630f4987 100644 --- a/lib/internal/Magento/Framework/App/Cache/ManagerApp.php +++ b/lib/internal/Magento/Framework/App/Cache/ManagerApp.php @@ -22,6 +22,7 @@ class ManagerApp implements AppInterface const KEY_SET = 'set'; const KEY_CLEAN = 'clean'; const KEY_FLUSH = 'flush'; + const KEY_STATUS = 'status'; /**#@- */ /** @@ -89,18 +90,24 @@ public function launch() } if (isset($this->requestArgs[self::KEY_FLUSH])) { $this->cacheManager->flush($types); - $output[] = 'Flushed cache types: ' . join(', ', $types); + $output[] = 'Flushed cache types:'; + $output[] = join("\n", $types); } elseif (isset($this->requestArgs[self::KEY_CLEAN])) { $this->cacheManager->clean($types); - $output[] = 'Cleaned cache types: ' . join(', ', $types); + $output[] = 'Cleaned cache types:'; + $output[] = join("\n", $types); + } elseif (isset($this->requestArgs[self::KEY_STATUS])) { + $output[] = 'Current status:'; + foreach ($this->cacheManager->getStatus() as $cache => $status) { + $output[] = sprintf('%30s: %d', $cache, $status); + } } elseif (!empty($enabledTypes)) { $this->cacheManager->clean($enabledTypes); - $output[] = 'Cleaned cache types: ' . join(', ', $enabledTypes); - } - $output[] = 'Current status:'; - foreach ($this->cacheManager->getStatus() as $cache => $status) { - $output[] = sprintf('%30s: %d', $cache, $status); + $output[] = 'Cleaned cache types:'; + $output[] = join("\n", $enabledTypes); } + + $output[] = ''; $this->response->setBody(join("\n", $output)); return $this->response; }