Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ExcludeFilterTest.php
Go to the documentation of this file.
1 <?php
8 
10 
14 class ExcludeFilterTest extends \PHPUnit\Framework\TestCase
15 {
19  protected $iterator;
20 
21  protected function setUp()
22  {
23  $this->iterator = $this->getFilesIterator();
24  }
25 
26  public function testExclusion()
27  {
29  $this->iterator,
30  [
31  BP . '/var/session/'
32  ]
33  );
34 
35  foreach ($iterator as $i) {
36  $result[] = $i;
37  }
38 
39  $this->assertTrue(!in_array(BP . '/var/session/', $result), 'Filtered path should not be in array');
40  }
41 
45  private function getFilesIterator()
46  {
47  $files = [
48  BP . '/var/',
49  BP . '/var/session/',
50  BP . '/var/cache/'
51  ];
52 
53  foreach ($files as $file) {
54  $item = $this->getMockBuilder(
55  \SplFileInfoClass::class
56  )->setMethods(['__toString', 'getFilename'])->getMock();
57  $item->expects($this->any())->method('__toString')->willReturn($file);
58  $item->expects($this->any())->method('getFilename')->willReturn('notDots');
59  yield $item;
60  }
61  }
62 }
const BP
Definition: autoload.php:14
$i
Definition: gallery.phtml:31
foreach($appDirs as $dir) $files