/**
  * Get the name of the test to create.
  * Method has to begin with 'test'
  *
  * @param string $methodName
  * @param bool $useDefaultTestMethodName
  * @param \Box\TestScribe\Spec\SpecsPerClass $specPerClass
  *
  * @return string
  */
 public function getTestName($methodName, $useDefaultTestMethodName, SpecsPerClass $specPerClass)
 {
     $specsPerMethod = $specPerClass->getSpecsPerMethodByName($methodName);
     $specs = $specsPerMethod->getSpecs();
     if ($specs) {
         $existingTestNames = array_keys($specs);
         $testMethodName = $this->testNameSelector->selectTestName($existingTestNames);
         if ($testMethodName !== '') {
             $msg = "Updating existing test ( {$testMethodName} ).";
             $this->output->writeln($msg);
             return $testMethodName;
         }
     }
     $testMethodNamePart = $methodName;
     if (!$useDefaultTestMethodName) {
         $message = "\nEnter the name of the test. It will be prefixed with 'test_'\n" . "Press enter to use the method name ( {$methodName} ) as the default.";
         $this->output->writeln($message);
         // rawInput is used instead of InputWithHelp so that
         // users don't have to quote the name as instructed by the help.
         $input = $this->rawInputWithPrompt->getString();
         if ($input !== '') {
             $testMethodNamePart = $input;
         }
     }
     $testMethodName = "test_{$testMethodNamePart}";
     return $testMethodName;
 }
예제 #2
0
 /**
  * @return \Box\TestScribe\Spec\SpecsPerMethod
  */
 public function getSpecsPerMethod()
 {
     $specsPerMethod = $this->specPerClass->getSpecsPerMethodByName($this->methodName);
     return $specsPerMethod;
 }