SignatureTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Scan source code for detects invocations of outdated __() method
  8. */
  9. namespace Magento\Test\Integrity\Phrase\Legacy;
  10. use Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer;
  11. use Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate\MethodCollector;
  12. class SignatureTest extends \Magento\Test\Integrity\Phrase\AbstractTestCase
  13. {
  14. /**
  15. * @var \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate\MethodCollector
  16. */
  17. protected $_phraseCollector;
  18. protected function setUp()
  19. {
  20. $this->_phraseCollector = new MethodCollector(
  21. new Tokenizer()
  22. );
  23. }
  24. public function testSignature()
  25. {
  26. $errors = [];
  27. foreach ($this->_getFiles() as $file) {
  28. $this->_phraseCollector->parse($file);
  29. foreach ($this->_phraseCollector->getPhrases() as $phrase) {
  30. $errors[] = $this->_createPhraseError($phrase);
  31. }
  32. }
  33. $this->assertEmpty(
  34. $errors,
  35. sprintf(
  36. '%d usages of the old translation method call were discovered: %s',
  37. count($errors),
  38. implode("\n\n", $errors)
  39. )
  40. );
  41. }
  42. }