本文整理汇总了PHP中PhpSpec\Locator\ResourceInterface::getSpecClassname方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceInterface::getSpecClassname方法的具体用法?PHP ResourceInterface::getSpecClassname怎么用?PHP ResourceInterface::getSpecClassname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpSpec\Locator\ResourceInterface
的用法示例。
在下文中一共展示了ResourceInterface::getSpecClassname方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateCodeForResource
protected function generateCodeForResource(ResourceInterface $resource, array $data)
{
/** @var Object $structure */
$structure = Object::make($resource->getSpecClassname());
$structure->extend(Object::make('PhpSpec\\ObjectBehavior'));
$methodBody = <<<BODY
\$this->shouldHaveType('{$resource->getSrcClassname()}');
BODY;
$structure->addMethod(Method::make('it_is_initializable')->setBody($methodBody));
foreach ($data['params'] as $param) {
$specExample = sprintf('it_should_retrieve_%s_getter_value', $param);
$specMethodBody = "";
$specMethodBody .= " throw new PendingException('pending implementation');" . "\n";
$specMethodBody .= " \$expectation = 'put value here';" . "\n";
$specMethodBody .= " \$this->{$param}()->shouldBeLike(\$expectation);";
$specExampleMethod = Method::make($specExample)->setBody($specMethodBody);
$structure->addMethod($specExampleMethod);
}
$file = File::make($resource->getSpecFilename());
$file->addFullyQualifiedName(new FullyQualifiedName('PhpSpec\\ObjectBehavior'));
$file->addFullyQualifiedName(new FullyQualifiedName('Prophecy\\Argument'));
$file->addFullyQualifiedName(new FullyQualifiedName('PhpSpec\\Exception\\Example\\PendingException'));
$file->setStructure($structure);
$prettyPrinter = Build::prettyPrinter();
return $prettyPrinter->generateCode($file);
}
示例2: generateCodeForResource
protected function generateCodeForResource(ResourceInterface $resource, array $data)
{
/** @var Object $structure */
$structure = Object::make($resource->getSpecClassname());
$handledClass = $data['handles'];
$pieces = explode("\\", $handledClass);
$handledClassShortName = end($pieces);
$arguments = '$' . implode(', $', $data['params']);
$structure->extend(Object::make('PhpSpec\\ObjectBehavior'));
$methodBody = <<<BODY
\$this->shouldHaveType('{$resource->getSrcClassname()}');
BODY;
$structure->addMethod(Method::make('it_is_initializable')->setBody($methodBody));
$methodBody = <<<BODY
throw new PendingException('Pending implementation');
\$command = new {$handledClassShortName}({$arguments});
\$this->handle(\$command);
BODY;
$structure->addMethod(Method::make('it_should_handle')->setBody($methodBody));
$file = File::make($resource->getSpecFilename());
$file->addFullyQualifiedName(new FullyQualifiedName('PhpSpec\\ObjectBehavior'));
$file->addFullyQualifiedName(new FullyQualifiedName('Prophecy\\Argument'));
$file->addFullyQualifiedName(new FullyQualifiedName('PhpSpec\\Exception\\Example\\PendingException'));
$file->addFullyQualifiedName(new FullyQualifiedName($handledClass));
$file->setStructure($structure);
$prettyPrinter = Build::prettyPrinter();
return $prettyPrinter->generateCode($file);
}
示例3:
function it_uses_the_resource_from_the_highest_priority_locator_when_duplicates_occur($locator1, $locator2, ResourceInterface $resource1, ResourceInterface $resource2)
{
$locator1->getPriority()->willReturn(2);
$locator2->getPriority()->willReturn(1);
$this->registerLocator($locator1);
$this->registerLocator($locator2);
$resource1->getSpecClassname()->willReturn('Some\\Spec');
$resource2->getSpecClassname()->willReturn('Some\\Spec');
$locator1->getAllResources()->willReturn(array($resource1));
$locator2->getAllResources()->willReturn(array($resource2));
$this->locateResources('')->shouldReturn(array($resource1));
}
示例4: 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);
}