當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Locator\ResourceInterface類代碼示例

本文整理匯總了PHP中PhpSpec\Locator\ResourceInterface的典型用法代碼示例。如果您正苦於以下問題:PHP ResourceInterface類的具體用法?PHP ResourceInterface怎麽用?PHP ResourceInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ResourceInterface類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: let

 function let(ResourceInterface $resource)
 {
     $resource->getSrcNamespace()->willReturn('Foo');
     $resource->getSpecNamespace()->willReturn('spec/Foo');
     $resource->getName()->willReturn('Bar');
     $this->beConstructedWith($resource, self::CONTENT);
 }
開發者ID:mike182uk,項目名稱:phpspec-rename,代碼行數:7,代碼來源:ResourceContentModifierSpec.php

示例2: array

    function it_generates_class_method_from_resource($io, $tpl, $fs, ResourceInterface $resource)
    {
        $codeWithoutMethod = <<<CODE
<?php

namespace Acme;

class App
{
}

CODE;
        $codeWithMethod = <<<CODE
<?php

namespace Acme;

class App
{
METHOD
}

CODE;
        $values = array('%name%' => 'setName', '%arguments%' => '$argument1');
        $resource->getSrcFilename()->willReturn('/project/src/Acme/App.php');
        $resource->getSrcClassname()->willReturn('Acme\\App');
        $tpl->render('method', $values)->willReturn(null);
        $tpl->renderString(Argument::type('string'), $values)->willReturn('METHOD');
        $fs->getFileContents('/project/src/Acme/App.php')->willReturn($codeWithoutMethod);
        $fs->putFileContents('/project/src/Acme/App.php', $codeWithMethod)->shouldBeCalled();
        $this->generate($resource, array('name' => 'setName', 'arguments' => array('everzet')));
    }
開發者ID:edwardricardo,項目名稱:zenska,代碼行數:32,代碼來源:MethodGeneratorSpec.php

示例3: array

 function it_should_not_dispatch_an_event_if_the_file_already_existed($dispatcher, $filesystem, ResourceInterface $resource)
 {
     $path = '/foo';
     $resource->getSrcFilename()->willReturn($path);
     $filesystem->pathExists($path)->willReturn(true);
     $this->generate($resource, array());
     $dispatcher->dispatch('afterFileCreation', Argument::any())->shouldNotHaveBeenCalled();
 }
開發者ID:focuslife,項目名稱:v0.1,代碼行數:8,代碼來源:NewFileNotifyingGeneratorSpec.php

示例4: getContent

 /**
  * @param ResourceInterface $resource
  * @param string            $methodName
  * @param array             $arguments
  * @return string
  */
 private function getContent(ResourceInterface $resource, $methodName, $arguments)
 {
     $className = $resource->getName();
     $class = $resource->getSrcClassname();
     $template = new CreateObjectTemplate($this->templates, $methodName, $arguments, $className);
     if (method_exists($class, '__construct')) {
         $template = new ExistingConstructorTemplate($this->templates, $methodName, $arguments, $className, $class);
     }
     return $template->getContent();
 }
開發者ID:franzliedke,項目名稱:phpspec,代碼行數:16,代碼來源:NamedConstructorGenerator.php

示例5: generate

 /**
  * @param ResourceInterface $resource
  * @param array $data
  */
 public function generate(ResourceInterface $resource, array $data)
 {
     $filepath = $resource->getSrcFilename();
     if (!($content = $this->templates->render('private-constructor', array()))) {
         $content = $this->templates->renderString($this->getTemplate(), array());
     }
     $code = $this->filesystem->getFileContents($filepath);
     $code = preg_replace('/}[ \\n]*$/', rtrim($content) . "\n}\n", trim($code));
     $this->filesystem->putFileContents($filepath, $code);
     $this->io->writeln("<info>Private constructor has been created.</info>\n", 2);
 }
