Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
LibraryLocationTest.php
Go to the documentation of this file.
1 <?php
10 namespace Magento\Test\Legacy;
11 
12 class LibraryLocationTest extends \PHPUnit\Framework\TestCase
13 {
19  protected static $root;
20 
21  public static function setUpBeforeClass()
22  {
23  self::$root = BP;
24  }
25 
26  public function testOldWebLibrariesLocation()
27  {
28  $oldLocation = self::$root . '/pub/lib';
29  $this->assertFileNotExists($oldLocation, "The web libraries have been moved from 'pub/lib' to 'lib/web'");
30  }
31 
32  public function testOldPhpLibrariesLocation()
33  {
34  $libLocation = self::$root . '/lib';
35 
36  $permittedEntries = [
37  self::$root . '/lib/web',
38  self::$root . '/lib/internal',
39  self::$root . '/.htaccess',
40  ];
41 
42  $entries = glob("{$libLocation}/*");
43  $excessiveEntries = [];
44  foreach ($entries as $entry) {
45  $entry = str_replace('\\', '/', $entry);
46  $permitted = false;
47  foreach ($permittedEntries as $permittedEntry) {
48  if ($permittedEntry == $entry) {
49  $permitted = true;
50  break;
51  }
52  }
53  if (!$permitted) {
54  $excessiveEntries[] = $entry;
55  }
56  }
57 
58  $this->assertEmpty(
59  $excessiveEntries,
60  "All files and directories have been moved from 'lib' to 'lib/internal'"
61  );
62  }
63 }
const BP
Definition: autoload.php:14