LicenseTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Tests to ensure that all license blocks are represented by placeholders
  8. */
  9. namespace Magento\Test\Legacy;
  10. class LicenseTest extends \PHPUnit\Framework\TestCase
  11. {
  12. public function testLegacyComment()
  13. {
  14. $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
  15. $invoker(
  16. function ($filename) {
  17. $fileText = file_get_contents($filename);
  18. if (!preg_match_all('#/\*\*.+@copyright.+?\*/#s', $fileText, $matches)) {
  19. return;
  20. }
  21. foreach ($matches[0] as $commentText) {
  22. foreach (['Irubin Consulting Inc', 'DBA Varien', 'Magento Inc'] as $legacyText) {
  23. $this->assertNotContains(
  24. $legacyText,
  25. $commentText,
  26. "The license of file {$filename} contains legacy text."
  27. );
  28. }
  29. }
  30. },
  31. $this->legacyCommentDataProvider()
  32. );
  33. }
  34. public function legacyCommentDataProvider()
  35. {
  36. $allFiles = \Magento\Framework\App\Utility\Files::init()->getAllFiles();
  37. $result = [];
  38. foreach ($allFiles as $file) {
  39. if (!file_exists($file[0]) || !is_readable($file[0])) {
  40. continue;
  41. }
  42. $result[] = [$file[0]];
  43. }
  44. return $result;
  45. }
  46. }