WordsTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Tests, that perform search of words, that signal of obsolete code
  8. */
  9. namespace Magento\Test\Legacy;
  10. use Magento\Framework\Component\ComponentRegistrar;
  11. class WordsTest extends \PHPUnit\Framework\TestCase
  12. {
  13. /**
  14. * @var \Magento\TestFramework\Inspection\WordsFinder
  15. */
  16. protected static $_wordsFinder;
  17. public static function setUpBeforeClass()
  18. {
  19. self::$_wordsFinder = new \Magento\TestFramework\Inspection\WordsFinder(
  20. glob(__DIR__ . '/_files/words_*.xml'),
  21. BP,
  22. new ComponentRegistrar()
  23. );
  24. }
  25. public function testWords()
  26. {
  27. $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
  28. $invoker(
  29. /**
  30. * @param string $file
  31. */
  32. function ($file) {
  33. $words = self::$_wordsFinder->findWords(realpath($file));
  34. if ($words) {
  35. $this->fail("Found words: '" . implode("', '", $words) . "' in '{$file}' file");
  36. }
  37. },
  38. \Magento\Framework\App\Utility\Files::init()->getAllFiles()
  39. );
  40. }
  41. }