Hướng dẫn phpunittextui defaultresultprinter cannot implement phpunittextuiresultprinter - phpunittextui defaultresultprinter không thể triển khai phpunittextuiresultprinter

/var/www/html $ bin/phpunit --filter ArraysTest
PHPUnit 8.5.2 by Sebastian Bergmann and contributors.

Testing Project Test Suite

                       App\Tests\Common\ArraysTest ...

Time: 216 ms, Memory: 8.00 MB

OK [3 tests, 6 assertions]

Other deprecation notices [1]

  1x: The "PHPUnit\TextUI\ResultPrinter" class is considered internal This class is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not use it from "DiabloMedia\PHPUnit\Printer\PrettyPrinter".

Có thể có lớp này là một phần của API công khai như được đề cập trong #3236 không?

Bất cứ khi nào tôi chạy các bài kiểm tra PHPUNIT từ phpstorm, tôi sẽ gặp lỗi. Tôi đã cung cấp thêm thông tin dưới đây. Tôi không chắc nơi tôi đã bỏ lỡ cấu hình thiết lập.

Thiết lập của tôi

  • Ubuntu
  • Phpstorm 8.0.1
  • PHPUNIT 4.3.4

Thêm thông tin:

Phpunit.phar nằm ở /usr/local/bin/phpunit.phar. Tôi đã thiết lập đường dẫn phpunit trực tiếp trong phpstorm. Các xét nghiệm chạy từ bash mà không có vấn đề. Tôi cũng đã thiết lập tệp cấu hình của mình phpunit.xml trong phpunit, nằm trong gốc của dự án của tôi. Tệp phpunit.xml yêu cầu PHPUNIT tải tệp trình soạn thảo autoload.php.

Đầu ra phpunit:

/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /tmp/ide-phpunit.php --configuration /home/mkelley/projects/CompanyName/phpunit.xml
Testing started at 10:33 AM ...
PHPUnit 4.3.4 by Sebastian Bergmann.

Configuration read from /home/mkelley/projects/CompanyName/phpunit.xml

PHP Fatal error:  Call to undefined method  CompanyNameTests\Boundaries\BoardMemberVotingBoundaryTest::hasExpectationOnOutput[] in phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/ResultPrinter.php on line 545
PHP Stack trace:
PHP   1. {main}[] /tmp/ide-phpunit.php:0
PHP   2. IDE_Base_PHPUnit_TextUI_Command::main[$exit = *uninitialized*] /tmp/ide-phpunit.php:500
PHP   3. PHPUnit_TextUI_Command->run[$argv = *uninitialized*, $exit = *uninitialized*] /tmp/ide-phpunit.php:243
PHP   4. PHPUnit_TextUI_TestRunner->doRun[$suite = *uninitialized*, $arguments = *uninitialized*] phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/Command.php:186
PHP   5. PHPUnit_Framework_TestSuite->run[$result = *uninitialized*] /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:423
PHP   6. PHPUnit_Framework_TestSuite->run[$result = *uninitialized*] /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP   7. PHPUnit_Framework_TestCase->run[$result = *uninitialized*] /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP   8. PHPUnit_Framework_TestResult->run[$test = *uninitialized*] /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestCase.php:771
PHP   9. PHPUnit_Framework_TestResult->endTest[$test = *uninitialized*, $time = *uninitialized*] /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestResult.php:760
PHP  10. PHPUnit_TextUI_ResultPrinter->endTest[$test = *uninitialized*, $time = *uninitialized*] /home/mkelley/projects/CompanyName/vendor/phpunit/phpunit/src/Framework/TestResult.php:378

Process finished with exit code 255

Tôi đã tìm kiếm Google và không thể tìm thấy một vấn đề tương tự. Tôi đánh giá cao bất kỳ sự giúp đỡ!

CHỈNH SỬA

Đây là tệp phpunit.xml của tôi. Phpstorm đang sử dụng điều này như một "tệp cấu hình thay thế"


    
    
        
            ./tests/
        
    

Drupal 9.3.xcommand.phpcommandCommand.phpCommand

Lệnh chức năng được bảo vệ :: HandleArgument

