/** @test */ public function TestSetAndShowData() { $surface = new Nether\Surface(); $surface->Set('test', '<b>boing</b>'); ob_start(); $surface->Show('test'); $this->AssertTrue(ob_get_clean() === '<b>boing</b>', 'by default shows are protected'); ob_start(); $surface->Show('test', true); $this->AssertTrue(ob_get_clean() === '<b>boing</b>', 'explictly shows are protected'); ob_start(); $surface->Show('test', false); $this->AssertTrue(ob_get_clean() === '<b>boing</b>', 'explictly shows are unprotected'); return; }
protected function RenderHtmlVersion() : self { $Printer = NULL; $Printer = function (Nether\Senpai\Struct $Struct, int $Level = 1) use(&$Printer) { $File = sprintf('%s%s%s', $this->GetConfig()->GetOutputDir(), DIRECTORY_SEPARATOR, $Struct->GetAbsolutePath($Struct->GetRenderFilename('html'))); $Dir = dirname($File); //////// if (!is_dir($Dir)) { @mkdir($Dir, 0777, TRUE); } touch($File); echo "Writing {$File}", PHP_EOL; //////// $Surface = new Nether\Surface(['AutoStash' => FALSE, 'AutoRender' => FALSE, 'AutoCapture' => FALSE, 'ThemeRoot' => sprintf('%s%sthemes', dirname(__FILE__, 4), DIRECTORY_SEPARATOR)]); $Surface->Start(); $Surface->Set('Level', $Level); $Surface->Set('Root', $this->Root); //////// if ($Struct instanceof NamespaceObject) { $Surface->Set('Namespace', $Struct); echo $Surface->GetArea('code/namespace'); } elseif ($Struct instanceof ClassObject) { $Surface->Set('Class', $Struct); echo $Surface->GetArea('code/class'); } //////// file_put_contents($File, $Surface->Render(TRUE)); unset($Surface); //////// if ($Struct instanceof NamespaceObject) { foreach ($Struct->GetNamespaces()->GetData() as $Struck) { $Printer($Struck, $Level + 1); } foreach ($Struct->GetClasses()->GetData() as $Struck) { $Printer($Struck, $Level); } } //////// return; }; $Printer($this->Root); return $this; }