public function __construct($license, $year, $holder) { $license = strtolower($license); $content = ''; switch ($license) { case 'gpl': $content = self::GPL; break; case 'mit': $content = self::MIT; break; case 'bsd-3': $content = self::BSD3; break; } $content = Utils::renderStringTemplate($content, array('year' => $year, 'holder' => $holder)); parent::__construct(explode("\n", $content)); }
/** * @param Block $block * @param ClassFile $class * @param $config * @return bool */ private static function openInMenuBlock(Block $block, UserClass $class, $config) { fwrite(STDOUT, 'processing: ' . $config->module . ':' . $config->controller . ':' . $config->action . "\n"); $elements = Reverse::getElements($config); if ($elements === false) { return false; } $tryStmt = new TryCatchStatement(); $block->appendRenderable($tryStmt); $tryBlock = $tryStmt->tryBlock; $tryBlock->appendRenderable(new Statement(new AssignExpr('$session', new MethodCall('$this', 'getLoggedSession')))); $tryBlock->appendRenderable(new Statement(new MethodCall('$this', 'openInMenu', [new ObjectProperty('$this', 'mapModule'), '$session']))); $tryBlock->appendRenderable(new Statement(new MethodCall('$this', 'checkWait', ['$session']))); $tryBlock->appendRenderable(new Statement(new AssignExpr('$page', new MethodCall('$session', 'getPage')))); /** @var FormElement $input */ foreach ($elements->getInputs() as $input) { $tryBlock->appendLine(''); $tryBlock->appendRenderable(new Comment('input type: ' . $input->getType() . ' label: ' . $input->getLabel())); $tryBlock->appendRenderable(new AssignStatement(new Raw($input->getPhpName() . 'Input'), new MethodCall('$page', $input->getFindMethod(), $input->getFindArgs()))); } /** @var Button $button */ foreach ($elements->getButtons() as $button) { $tryBlock->appendLine(''); //$tryBlock->appendRenderable( // new CommentBlock(explode("\n", var_export($button, true))) //); $tryBlock->appendRenderable(new Comment('button label: ' . $button->getLabel())); $tryBlock->appendRenderable(new AssignStatement(new Raw($button->getPhpName() . 'Button'), new MethodCall('$page', $button->getFindMethod(), $button->getFindArgs()))); } $tryBlock->appendLine(''); $tryBlock->appendLine(''); $tryBlock->appendRenderable(new Comment('Implement test here.')); $tryBlock->appendLine(''); $tryBlock->appendLine(''); $tryBlock->appendRenderable(new Statement(new MethodCall('$this', 'checkErrors', ['$session']))); $tryBlock->appendLine(''); $tryBlock->appendLine(''); $tryBlock->appendRenderable(new Comment('Remove the following lines when you implement this test.')); /* $tryBlock->appendRenderable( new Statement(new StaticMethodCall('static', 'markTestIncomplete', ['This test has not been implemented yet . '])));*/ $tryBlock->appendLine(''); $tryBlock->appendLine(''); $throwBlock = $tryStmt->catchBlock; $throwBlock->appendRenderable(new Statement(new MethodCall(new StaticMethodCall('Mink', 'getInstance'), 'ss'))); $throwBlock->appendRenderable(new Comment('Remove the following lines when you implement this test.')); /* $throwBlock->appendRenderable( new Statement(new StaticMethodCall('static', 'markTestIncomplete', ['This test has not been implemented yet . '])));*/ if ($elements->getDataTables()) { foreach ($elements->getDataTables() as $key => $dataTable) { $doc = new CommentBlock(); $doc->appendLine('Datatable tests'); $dtTest = new ClassMethod('testDataTable' . ($key + 1)); $dtTest->setScope('public'); //$dtTest->setCommentBlock($doc); $block = $dtTest->getBlock(); self::createDataTableTest($dataTable, $block); $class->addMethodObject($dtTest); } } return true; }