Cùng tên và không gian tên trong các nhánh khác

  1. 9.0.x Nhà cung cấp/Phpunit/Phpunit/SRC/TextUI/Command.php \ Phpunit \ TextUI \ Command :: HandLeargument []
  2. 9.1.x Nhà cung cấp/Phpunit/Phpunit/SRC/TextUI/Command.php \ Phpunit \ TextUI \ Command :: HandLeargument []
  3. 9.2.x Nhà cung cấp/phpunit/phpunit/src/textui/cal công
  4. 9.4.x Nhà cung cấp/phpunit/phpunit/src/textui/cress.php \ phpunit \ textui \ Command :: HandleArgument []
  5. 8.9.x Nhà cung cấp/phpunit/phpunit/src/textui/cal công
  6. 8.8.x Nhà cung cấp/Phpunit/Phpunit/SRC/TextUI/Command.php \ Phpunit \ TextUI \ Command :: HandleArgument []
  7. 10.0.x Nhà cung cấp/Phpunit/Phpunit/SRC/TextUI/Command.php \ Phpunit \ TextUI \ Command :: HandleArgument []

Xử lý các đối số dòng lệnh.

Một lớp con của lệnh phpunit \ textui \ có thể nối vào phân tích cú pháp đối số bằng cách thêm [es] vào mảng $ dài và trỏ đến phương thức gọi lại xử lý công tắc trong lớp con như thế này

LongOptions ['My-Switch'] = 'MyHandler'; // My-secondSwitch sẽ chấp nhận một giá trị-Lưu ý các dấu bằng $ this-> longOptions ['my-secondSwitch ='] = 'myotherHandler'; }

// - -my -switch -> myHandler [] Hàm được bảo vệ MyHandler [] {}

// - -my -secondswitch foo -> myotherhandler ['foo'] Chức năng được bảo vệ myotherhandler [$ value] {}

// Bạn cũng sẽ cần điều này - từ khóa tĩnh trong // phpunit \ textui \ lệnh sẽ có nghĩa là nó sẽ là // phpunit \ textui \ lệnh được khởi tạo, // không phải Đúng] {$ lệnh = mới tĩnh;

Trả về $ Command-> Run [$ _ Server ['argv'], $ exit]; }

}

Ném

Ngoại lệ

1 CALL ĐỂ Lệnh :: HandLeargument [] Lệnh :: Chạy trong Nhà cung cấp/Phpunit/Phpunit/SRC/TextUI/Command.php

Tập tin

Nhà cung cấp/phpunit/phpunit/src/textui/cress.php, dòng 308

Lớp

Commanda testrunner cho mô -đun Php SAPI của giao diện dòng lệnh [CLI].

Không gian tên

Phpunit \ textui

Mã số