開發者ID:araines,項目名稱:phpspec,代碼行數:15,代碼來源:PrivateConstructorGenerator.php

示例6: generate

 /**
  * @param ResourceInterface $resource
  * @param array $data
  */
 public function generate(ResourceInterface $resource, array $data)
 {
     $filepath = $resource->getSrcFilename();
     if (!($content = $this->templates->render('private-constructor', array()))) {
         $content = $this->templates->renderString($this->getTemplate(), array());
     }
     $code = $this->filesystem->getFileContents($filepath);
     $code = $this->codeWriter->insertMethodFirstInClass($code, $content);
     $this->filesystem->putFileContents($filepath, $code);
     $this->io->writeln("<info>Private constructor has been created.</info>\n", 2);
 }
開發者ID:EnmanuelCode,項目名稱:backend-laravel,代碼行數:15,代碼來源:PrivateConstructorGenerator.php

示例7:

 function it_prepares_the_subject(ExampleNode $example, ObjectBehavior $context, MatcherManager $matchers, CollaboratorManager $collaborators, SpecificationNode $specification, ResourceInterface $resource, VarienWrapper $wrapper, Subject $subject, $factory)
 {
     $factory->create(Argument::cetera())->willReturn($wrapper);
     $wrapper->wrap(null)->willReturn($subject);
     $subject->beAnInstanceOf('\\stdObject');
     $subject = $subject->getWrappedObject();
     $resource->getSrcClassname()->willReturn('\\stdObject');
     $specification->getResource()->willReturn($resource);
     $example->getSpecification()->willReturn($specification);
     $context->setSpecificationSubject($subject)->shouldBeCalled();
     $this->prepare($example, $context, $matchers, $collaborators);
 }
開發者ID:kbulloch,項目名稱:MageSpec_vm,代碼行數:12,代碼來源:VarienSubjectMaintainerSpec.php

示例8:

 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));
 }
開發者ID:edwardricardo,項目名稱:zenska,代碼行數:12,代碼來源:ResourceManagerSpec.php

示例9: generate

 /**
  * @param ResourceInterface $resource
  * @param array $data
  */
 public function generate(ResourceInterface $resource, array $data = array())
 {
     $filepath = $resource->getSrcFilename();
     $name = $data['name'];
     $arguments = $data['arguments'];
     $argString = $this->buildArgumentString($arguments);
     $values = array('%name%' => $name, '%arguments%' => $argString);
     if (!($content = $this->templates->render('interface-method-signature', $values))) {
         $content = $this->templates->renderString($this->getTemplate(), $values);
     }
     $this->insertMethodSignature($filepath, $content);
     $this->io->writeln(sprintf("<info>Method signature <value>%s::%s()</value> has been created.</info>\n", $resource->getSrcClassname(), $name), 2);
 }
開發者ID:edwardricardo,項目名稱:zenska,代碼行數:17,代碼來源:MethodSignatureGenerator.php

示例10: renderTemplate

    /**
     * @param ResourceInterface $resource
     * @param string            $filepath
     *
     * @return string
     */
    protected function renderTemplate(ResourceInterface $resource, $filepath)
    {
        $controller = <<<CONTROLLER
    function let(\\Fuel\\Core\\Request \$request, \\Fuel\\Core\\Response \$response){
        \$this->beConstructedWith(\$request, \$response);
    }

CONTROLLER;
        $values = array('%filepath%' => $filepath, '%name%' => $resource->getSpecName(), '%namespace%' => $resource->getSpecNamespace(), '%subject%' => $resource->getSrcClassname(), "%constructor%" => preg_match("!^Controller_!i", $resource->getSpecName()) ? $controller : "");
        if (!($content = $this->getTemplateRenderer()->render('specification', $values))) {
            $content = $this->getTemplateRenderer()->renderString($this->getTemplate(), $values);
        }
        return $content;
    }
