17 private $directoryList;
22 private $writeInterface;
31 $this->directoryList =
33 $writeFactory = $this->createMock(\
Magento\Framework\
Filesystem\Directory\WriteFactory::class);
34 $this->writeInterface = $this->getMockBuilder(\
Magento\Framework\
Filesystem\Directory\WriteInterface::class)
35 ->setMethods([
'getPath',
'delete'])
36 ->getMockForAbstractClass();
37 $writeFactory->expects($this->once())->method(
'create')->willReturn($this->writeInterface);
38 $this->model =
new GeneratedFiles($this->directoryList, $writeFactory);
51 ->expects($this->any())
58 $this->directoryList->expects($this->any())->method(
'getPath')->willReturnMap($getPathMap);
59 $this->writeInterface->expects($this->any())->method(
'getRelativePath')->willReturnMap($getPathMap);
60 $this->writeInterface->expects($this->any())->method(
'isDirectory')->willReturnMap($isDirectoryMap);
61 $this->writeInterface->expects($this->exactly(1))->method(
'delete')->willReturnMap($deleteMap);
62 $this->model->cleanGeneratedFiles();
70 $pathToGeneration =
'path/to/generation';
71 $pathToDi =
'path/to/di';
72 $pathToCache =
'path/to/di';
73 $pathToConfig =
'path/to/config';
82 $deleteMap = [[
BP .
'/' . $pathToGeneration,
true],
83 [
BP .
'/' . $pathToDi,
true],
88 'runAll' => [ $getPathMap, [[
BP .
'/' . $pathToGeneration,
true],
89 [
BP .
'/' . $pathToDi,
true]], $deleteMap ],
90 'noDIfolder' => [ $getPathMap, [[
BP .
'/' . $pathToGeneration,
true],
91 [
BP .
'/' . $pathToDi,
false]], $deleteMap],
92 'noGenerationfolder' => [$getPathMap, [[
BP .
'/' . $pathToGeneration,
false],
93 [
BP .
'/' . $pathToDi,
true]], $deleteMap],
94 'nofolders' => [ $getPathMap, [[
BP .
'/' . $pathToGeneration,
false],
95 [
BP .
'/' . $pathToDi,
false]], $deleteMap],
101 $this->writeInterface
102 ->expects($this->once())
106 $this->directoryList->expects($this->never())->method(
'getPath');
107 $this->writeInterface->expects($this->never())->method(
'getPath');
108 $this->writeInterface->expects($this->never())->method(
'delete');
109 $this->model->cleanGeneratedFiles();
114 $this->writeInterface->expects($this->once())->method(
"touch");
115 $this->model->requestRegeneration();
cleanGeneratedFilesDataProvider()
testRequestRegeneration()
testCleanGeneratedFilesWithNoFlag()
testCleanGeneratedFiles($getPathMap, $isDirectoryMap, $deleteMap)