/**
  * Get the history file path.
  *
  * @return string
  */
 public function getHistoryFile()
 {
     $historyFilePathRoot = $this->testFileRoot . DIRECTORY_SEPARATOR . 'test_generator' . DIRECTORY_SEPARATOR . 'history';
     $historyFilePath = PathUtil::getPathUnderRoot($historyFilePathRoot, $this->sourceFilePathRelativeToSourceRoot);
     $inClassName = $this->inPhpClassName->getClassName();
     $historyFilePath .= DIRECTORY_SEPARATOR . $inClassName . '.yaml';
     return $historyFilePath;
 }
 /**
  * @param string $className
  * @param bool   $isStatic
  * @param string $nameOfTheMethodToPassThrough
  *   If not empty string, it tells this instance to pass calls to
  *   this method to the real object of the class being mocked
  *   and continue to mock other methods.
  *   If it is empty, it tells this instance to mock all methods.
  *
  * @return \Box\TestScribe\Mock\MockClass
  * @throws \DI\NotFoundException
  */
 public function create($className, $isStatic, $nameOfTheMethodToPassThrough)
 {
     $phpClassName = new PhpClassName($className);
     $simpleClassName = $phpClassName->getClassName();
     $mockObjectName = $this->mockObjectNameMgr->getMockObjectName($simpleClassName);
     $phpClass = new PhpClass($phpClassName);
     $mock = new MockClass($this->mockClassService, $phpClass, $isStatic, $nameOfTheMethodToPassThrough, $mockObjectName);
     $this->mockMgr->addMock($mock);
     return $mock;
 }
Esempio n. 3
0
 /**
  * @param \Box\TestScribe\Config\Options $options
  * @param \Box\TestScribe\Config\ConfigParams $inputParams
  *
  * @return \Box\TestScribe\Config\ConfigParams
  */
 public function getOutputParams(Options $options, ConfigParams $inputParams)
 {
     $inFullClassName = $inputParams->getFullClassName();
     $outFullClassName = $inFullClassName . 'GenTest';
     $outPhpClassName = new PhpClassName($outFullClassName);
     $outSimpleClassName = $outPhpClassName->getClassName();
     $outSourceFileDir = $options->getOutSourceFileDir();
     $outSourceFilePath = $outSourceFileDir . DIRECTORY_SEPARATOR . $outSimpleClassName . '.php';
     $overwriteExistingDestinationFile = $options->isOverwriteExistingDestinationFile();
     $methodName = $inputParams->getMethodName();
     $specPerClass = $this->savedSpecs->loadExistingSpecs($inputParams, $outSourceFileDir);
     $outTestMethodName = $this->outputTestNameGetter->getTestName($methodName, $overwriteExistingDestinationFile, $specPerClass);
     $outputParams = new ConfigParams($outSourceFilePath, $outPhpClassName, $outTestMethodName);
     return $outputParams;
 }
    /**
     * @param PhpClassName $outPhpClassName
     *
     * @return string
     */
    public function renderClassHeader(PhpClassName $outPhpClassName)
    {
        $classNamespace = $outPhpClassName->getNameSpace();
        if ($classNamespace != '') {
            $namespaceStatement = "namespace {$classNamespace};";
        } else {
            $namespaceStatement = '';
        }
        $testClassName = $outPhpClassName->getClassName();
        $testBaseClassName = $this->globalComputedConfig->getTestBaseClassName();
        $headerStatements = <<<TAG
<?php
{$namespaceStatement}

/**
 * Generated by TestScribe.
 */
class {$testClassName} extends {$testBaseClassName}

TAG;
        return $headerStatements;
    }
 /**
  * @param \Box\TestScribe\ClassInfo\PhpClassName $inPhpClassName
  * @param string $outSourcePath
  *
  * @return string
  */
 public static function computeSpecFilePath(PhpClassName $inPhpClassName, $outSourcePath)
 {
     $inClassName = $inPhpClassName->getClassName();
     $specFilePath = $outSourcePath . DIRECTORY_SEPARATOR . $inClassName . '_ts.yaml';
     return $specFilePath;
 }
Esempio n. 6
0
 /**
  * @return string
  */
 public function getClassName()
 {
     $simpleName = $this->phpClassName->getClassName();
     return $simpleName;
 }