AbstractTestCase.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Abstract class for phrase testing
  8. */
  9. namespace Magento\Test\Integrity\Phrase;
  10. use Magento\Framework\Component\ComponentRegistrar;
  11. use Magento\Setup\Module\I18n\FilesCollector;
  12. class AbstractTestCase extends \PHPUnit\Framework\TestCase
  13. {
  14. /**
  15. * @param array $phrase
  16. * @return string
  17. */
  18. protected function _createPhraseError($phrase)
  19. {
  20. return "\nPhrase: {$phrase['phrase']} \nFile: {$phrase['file']} \nLine: {$phrase['line']}";
  21. }
  22. /**
  23. * @param array $phrase
  24. * @return string
  25. */
  26. protected function _createMissedPhraseError($phrase)
  27. {
  28. return "\nMissed Phrase: File: {$phrase['file']} \nLine: {$phrase['line']}";
  29. }
  30. /**
  31. * @return \RegexIterator
  32. */
  33. protected function _getFiles()
  34. {
  35. $filesCollector = new FilesCollector();
  36. $componentRegistrar = new ComponentRegistrar();
  37. $paths = array_merge(
  38. $componentRegistrar->getPaths(ComponentRegistrar::MODULE),
  39. $componentRegistrar->getPaths(ComponentRegistrar::LIBRARY)
  40. );
  41. return $filesCollector->getFiles(
  42. $paths,
  43. '/\.(php|phtml)$/'
  44. );
  45. }
  46. }