開發者ID:dohzoh,項目名稱:phpspec-fuel,代碼行數:20,代碼來源:FuelphpSpecificationGenerator.php

示例11: generate

 /**
  * @param ResourceInterface $resource
  * @param array             $data
  */
 public function generate(ResourceInterface $resource, array $data = array())
 {
     $filepath = $resource->getSrcFilename();
     $name = $data['name'];
     $arguments = $data['arguments'];
     $argString = count($arguments) ? '$argument' . implode(', $argument', range(1, count($arguments))) : '';
     $values = array('%name%' => $name, '%arguments%' => $argString);
     if (!($content = $this->templates->render('method', $values))) {
         $content = $this->templates->renderString($this->getTemplate(), $values);
     }
     $code = $this->filesystem->getFileContents($filepath);
     $this->filesystem->putFileContents($filepath, $this->getUpdatedCode($name, $content, $code));
     $this->io->writeln(sprintf("<info>Method <value>%s::%s()</value> has been created.</info>\n", $resource->getSrcClassname(), $name), 2);
 }
開發者ID:focuslife,項目名稱:v0.1,代碼行數:18,代碼來源:MethodGenerator.php

示例12: generate

 /**
  * @param ResourceInterface $resource
  * @param array $data
  *
  * @return mixed
  */
 public function generate(ResourceInterface $resource, array $data = array())
 {
     $filepath = $resource->getSrcFilename();
     $name = $data['name'];
     $arguments = $data['arguments'];
     $argString = $this->argumentBuilder->buildFrom($arguments);
     $values = array('%name%' => $name, '%arguments%' => $argString);
     if (!($content = $this->templates->render('method', $values))) {
         $content = $this->templates->renderString($this->getTemplate(), $values);
     }
     $code = $this->filesystem->getFileContents($filepath);
     $code = preg_replace('/}[ \\n]*$/', rtrim($content) . "\n}\n", trim($code));
     $this->filesystem->putFileContents($filepath, $code);
     $this->io->writeln(sprintf("\n<info>Method <value>%s::%s()</value> has been created.</info>", $resource->getSrcClassname(), $name), 2);
 }
開發者ID:amir20202000,項目名稱:phpspec-typehintedmethods,代碼行數:21,代碼來源:TypeHintedMethodGenerator.php

示例13: 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();
 }
開發者ID:nick-jones,項目名稱:phpspec-git-extension,代碼行數:15,代碼來源:GitAddingGeneratorSpec.php

示例14: generate

 /**
  * @param ResourceInterface $resource
  * @param array $data
  */
 public function generate(ResourceInterface $resource, array $data)
 {
     $method = $data['method'];
     $expected = $data['expected'];
     $code = $this->filesystem->getFileContents($resource->getSrcFilename());
     $values = array('%constant%' => var_export($expected, true));
     if (!($content = $this->templates->render('method', $values))) {
         $content = $this->templates->renderString($this->getTemplate(), $values);
     }
     $pattern = '/' . '(function\\s+' . preg_quote($method, '/') . '\\s*\\([^\\)]*\\))\\s+{[^}]*?}/';
     $replacement = '$1' . $content;
     $modifiedCode = preg_replace($pattern, $replacement, $code);
     $this->filesystem->putFileContents($resource->getSrcFilename(), $modifiedCode);
     $this->io->writeln(sprintf("\n<info>Method <value>%s::%s()</value> has been modified.</info>", $resource->getSrcClassname(), $method), 2);
 }
開發者ID:franzliedke,項目名稱:phpspec,代碼行數:19,代碼來源:ReturnConstantGenerator.php

示例15:

 function it_records_that_class_was_created_in_executioncontext(ResourceInterface $resource, ExecutionContextInterface $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();
 }
開發者ID:manhvu1212,項目名稱:videoplatform,代碼行數:9,代碼來源:ClassGeneratorSpec.php


注:本文中的PhpSpec\Locator\ResourceInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。