CodingStandardsIgnoreAnnotationUsageTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Test\Legacy;
  7. use PHPUnit\Framework\TestCase;
  8. use Magento\Framework\App\Utility\Files;
  9. class CodingStandardsIgnoreAnnotationUsageTest extends TestCase
  10. {
  11. public function testAnnotationUsage()
  12. {
  13. $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
  14. $invoker(
  15. function ($filename) {
  16. $fileText = file_get_contents($filename);
  17. if (strpos($fileText, '@codingStandardsIgnoreFile') !== false) {
  18. $this->fail(
  19. '@codingStandardsIgnoreFile annotation must be avoided. '
  20. . 'Use codingStandardsIgnoreStart/codingStandardsIgnoreEnd to suppress code fragment '
  21. . 'or use codingStandardsIgnoreLine to suppress line. '
  22. . $filename
  23. );
  24. }
  25. },
  26. Files::init()->getPhpFiles(
  27. Files::INCLUDE_APP_CODE
  28. | Files::INCLUDE_PUB_CODE
  29. | Files::INCLUDE_LIBS
  30. | Files::AS_DATA_SET
  31. | Files::INCLUDE_NON_CLASSES
  32. )
  33. );
  34. }
  35. }