/** * @covers \Box\TestScribe\Config\PathUtil::getPathUnderRoot * @covers \Box\TestScribe\Config\PathUtil */ public function test_getPathUnderRoot_empty_relative_path() { // Execute the method under test. $executionResult = \Box\TestScribe\Config\PathUtil::getPathUnderRoot('root', ''); // Validate the execution result. $expected = 'root'; $this->assertSame($expected, $executionResult, 'Variable ( executionResult ) doesn\'t have the expected value.'); }
/** * @param \Symfony\Component\Console\Input\InputInterface $input * @param string $inSourceFile * * @return \Box\TestScribe\Config\Options */ public function getOptions(InputInterface $input, $inSourceFile) { $configFilePath = $this->configHelper->getConfigFilePath($input); $generateSpec = false; $testBaseClassName = self::DEFAULT_TEST_BASE_CLASS_NAME; if ($configFilePath) { $data = $this->yamlUtil->loadYamlFile($configFilePath); $generateSpec = ArrayUtil::lookupBoolValue(self::GENERATE_SPEC_KEY, $data, false); $testBaseClassName = ArrayUtil::lookupStringValue(self::TEST_BASE_CLASS_NAME_KEY, $data, self::DEFAULT_TEST_BASE_CLASS_NAME); } $overwriteExistingDestinationFile = $input->getOption(CmdOption::OVERWRITE_EXISTING_DESTINATION_FILE_OPTION); $testFileRoot = $this->configHelper->getTestRootPath($input); $sourceFileRoot = $this->configHelper->getSourceFileRoot($input, $testFileRoot, $inSourceFile); $sourceFilePathRelativeToSourceRoot = $this->configHelper->getSourceFilePathRelativeToSourceRoot($sourceFileRoot, $inSourceFile); $outSourceFileDir = PathUtil::getPathUnderRoot($testFileRoot, $sourceFilePathRelativeToSourceRoot); $inputOptions = new Options($overwriteExistingDestinationFile, $testFileRoot, $sourceFileRoot, $outSourceFileDir, $sourceFilePathRelativeToSourceRoot, $generateSpec, $testBaseClassName); return $inputOptions; }
/** * 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; }