protected function handleArguments[array $argv] : void {
  try {
    $this->options = Getopt::parse[$argv, 'd:c:hv', array_keys[$this->longOptions]];
  } catch [Exception $t] {
    $this
      ->exitWithErrorMessage[$t
      ->getMessage[]];
  }
  foreach [$this->options[0] as $option] {
    switch [$option[0]] {
      case '--colors':
        $this->arguments['colors'] = $option[1] ?: ResultPrinter::COLOR_AUTO;
        break;
      case '--bootstrap':
        $this->arguments['bootstrap'] = $option[1];
        break;
      case '--cache-result':
        $this->arguments['cacheResult'] = true;
        break;
      case '--do-not-cache-result':
        $this->arguments['cacheResult'] = false;
        break;
      case '--cache-result-file':
        $this->arguments['cacheResultFile'] = $option[1];
        break;
      case '--columns':
        if [is_numeric[$option[1]]] {
          $this->arguments['columns'] = [int] $option[1];
        }
        elseif [$option[1] === 'max'] {
          $this->arguments['columns'] = 'max';
        }
        break;
      case 'c':
      case '--configuration':
        $this->arguments['configuration'] = $option[1];
        break;
      case '--coverage-clover':
        $this->arguments['coverageClover'] = $option[1];
        break;
      case '--coverage-crap4j':
        $this->arguments['coverageCrap4J'] = $option[1];
        break;
      case '--coverage-html':
        $this->arguments['coverageHtml'] = $option[1];
        break;
      case '--coverage-php':
        $this->arguments['coveragePHP'] = $option[1];
        break;
      case '--coverage-text':
        if [$option[1] === null] {
          $option[1] = 'php://stdout';
        }
        $this->arguments['coverageText'] = $option[1];
        $this->arguments['coverageTextShowUncoveredFiles'] = false;
        $this->arguments['coverageTextShowOnlySummary'] = false;
        break;
      case '--coverage-xml':
        $this->arguments['coverageXml'] = $option[1];
        break;
      case 'd':
        $ini = explode['=', $option[1]];
        if [isset[$ini[0]]] {
          if [isset[$ini[1]]] {
            ini_set[$ini[0], $ini[1]];
          }
          else {
            ini_set[$ini[0], '1'];
          }
        }
        break;
      case '--debug':
        $this->arguments['debug'] = true;
        break;
      case 'h':
      case '--help':
        $this
          ->showHelp[];
        exit[TestRunner::SUCCESS_EXIT];
        break;
      case '--filter':
        $this->arguments['filter'] = $option[1];
        break;
      case '--testsuite':
        $this->arguments['testsuite'] = $option[1];
        break;
      case '--generate-configuration':
        $this
          ->printVersionString[];
        print 'Generating phpunit.xml in ' . getcwd[] . PHP_EOL . PHP_EOL;
        print 'Bootstrap script [relative to path shown above; default: vendor/autoload.php]: ';
        $bootstrapScript = trim[fgets[STDIN]];
        print 'Tests directory [relative to path shown above; default: tests]: ';
        $testsDirectory = trim[fgets[STDIN]];
        print 'Source directory [relative to path shown above; default: src]: ';
        $src = trim[fgets[STDIN]];
        if [$bootstrapScript === ''] {
          $bootstrapScript = 'vendor/autoload.php';
        }
        if [$testsDirectory === ''] {
          $testsDirectory = 'tests';
        }
        if [$src === ''] {
          $src = 'src';
        }
        $generator = new ConfigurationGenerator[];
        file_put_contents['phpunit.xml', $generator
          ->generateDefaultConfiguration[Version::series[], $bootstrapScript, $testsDirectory, $src]];
        print PHP_EOL . 'Generated phpunit.xml in ' . getcwd[] . PHP_EOL;
        exit[TestRunner::SUCCESS_EXIT];
        break;
      case '--group':
        $this->arguments['groups'] = explode[',', $option[1]];
        break;
      case '--exclude-group':
        $this->arguments['excludeGroups'] = explode[',', $option[1]];
        break;
      case '--test-suffix':
        $this->arguments['testSuffixes'] = explode[',', $option[1]];
        break;
      case '--include-path':
        $includePath = $option[1];
        break;
      case '--list-groups':
        $this->arguments['listGroups'] = true;
        break;
      case '--list-suites':
        $this->arguments['listSuites'] = true;
        break;
      case '--list-tests':
        $this->arguments['listTests'] = true;
        break;
      case '--list-tests-xml':
        $this->arguments['listTestsXml'] = $option[1];
        break;
      case '--printer':
        $this->arguments['printer'] = $option[1];
        break;
      case '--loader':
        $this->arguments['loader'] = $option[1];
        break;
      case '--log-junit':
        $this->arguments['junitLogfile'] = $option[1];
        break;
      case '--log-teamcity':
        $this->arguments['teamcityLogfile'] = $option[1];
        break;
      case '--order-by':
        $this
          ->handleOrderByOption[$option[1]];
        break;
      case '--process-isolation':
        $this->arguments['processIsolation'] = true;
        break;
      case '--repeat':
        $this->arguments['repeat'] = [int] $option[1];
        break;
      case '--stderr':
        $this->arguments['stderr'] = true;
        break;
      case '--stop-on-defect':
        $this->arguments['stopOnDefect'] = true;
        break;
      case '--stop-on-error':
        $this->arguments['stopOnError'] = true;
        break;
      case '--stop-on-failure':
        $this->arguments['stopOnFailure'] = true;
        break;
      case '--stop-on-warning':
        $this->arguments['stopOnWarning'] = true;
        break;
      case '--stop-on-incomplete':
        $this->arguments['stopOnIncomplete'] = true;
        break;
      case '--stop-on-risky':
        $this->arguments['stopOnRisky'] = true;
        break;
      case '--stop-on-skipped':
        $this->arguments['stopOnSkipped'] = true;
        break;
      case '--fail-on-warning':
        $this->arguments['failOnWarning'] = true;
        break;
      case '--fail-on-risky':
        $this->arguments['failOnRisky'] = true;
        break;
      case '--teamcity':
        $this->arguments['printer'] = TeamCity::class;
        break;
      case '--testdox':
        $this->arguments['printer'] = CliTestDoxPrinter::class;
        break;
      case '--testdox-group':
        $this->arguments['testdoxGroups'] = explode[',', $option[1]];
        break;
      case '--testdox-exclude-group':
        $this->arguments['testdoxExcludeGroups'] = explode[',', $option[1]];
        break;
      case '--testdox-html':
        $this->arguments['testdoxHTMLFile'] = $option[1];
        break;
      case '--testdox-text':
        $this->arguments['testdoxTextFile'] = $option[1];
        break;
      case '--testdox-xml':
        $this->arguments['testdoxXMLFile'] = $option[1];
        break;
      case '--no-configuration':
        $this->arguments['useDefaultConfiguration'] = false;
        break;
      case '--no-extensions':
        $this->arguments['noExtensions'] = true;
        break;
      case '--no-coverage':
        $this->arguments['noCoverage'] = true;
        break;
      case '--no-logging':
        $this->arguments['noLogging'] = true;
        break;
      case '--no-interaction':
        $this->arguments['noInteraction'] = true;
        break;
      case '--globals-backup':
        $this->arguments['backupGlobals'] = true;
        break;
      case '--static-backup':
        $this->arguments['backupStaticAttributes'] = true;
        break;
      case 'v':
      case '--verbose':
        $this->arguments['verbose'] = true;
        break;
      case '--atleast-version':
        if [version_compare[Version::id[], $option[1], '>=']] {
          exit[TestRunner::SUCCESS_EXIT];
        }
        exit[TestRunner::FAILURE_EXIT];
        break;
      case '--version':
        $this
          ->printVersionString[];
        exit[TestRunner::SUCCESS_EXIT];
        break;
      case '--dont-report-useless-tests':
        $this->arguments['reportUselessTests'] = false;
        break;
      case '--strict-coverage':
        $this->arguments['strictCoverage'] = true;
        break;
      case '--disable-coverage-ignore':
        $this->arguments['disableCodeCoverageIgnore'] = true;
        break;
      case '--strict-global-state':
        $this->arguments['beStrictAboutChangesToGlobalState'] = true;
        break;
      case '--disallow-test-output':
        $this->arguments['disallowTestOutput'] = true;
        break;
      case '--disallow-resource-usage':
        $this->arguments['beStrictAboutResourceUsageDuringSmallTests'] = true;
        break;
      case '--default-time-limit':
        $this->arguments['defaultTimeLimit'] = [int] $option[1];
        break;
      case '--enforce-time-limit':
        $this->arguments['enforceTimeLimit'] = true;
        break;
      case '--disallow-todo-tests':
        $this->arguments['disallowTodoAnnotatedTests'] = true;
        break;
      case '--reverse-list':
        $this->arguments['reverseList'] = true;
        break;
      case '--check-version':
        $this
          ->handleVersionCheck[];
        break;
      case '--whitelist':
        $this->arguments['whitelist'] = $option[1];
        break;
      case '--random-order':
        $this
          ->handleOrderByOption['random'];
        break;
      case '--random-order-seed':
        $this->arguments['randomOrderSeed'] = [int] $option[1];
        break;
      case '--resolve-dependencies':
        $this
          ->handleOrderByOption['depends'];
        break;
      case '--ignore-dependencies':
        $this
          ->handleOrderByOption['no-depends'];
        break;
      case '--reverse-order':
        $this
          ->handleOrderByOption['reverse'];
        break;
      case '--dump-xdebug-filter':
        $this->arguments['xdebugFilterFile'] = $option[1];
        break;
      default:
        $optionName = str_replace['--', '', $option[0]];
        $handler = null;
        if [isset[$this->longOptions[$optionName]]] {
          $handler = $this->longOptions[$optionName];
        }
        elseif [isset[$this->longOptions[$optionName . '=']]] {
          $handler = $this->longOptions[$optionName . '='];
        }
        if [isset[$handler] && is_callable[[
          $this,
          $handler,
        ]]] {
          $this
            ->{$handler}[$option[1]];
        }
    }
  }
  $this
    ->handleCustomTestSuite[];
  if [!isset[$this->arguments['testSuffixes']]] {
    $this->arguments['testSuffixes'] = [
      'Test.php',
      '.phpt',
    ];
  }
  if [isset[$this->options[1][0]] && substr[$this->options[1][0], -5, 5] !== '.phpt' && substr[$this->options[1][0], -4, 4] !== '.php' && substr[$this->options[1][0], -1, 1] !== '/' && !is_dir[$this->options[1][0]]] {
    $this->warnings[] = 'Invocation with class name is deprecated';
  }
  if [!isset[$this->arguments['test']]] {
    if [isset[$this->options[1][0]]] {
      $this->arguments['test'] = $this->options[1][0];
    }
    if [isset[$this->options[1][1]]] {
      $testFile = realpath[$this->options[1][1]];
      if [$testFile === false] {
        $this
          ->exitWithErrorMessage[sprintf['Cannot open file "%s".', $this->options[1][1]]];
      }
      $this->arguments['testFile'] = $testFile;
    }
    else {
      $this->arguments['testFile'] = '';
    }
    if [isset[$this->arguments['test']] && is_file[$this->arguments['test']] && strrpos[$this->arguments['test'], '.'] !== false && substr[$this->arguments['test'], -5, 5] !== '.phpt'] {
      $this->arguments['testFile'] = realpath[$this->arguments['test']];
      $this->arguments['test'] = substr[$this->arguments['test'], 0, strrpos[$this->arguments['test'], '.']];
    }
    if [isset[$this->arguments['test']] && is_string[$this->arguments['test']] && substr[$this->arguments['test'], -5, 5] === '.phpt'] {
      $suite = new TestSuite[];
      $suite
        ->addTestFile[$this->arguments['test']];
      $this->arguments['test'] = $suite;
    }
  }
  if [isset[$includePath]] {
    ini_set['include_path', $includePath . PATH_SEPARATOR . ini_get['include_path']];
  }
  if [$this->arguments['loader'] !== null] {
    $this->arguments['loader'] = $this
      ->handleLoader[$this->arguments['loader']];
  }
  if [isset[$this->arguments['configuration']] && is_dir[$this->arguments['configuration']]] {
    $configurationFile = $this->arguments['configuration'] . '/phpunit.xml';
    if [file_exists[$configurationFile]] {
      $this->arguments['configuration'] = realpath[$configurationFile];
    }
    elseif [file_exists[$configurationFile . '.dist']] {
      $this->arguments['configuration'] = realpath[$configurationFile . '.dist'];
    }
  }
  elseif [!isset[$this->arguments['configuration']] && $this->arguments['useDefaultConfiguration']] {
    if [file_exists['phpunit.xml']] {
      $this->arguments['configuration'] = realpath['phpunit.xml'];
    }
    elseif [file_exists['phpunit.xml.dist']] {
      $this->arguments['configuration'] = realpath['phpunit.xml.dist'];
    }
  }
  if [isset[$this->arguments['configuration']]] {
    try {
      $configuration = Configuration::getInstance[$this->arguments['configuration']];
    } catch [Throwable $t] {
      print $t
        ->getMessage[] . PHP_EOL;
      exit[TestRunner::FAILURE_EXIT];
    }
    $phpunitConfiguration = $configuration
      ->getPHPUnitConfiguration[];
    $configuration
      ->handlePHPConfiguration[];

    /*
     * Issue #1216
     */
    if [isset[$this->arguments['bootstrap']]] {
      $this
        ->handleBootstrap[$this->arguments['bootstrap']];
    }
    elseif [isset[$phpunitConfiguration['bootstrap']]] {
      $this
        ->handleBootstrap[$phpunitConfiguration['bootstrap']];
    }

    /*
     * Issue #657
     */
    if [isset[$phpunitConfiguration['stderr']] && !isset[$this->arguments['stderr']]] {
      $this->arguments['stderr'] = $phpunitConfiguration['stderr'];
    }
    if [isset[$phpunitConfiguration['extensionsDirectory']] && !isset[$this->arguments['noExtensions']] && extension_loaded['phar']] {
      $this
        ->handleExtensions[$phpunitConfiguration['extensionsDirectory']];
    }
    if [isset[$phpunitConfiguration['columns']] && !isset[$this->arguments['columns']]] {
      $this->arguments['columns'] = $phpunitConfiguration['columns'];
    }
    if [!isset[$this->arguments['printer']] && isset[$phpunitConfiguration['printerClass']]] {
      $file = $phpunitConfiguration['printerFile'] ?? '';
      $this->arguments['printer'] = $this
        ->handlePrinter[$phpunitConfiguration['printerClass'], $file];
    }
    if [isset[$phpunitConfiguration['testSuiteLoaderClass']]] {
      $file = $phpunitConfiguration['testSuiteLoaderFile'] ?? '';
      $this->arguments['loader'] = $this
        ->handleLoader[$phpunitConfiguration['testSuiteLoaderClass'], $file];
    }
    if [!isset[$this->arguments['testsuite']] && isset[$phpunitConfiguration['defaultTestSuite']]] {
      $this->arguments['testsuite'] = $phpunitConfiguration['defaultTestSuite'];
    }
    if [!isset[$this->arguments['test']]] {
      $testSuite = $configuration
        ->getTestSuiteConfiguration[$this->arguments['testsuite'] ?? ''];
      if [$testSuite !== null] {
        $this->arguments['test'] = $testSuite;
      }
    }
  }
  elseif [isset[$this->arguments['bootstrap']]] {
    $this
      ->handleBootstrap[$this->arguments['bootstrap']];
  }
  if [isset[$this->arguments['printer']] && is_string[$this->arguments['printer']]] {
    $this->arguments['printer'] = $this
      ->handlePrinter[$this->arguments['printer']];
  }
  if [!isset[$this->arguments['test']]] {
    $this
      ->showHelp[];
    exit[TestRunner::EXCEPTION_EXIT];
  }
}

Bài Viết Liên Quan

Chủ Đề