1
0
mirror of https://github.com/php/phd.git synced 2026-04-29 01:43:11 +02:00
Files
archived-phd/phpdotnet/phd/TestGenericChunkedXHTML.php
T
haszi b703f50bdf Refactor test helpers and test files (#104)
* Add Format as an optional constructor dependency to TestRender

Add Format as an optional constructor dependency to TestRender.
Check format's methods conditionally.
Refactor tests to inject formats.

* Add Config as a constructor dependency to TestRender

Add Config as a constructor dependency to TestRender.
Refactor tests to inject Config.

* Add Index as an optional constructor dependency to TestRender

* TestRender to extend Render

* Config to allow calling instance methods

* Refactor test helpers and test directory structure

Refactor TestRender to use only constructor injected objects.
Rename test format helper classes to indicate which package they belong to.
Move TestRender and all format helper classes into the phpdotnet phd directory to enable autoloading.
Remove all unnecessary lines from setup.php.
Restructure test directory to follow the structure of the tested classes.

---------

Co-authored-by: haszi <haszika80@gmail.com>
2024-02-26 15:12:03 +00:00

37 lines
935 B
PHP

<?php
namespace phpdotnet\phd;
class TestGenericChunkedXHTML extends Package_Generic_ChunkedXHTML {
public function update($event, $val = null) {
switch($event) {
case Render::CHUNK:
parent::update($event, $val);
break;
case Render::STANDALONE:
parent::update($event, $val);
break;
case Render::INIT:
$this->setOutputDir(Config::output_dir() . strtolower($this->getFormatName()) . '/');
break;
//No verbose
}
}
public function writeChunk($id, $fp) {
$filename = $this->getOutputDir() . $id . $this->getExt();
rewind($fp);
$content = "\n";
$content .= stream_get_contents($fp);
if ($id === "") {
$filename = Config::xml_file();
}
echo "Filename: " . basename($filename) . "\n";
echo "Content:" . $content . "\n";
}
}