LibraryLocationTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Verify that there are no files in the old locations of web and php libraries
  8. */
  9. namespace Magento\Test\Legacy;
  10. class LibraryLocationTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * Root path of Magento
  14. *
  15. * @var string
  16. */
  17. protected static $root;
  18. public static function setUpBeforeClass()
  19. {
  20. self::$root = BP;
  21. }
  22. public function testOldWebLibrariesLocation()
  23. {
  24. $oldLocation = self::$root . '/pub/lib';
  25. $this->assertFileNotExists($oldLocation, "The web libraries have been moved from 'pub/lib' to 'lib/web'");
  26. }
  27. public function testOldPhpLibrariesLocation()
  28. {
  29. $libLocation = self::$root . '/lib';
  30. $permittedEntries = [
  31. self::$root . '/lib/web',
  32. self::$root . '/lib/internal',
  33. self::$root . '/.htaccess',
  34. ];
  35. $entries = glob("{$libLocation}/*");
  36. $excessiveEntries = [];
  37. foreach ($entries as $entry) {
  38. $entry = str_replace('\\', '/', $entry);
  39. $permitted = false;
  40. foreach ($permittedEntries as $permittedEntry) {
  41. if ($permittedEntry == $entry) {
  42. $permitted = true;
  43. break;
  44. }
  45. }
  46. if (!$permitted) {
  47. $excessiveEntries[] = $entry;
  48. }
  49. }
  50. $this->assertEmpty(
  51. $excessiveEntries,
  52. "All files and directories have been moved from 'lib' to 'lib/internal'"
  53. );
  54. }
  55. }