spec\PhpSpec\CodeGenerator\Generator\MethodGeneratorSpec::it_generates_class_method_from_resource PHP Method

it_generates_class_method_from_resource() public method

public it_generates_class_method_from_resource ( $io, $tpl, $fs, PhpSpec\Locator\Resource $resource, PhpSpec\CodeGenerator\Writer\CodeWriter $codeWriter )
$resource PhpSpec\Locator\Resource
$codeWriter PhpSpec\CodeGenerator\Writer\CodeWriter
    function it_generates_class_method_from_resource($io, $tpl, $fs, Resource $resource, CodeWriter $codeWriter)
    {
        $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');
        $codeWriter->insertMethodLastInClass($codeWithoutMethod, 'METHOD')->willReturn($codeWithMethod);
        $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')));
    }