Skip to content

Commit 5cb5b9c

Browse files
committed
Merge remote-tracking branch 'github/develop' into public-pulls
2 parents e8fd092 + 313019d commit 5cb5b9c

File tree

5 files changed

+76
-15
lines changed

5 files changed

+76
-15
lines changed

app/code/Magento/Ui/DataProvider/Config/FileResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function get($filename, $scope)
4646
{
4747
$iterator = $this->iteratorFactory->create(
4848
$this->directoryRead,
49-
$this->directoryRead->search('/*/*/etc/data_source/*')
49+
$this->directoryRead->search('/*/*/etc/data_source/' . $filename)
5050
);
5151
return $iterator;
5252
}

dev/shell/cache.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@
1515

1616
$usage = 'Usage: php -f cache.php -- [--' . ManagerApp::KEY_SET . '=1|0]'
1717
. ' [--' . ManagerApp::KEY_CLEAN . ']'
18+
. ' [--' . ManagerApp::KEY_STATUS . ']'
1819
. ' [--' . ManagerApp::KEY_FLUSH . ']'
1920
. ' [--' . ManagerApp::KEY_TYPES . '=<type1>,<type2>,...]'
2021
. ' [--bootstrap=' . escapeshellarg('INIT_PARAM=foo&ANOTHER_PARAM[key]=bar') . ']
2122
--' . ManagerApp::KEY_TYPES . ' - list of cache types, comma-separated. If omitted, all caches will be affected
2223
--' . ManagerApp::KEY_SET . ' - enable or disable the specified cache types
2324
--' . ManagerApp::KEY_CLEAN . ' - clean data of the specified cache types
25+
--' . ManagerApp::KEY_STATUS . ' - display current status for each cache type
2426
--' . ManagerApp::KEY_FLUSH . ' - destroy all data in storage that the specified cache types reside on
2527
--bootstrap - add or override parameters of the bootstrap' . PHP_EOL;
2628
$longOpts = [
2729
ManagerApp::KEY_SET . '::',
2830
ManagerApp::KEY_CLEAN,
31+
ManagerApp::KEY_STATUS,
2932
ManagerApp::KEY_FLUSH,
3033
ManagerApp::KEY_TYPES . '::',
3134
'bootstrap::',

dev/tests/unit/testsuite/Magento/Framework/App/Cache/ManagerAppTest.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ protected function setUp()
3232

3333
public function testLaunchStatus()
3434
{
35+
$requestArgs = [
36+
ManagerApp::KEY_STATUS => true
37+
];
38+
3539
$this->response->expects($this->once())
3640
->method('setBody')
3741
->with(
3842
$this->matches("Current status:%afoo: 1%abar: 1%abaz: 0")
3943
);
4044

41-
$model = new ManagerApp($this->cacheManager, $this->response, []);
45+
$model = new ManagerApp($this->cacheManager, $this->response, $requestArgs);
4246
$model->launch();
4347
}
4448

@@ -58,7 +62,7 @@ public function testLaunchEnable()
5862
$this->response->expects($this->once())
5963
->method('setBody')
6064
->with(
61-
$this->matches("Changed cache status:%abaz: 0 -> 1%aCleaned cache types: baz%a")
65+
$this->matches("Changed cache status:\n%abaz: 0 -> 1\nCleaned cache types:\nbaz")
6266
);
6367

6468
$model = new ManagerApp($this->cacheManager, $this->response, $requestArgs);
@@ -80,7 +84,7 @@ public function testLaunchDisable()
8084
$this->response->expects($this->once())
8185
->method('setBody')
8286
->with(
83-
$this->matches("Changed cache status:%abaz: 1 -> 0%a%a")
87+
$this->matches("Changed cache status:\n%abaz: 1 -> 0\n")
8488
);
8589

8690
$model = new ManagerApp($this->cacheManager, $this->response, $requestArgs);
@@ -103,7 +107,7 @@ public function testLaunchFlush()
103107
$this->response->expects($this->once())
104108
->method('setBody')
105109
->with(
106-
$this->matches("Flushed cache types: foo, bar%a")
110+
$this->matches("Flushed cache types:\nfoo\nbar")
107111
);
108112

109113
$model = new ManagerApp($this->cacheManager, $this->response, $requestArgs);
@@ -126,7 +130,7 @@ public function testLaunchClean()
126130
$this->response->expects($this->once())
127131
->method('setBody')
128132
->with(
129-
$this->matches("Cleaned cache types: foo, bar%a")
133+
$this->matches("Cleaned cache types:\nfoo\nbar")
130134
);
131135

132136
$model = new ManagerApp($this->cacheManager, $this->response, $requestArgs);
@@ -152,7 +156,7 @@ public function testLaunchSetAndClean()
152156
$this->response->expects($this->once())
153157
->method('setBody')
154158
->with(
155-
$this->matches("Changed cache status:%afoo: 0 -> 1%aCleaned cache types: foo, bar%a")
159+
$this->matches("Changed cache status:\n%afoo: 0 -> 1\nCleaned cache types:\nfoo\nbar")
156160
);
157161

158162
$model = new ManagerApp($this->cacheManager, $this->response, $requestArgs);
@@ -179,7 +183,7 @@ public function testLaunchAll()
179183
$this->response->expects($this->once())
180184
->method('setBody')
181185
->with(
182-
$this->matches("Changed cache status:%abaz: 0 -> 1%aFlushed cache types: foo, baz%a")
186+
$this->matches("Changed cache status:\n%abaz: 0 -> 1%aFlushed cache types:\nfoo\nbaz")
183187
);
184188

185189
$model = new ManagerApp($this->cacheManager, $this->response, $requestArgs);
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace Magento\Ui\DataProvider\Config;
4+
5+
use Magento\Framework\Filesystem;
6+
use Magento\Ui\DataProvider\Config\FileResolver;
7+
use Magento\Framework\Config\FileIteratorFactory;
8+
9+
class FileResolverTest extends \PHPUnit_Framework_TestCase
10+
{
11+
/**
12+
* @var \Magento\Framework\Filesystem\Directory\Read | \PHPUnit_Framework_MockObject_MockObject
13+
*/
14+
private $mockDirectoryRead;
15+
16+
/**
17+
* @var FileResolver
18+
*/
19+
private $fileResolver;
20+
21+
public function setUp()
22+
{
23+
$this->mockDirectoryRead = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\Read')
24+
->disableOriginalConstructor()
25+
->getMock();
26+
$stubFileIteratorFactory = $this->getMockBuilder('Magento\Framework\Config\FileIteratorFactory')
27+
->disableOriginalConstructor()
28+
->getMock();
29+
$stubFilesystem = $this->getMockBuilder('Magento\Framework\Filesystem')
30+
->disableOriginalConstructor()
31+
->getMock();
32+
$stubFilesystem->expects($this->any())
33+
->method('getDirectoryRead')
34+
->willReturn($this->mockDirectoryRead);
35+
$this->fileResolver = new FileResolver($stubFilesystem, $stubFileIteratorFactory);
36+
}
37+
38+
public function testItAppliesTheFilenamePattern()
39+
{
40+
$this->mockDirectoryRead->expects($this->once())
41+
->method('search')
42+
->with($this->matchesRegularExpression('#\*\.xml$#'))
43+
->willReturn([]);
44+
45+
$this->fileResolver->get('*.xml', '');
46+
}
47+
}

lib/internal/Magento/Framework/App/Cache/ManagerApp.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ManagerApp implements AppInterface
2222
const KEY_SET = 'set';
2323
const KEY_CLEAN = 'clean';
2424
const KEY_FLUSH = 'flush';
25+
const KEY_STATUS = 'status';
2526
/**#@- */
2627

2728
/**
@@ -89,18 +90,24 @@ public function launch()
8990
}
9091
if (isset($this->requestArgs[self::KEY_FLUSH])) {
9192
$this->cacheManager->flush($types);
92-
$output[] = 'Flushed cache types: ' . join(', ', $types);
93+
$output[] = 'Flushed cache types:';
94+
$output[] = join("\n", $types);
9395
} elseif (isset($this->requestArgs[self::KEY_CLEAN])) {
9496
$this->cacheManager->clean($types);
95-
$output[] = 'Cleaned cache types: ' . join(', ', $types);
97+
$output[] = 'Cleaned cache types:';
98+
$output[] = join("\n", $types);
99+
} elseif (isset($this->requestArgs[self::KEY_STATUS])) {
100+
$output[] = 'Current status:';
101+
foreach ($this->cacheManager->getStatus() as $cache => $status) {
102+
$output[] = sprintf('%30s: %d', $cache, $status);
103+
}
96104
} elseif (!empty($enabledTypes)) {
97105
$this->cacheManager->clean($enabledTypes);
98-
$output[] = 'Cleaned cache types: ' . join(', ', $enabledTypes);
99-
}
100-
$output[] = 'Current status:';
101-
foreach ($this->cacheManager->getStatus() as $cache => $status) {
102-
$output[] = sprintf('%30s: %d', $cache, $status);
106+
$output[] = 'Cleaned cache types:';
107+
$output[] = join("\n", $enabledTypes);
103108
}
109+
110+
$output[] = '';
104111
$this->response->setBody(join("\n", $output));
105112
return $this->response;
106113
}

0 commit comments

Comments
 (0)