本文整理汇总了PHP中PhpSpec\Locator\ResourceInterface::getSpecFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceInterface::getSpecFilename方法的具体用法?PHP ResourceInterface::getSpecFilename怎么用?PHP ResourceInterface::getSpecFilename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpSpec\Locator\ResourceInterface
的用法示例。
在下文中一共展示了ResourceInterface::getSpecFilename方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_asks_confirmation_if_spec_already_exists($io, $tpl, $fs, ResourceInterface $resource)
{
$resource->getSpecName()->willReturn('App');
$resource->getSpecFilename()->willReturn('/project/spec/Acme/App.php');
$resource->getSpecNamespace()->willReturn('spec\\Acme');
$resource->getSrcClassname()->willReturn('Acme\\App');
$fs->pathExists('/project/spec/Acme/App.php')->willReturn(true);
$io->askConfirmation(Argument::type('string'), false)->willReturn(false);
$fs->putFileContents(Argument::cetera())->shouldNotBeCalled();
$this->generate($resource);
}
示例2: it_stages_files_created_as_a_result_of_delegation_of_generation
public function it_stages_files_created_as_a_result_of_delegation_of_generation($delegate, ResourceInterface $resource, $filesystem, $repository)
{
$srcFilePath = '/foo/bar.php';
$specFilePath = '/foo/barspec.php';
$resource->getSrcFilename()->willReturn($srcFilePath);
$resource->getSpecFilename()->willReturn($specFilePath);
$filesystem->pathExists($srcFilePath)->willReturn(false);
$filesystem->pathExists($specFilePath)->willReturn(true);
$delegate->generate(Argument::cetera())->will(function () use($filesystem, $srcFilePath) {
$filesystem->pathExists($srcFilePath)->willReturn(true);
});
$this->generate($resource, []);
$repository->stageFile($srcFilePath)->shouldHaveBeenCalled();
$repository->stageFile($specFilePath)->shouldNotHaveBeenCalled();
}
示例3: generate
public function generate(ResourceInterface $resource, array $data = array())
{
$filepath = $resource->getSpecFilename();
if ($this->filesystem->pathExists($filepath)) {
$message = sprintf('File "%s" already exists. Overwrite?', basename($filepath));
if (!$this->io->askConfirmation($message, false)) {
return;
}
$this->io->writeln();
}
$path = dirname($filepath);
if (!$this->filesystem->isDirectory($path)) {
$this->filesystem->makeDirectory($path);
}
$values = array('%filepath%' => $filepath, '%name%' => $resource->getSpecName(), '%namespace%' => $resource->getSpecNamespace(), '%subject%' => $resource->getSrcClassname());
if (!($content = $this->templates->render('controller_specification', $values))) {
$content = $this->templates->renderString(file_get_contents(__DIR__ . '/templates/controller_spec.template'), $values);
}
$this->filesystem->putFileContents($filepath, $content);
$this->io->writeln(sprintf("<info>ControllerSpecification for <value>%s</value> created in <value>'%s'</value>.</info>\n", $resource->getSrcClassname(), $filepath));
}
示例4: getFilePath
/**
* @param ResourceInterface $resource
* @return mixed
*/
protected function getFilePath(ResourceInterface $resource)
{
return $resource->getSpecFilename();
}
示例5: getFilePathsFromResource
/**
* @param ResourceInterface $resource
* @return string[]
*/
private function getFilePathsFromResource(ResourceInterface $resource)
{
return [$resource->getSrcFilename(), $resource->getSpecFilename()];
}
示例6: relocateSpec
/**
* @param ResourceInterface $oldResource
* @param ResourceInterface $newResource
*/
private function relocateSpec(ResourceInterface $oldResource, ResourceInterface $newResource)
{
$this->relocateResource($oldResource->getSpecFilename(), $newResource->getSpecFilename(), $this->modifySpecContent($oldResource, $newResource));
}
示例7: importResource
private function importResource(Suite $suite, ResourceInterface $resource, $line = null)
{
if (!class_exists($resource->getSpecClassname()) && is_file($resource->getSpecFilename())) {
require_once $resource->getSpecFilename();
}
if (!class_exists($resource->getSpecClassname())) {
return;
}
$reflection = new ReflectionClass($resource->getSpecClassname());
if ($reflection->isAbstract()) {
return;
}
if (!$reflection->implementsInterface('PhpSpec\\SpecificationInterface')) {
return;
}
$spec = new SpecificationNode($resource->getSrcClassname(), $reflection, $resource);
foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
if (!preg_match('/^(it|its)[^a-zA-Z]/', $method->getName())) {
continue;
}
if (null !== $line && !$this->lineIsInsideMethod($line, $method)) {
continue;
}
$example = new ExampleNode(str_replace('_', ' ', $method->getName()), $method);
if ($this->methodIsEmpty($method)) {
$example->markAsPending();
}
$spec->addExample($example);
}
$suite->addSpecification($spec);
}