/** * Tests the setRenderMainFunction() method. * @covers \ManiaScript\Builder\Options::setRenderMainFunction */ public function testSetRenderMainFunction() { $expected = false; $options = new Options(); $result = $options->setRenderMainFunction($expected); $this->assertEquals($options, $result); $this->assertPropertyEquals($expected, $options, 'renderMainFunction'); }
/** * Provides the data for the getCode() test. * @return array The data. */ public function provideGetCode() { /* @var $renderedCode \ManiaScript\Builder\RenderedCode|\PHPUnit_Framework_MockObject_MockObject */ $renderedCode = $this->getMockBuilder('ManiaScript\\Builder\\RenderedCode')->setMethods(array('getContextDirective'))->getMock(); $renderedCode->expects($this->any())->method('getContextDirective')->will($this->returnValue('abc')); $renderedCode->setDirectives('def')->setGlobalCode('ghi')->setMainFunction('jkl'); $options = new Options(); $options->setRenderContextDirective(false)->setRenderDirectives(false)->setRenderGlobalCode(false)->setRenderMainFunction(false)->setCompress(false)->setIncludeScriptTag(false); $optionsContext = clone $options; $optionsContext->setRenderContextDirective(true); $optionsDirectives = clone $options; $optionsDirectives->setRenderDirectives(true); $optionsGlobalCode = clone $options; $optionsGlobalCode->setRenderGlobalCode(true); $optionsMainFunction = clone $options; $optionsMainFunction->setRenderMainFunction(true); $optionsCompress = clone $options; $optionsCompress->setRenderContextDirective(true)->setCompress(true); $optionsScriptTag = clone $options; $optionsScriptTag->setRenderContextDirective(true)->setIncludeScriptTag(true); $optionsAll = clone $options; $optionsAll->setRenderContextDirective(true)->setRenderDirectives(true)->setRenderGlobalCode(true)->setRenderMainFunction(true)->setCompress(true)->setIncludeScriptTag(true); return array(array('', $options, $renderedCode, null, null, null, null), array('abc', $optionsContext, $renderedCode, null, null, null, null), array('def', $optionsDirectives, $renderedCode, null, null, null, null), array('ghi', $optionsGlobalCode, $renderedCode, null, null, null, null), array('jkl', $optionsMainFunction, $renderedCode, null, null, null, null), array('foo', $optionsCompress, $renderedCode, 'abc', 'foo', null, null), array('bar', $optionsScriptTag, $renderedCode, null, null, 'abc', 'bar'), array('bar', $optionsAll, $renderedCode, 'abcdefghijkl', 'foo', 'foo', 'bar')); }
/** * Builds the main function of the ManiaScript. * @return $this Implementing fluent interface. */ protected function buildMainFunction() { $functionPrefix = $this->options->getFunctionPrefix(); $result = 'Void ' . $functionPrefix . '_Dummy() {}' . PHP_EOL . 'main() {' . PHP_EOL . $this->eventHandlerFactory->getHandler('Load')->getInlineCode() . ' yield;' . PHP_EOL . $this->eventHandlerFactory->getHandler('FirstLoop')->getInlineCode() . $this->buildEventLoop() . '}' . PHP_EOL; return $result; }