Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TestPlacementTest.php
Go to the documentation of this file.
1 <?php
10 namespace Magento\Test\Integrity;
11 
13 use \Magento\Framework\App\Bootstrap;
14 
15 class TestPlacementTest extends \PHPUnit\Framework\TestCase
16 {
18  private $scanList = ['dev/tests/unit/testsuite/Magento'];
19 
23  private $root;
24 
25  protected function setUp()
26  {
27  $this->root = BP;
28  }
29 
30  public function testUnitTestFilesPlacement()
31  {
32  $objectManager = Bootstrap::create(BP, $_SERVER)->getObjectManager();
34  $filesystem = $objectManager->get(\Magento\Framework\Data\Collection\Filesystem::class);
35  $filesystem->setCollectDirs(false)
36  ->setCollectFiles(true)
37  ->setCollectRecursively(true);
38 
39  $targetsExist = false;
40  foreach ($this->scanList as $dir) {
41  if (realpath($this->root . DIRECTORY_SEPARATOR . $dir)) {
42  $filesystem->addTargetDir($this->root . DIRECTORY_SEPARATOR . $dir);
43  $targetsExist = true;
44  }
45  }
46 
47  if ($targetsExist) {
48  $files = $filesystem->load()->toArray();
49  $fileList = [];
50  foreach ($files['items'] as $file) {
51  $fileList[] = $file['filename'];
52  }
53 
54  $this->assertEquals(
55  0,
56  $files['totalRecords'],
57  "The following files have been found in obsolete test directories: \n"
58  . implode("\n", $fileList)
59  );
60  }
61  }
62 }
static create($rootDir, array $initParams, ObjectManagerFactory $factory=null)
Definition: Bootstrap.php:119
$objectManager
Definition: bootstrap.php:17
$fileList
Definition: export.php:13
const BP
Definition: autoload.php:14
$filesystem
foreach($appDirs as $dir) $files