private function buildArgString() { $argstring = ''; foreach ($this->executionContext->asEnv() as $key => $value) { $argstring .= 'SET ' . $key . '=' . $value . ' && '; } return $argstring; }
private function buildArgString() { $argstring = ''; foreach ($this->executionContext->asEnv() as $key => $value) { $argstring .= $key . '=' . escapeshellarg($value) . ' '; } return $argstring; }
/** * @throws PrerequisiteFailedException */ public function guardPrerequisites() { $undefinedTypes = array(); foreach ($this->executionContext->getGeneratedTypes() as $type) { if (!class_exists($type) && !interface_exists($type)) { $undefinedTypes[] = $type; } } if ($undefinedTypes) { throw new PrerequisiteFailedException(sprintf("The type%s %s %s generated but could not be loaded. Do you need to configure an autoloader?\n", count($undefinedTypes) > 1 ? 's' : '', join(', ', $undefinedTypes), count($undefinedTypes) > 1 ? 'were' : 'was')); } }
/** * @param Resource $resource * @param array $data */ public function generate(Resource $resource, array $data = array()) { $filepath = $this->getFilePath($resource); if ($this->fileAlreadyExists($filepath)) { if ($this->userAborts($filepath)) { return; } $this->io->writeln(); } $this->createDirectoryIfItDoesExist($filepath); $this->generateFileAndRenderTemplate($resource, $filepath); $this->executionContext->addGeneratedType($resource->getSrcClassname()); }
function it_records_that_class_was_created_in_executioncontext(Resource $resource, ExecutionContext $executionContext) { $resource->getName()->willReturn('App'); $resource->getSrcFilename()->willReturn('/project/src/Acme/App.php'); $resource->getSrcNamespace()->willReturn('Acme'); $resource->getSrcClassname()->willReturn('Acme\\App'); $this->generate($resource); $executionContext->addGeneratedType('Acme\\App')->shouldHaveBeenCalled(); }
/** * Kills the current process and starts a new one */ public function reRunSuite() { $args = $_SERVER['argv']; $env = $this->executionContext ? $this->executionContext->asEnv() : array(); pcntl_exec($this->getExecutablePath(), $args, array_merge($env, $_SERVER)); }
function it_throws_execption_when_types_do_not_exist(ExecutionContext $executionContext) { $executionContext->getGeneratedTypes()->willReturn(array('stdClassXXX')); $this->shouldThrow('PhpSpec\\Process\\Prerequisites\\PrerequisiteFailedException')->duringGuardPrerequisites(); }