Example #1
0
 /**
  * Load and save the existing tests/specs into the member variable.
  * Call this method first before using other methods of this class.
  *
  * @param \Box\TestScribe\Config\ConfigParams $inputParams
  * @param string $outSourceFileDir
  *
  * @return \Box\TestScribe\Spec\SpecsPerClass
  */
 public function loadExistingSpecs(ConfigParams $inputParams, $outSourceFileDir)
 {
     $specFilePath = StaticConfigHelper::computeSpecFilePath($inputParams->getPhpClassName(), $outSourceFileDir);
     $this->specFilePath = $specFilePath;
     $inFullClassName = $inputParams->getFullClassName();
     $this->specPerClass = $this->specPersistence->loadSpec($specFilePath, $inFullClassName);
     $this->methodName = $inputParams->getMethodName();
     return $this->specPerClass;
 }
 /**
  * @covers \Box\TestScribe\Config\StaticConfigHelper::computeSpecFilePath
  * @covers \Box\TestScribe\Config\StaticConfigHelper
  */
 public function test_computeSpecFilePath()
 {
     // Setup mocks for parameters to the method under test.
     /** @var \Box\TestScribe\ClassInfo\PhpClassName $mockPhpClassName */
     $mockPhpClassName = $this->shmock('\\Box\\TestScribe\\ClassInfo\\PhpClassName', function ($shmock) {
         $shmock->order_matters();
         $shmock->disable_original_constructor();
         /** @var $mock \Shmock\Spec */
         $mock = $shmock->getClassName();
         $mock->return_value('inClassName');
     });
     // Execute the method under test.
     $executionResult = \Box\TestScribe\Config\StaticConfigHelper::computeSpecFilePath($mockPhpClassName, 'out/source/path');
     // Validate the execution result.
     $expected = 'out/source/path/inClassName_ts.yaml';
     $this->assertSame($expected, $executionResult, 'Variable ( executionResult ) doesn\'t have the expected value.');
 }
 /**
  * @param \Box\TestScribe\Config\ConfigParams $inputParams
  * @param \Box\TestScribe\MethodInfo\Method $inMethod
  * @param \Box\TestScribe\Config\Options $options
  * @param \Box\TestScribe\Config\ConfigParams $outputParams
  */
 function __construct(ConfigParams $inputParams, Method $inMethod, Options $options, ConfigParams $outputParams)
 {
     $this->inPhpClassName = $inputParams->getPhpClassName();
     $this->inMethod = $inMethod;
     $this->inSourceFile = $inputParams->getSourceFile();
     $this->outPhpClassName = $outputParams->getPhpClassName();
     $this->outSourceFile = $outputParams->getSourceFile();
     $this->outMethodName = $outputParams->getMethodName();
     $this->overwriteExistingDestinationFile = $options->isOverwriteExistingDestinationFile();
     $this->testFileRoot = $options->getTestRootPath();
     $this->sourceFilePathRelativeToSourceRoot = $options->getSourceFilePathRelativeToSourceRoot();
     $this->generateSpec = $options->isGenerateSpec();
     $this->outSourcePath = $options->getOutSourceFileDir();
     $this->specFilePath = StaticConfigHelper::computeSpecFilePath($this->inPhpClassName, $this->outSourcePath);
     $this->options = $options;
 }