/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configuration = InputHandler::handleInput($input);
     $suiteList = TestSuiteLoader::loadSuite($configuration);
     if (!count($suiteList)) {
         $output->writeln('No tests found to validate.');
         return 0;
     }
     $allValid = true;
     /** @var \PHPUnit_Framework_TestSuite $suite */
     foreach ($suiteList as $suite) {
         $testClass = $suite->getName();
         /** @var \PHPUnit_Framework_TestSuite $test */
         foreach ($suite as $test) {
             $testMethod = $test->getName();
             $isValid = Validator::isValidMethod($testClass, $testMethod);
             // Change exit code to 1 if invalid
             $allValid = $allValid && $isValid;
             $validityText = $isValid ? 'Valid' : 'Invalid';
             $output->writeln($validityText . ' - ' . $testClass . '::' . $testMethod);
         }
     }
     // Return exit code 1 if any of the tags are invalid
     // otherwise return exit code 0
     return (int) (!$allValid);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln($this->getApplication()->getLongVersion());
     $configuration = InputHandler::handleInput($input);
     if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
         $output->writeln(PHP_EOL . sprintf('Configuration file loaded: %s', $configuration->getFilename()));
     }
     $suiteList = TestSuiteLoader::loadSuite($configuration);
     if (!count($suiteList)) {
         $output->writeln(PHP_EOL . 'No tests found to validate.');
         return 0;
     }
     $failedCount = 0;
     $suiteIterator = new \RecursiveIteratorIterator($suiteList);
     /** @var \PHPUnit_Framework_TestCase $suite */
     foreach ($suiteIterator as $suite) {
         if ($suite instanceof \PHPUnit_Framework_Warning) {
             continue;
         }
         $testClass = get_class($suite);
         $testMethod = $suite->getName();
         $testSignature = $testClass . '::' . $testMethod;
         if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) {
             $this->writeValidity($output, 'Validating ' . $testSignature . '...');
         }
         $isValid = Validator::isValidMethod($testClass, $testMethod);
         if (!$isValid) {
             $failedCount++;
             $this->writeValidity($output, $testSignature, false);
         } elseif ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
             $this->writeValidity($output, $testSignature, true);
         }
     }
     $output->writeln('');
     if ($failedCount > 0) {
         $output->writeln("There were {$failedCount} test(s) with invalid @covers tags.");
         return 1;
     }
     $output->writeln('Validation complete. All @covers tags are valid.');
     return 0;
 }
 /**
  * @covers OckCyp\CoversValidator\Validator\Validator::isValidMethod
  */
 public function testReturnsTrueForExistingClassBeingCovered()
 {
     $this->assertTrue(Validator::isValidMethod($this->getFixtureClassName('OneTestCoveringExistingClassTest'), 'testDummyTest'));
 }