/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->paramRealizerMock = $this->getMock('\\Phpy\\Parameter\\ParameterRealizerInterface'); $this->paramRealizerMock->expects($this->any())->method('realize')->will($this->returnValue('xxx')); //This mock a func object, mocking its getParameters and getBody Method $this->funcMock = $this->getMockBuilder('\\Phpy\\Func\\Func')->disableOriginalConstructor()->getMock(); $this->funcMock->expects($this->any())->method('getParameters')->will($this->returnValue(array(new Parameter('a'), new Parameter('b'), new Parameter('c')))); $that = $this; $this->funcMock->expects($this->any())->method('getBody')->will($this->returnCallback(function () use($that) { return $that->returnedFuncBody; })); $this->realizer = new PhpFuncRealizer($this->paramRealizerMock, 'function({parametersList}){realizedBody}', '{{body}}'); }
/** * Returns the function body enclosed by brackets * @param Func $function * @return string */ private function getRealizedBody(Func $function) { return $this->realizeVars(array('body' => $function->getBody()), $this->bodyTemplate); }
/** * @covers Phpy\Func\Func::setBody * @covers Phpy\Func\Func::getBody */ public function testSetAndGetBody() { $body = 'asdasd xxx ; xasd'; $this->func->setBody($body); $this->assertEquals($body, $this->func->getBody()); }
/** * @param string $name The name of the method * @param array $params An array of \Phpy\Parameter\Parameter objects * @param string $visibility The visibility of the method * @param bool $isAbstract Is the method abstract? * @param bool $isStatic Is the method static? * @param bool $isFinal Is the method final? */ public function __construct($name, $params = array(), $visibility = 'public', $isAbstract = false, $isStatic = false, $isFinal = false) { parent::__construct($name, $params); $this->setVisibility($visibility)->setAbstract($isAbstract)->setStatic($isStatic)->setFinal($isFinal); }