public function test() { $converter = new \Rocker\Utils\XML\ArrayConverter(); $converter->setVersion('2.0'); $converter->setCharset('latin1'); $converter->setRootElementName('root'); $this->assertEquals($this->generate('<a>1</a>', 'root', '2.0', 'latin1'), trim($converter->convert(array('a' => 1))->saveXML())); $converter = new \Rocker\Utils\XML\ArrayConverter(); $this->assertEquals($this->generate('<a>1</a>'), trim($converter->convert(array('a' => 1))->saveXML())); $this->assertEquals($this->generate('<a>1</a><b><c><![CDATA[obj]]></c></b>'), trim($converter->convert(array('a' => 1, 'b' => array('c' => 'obj')))->saveXML())); $this->assertEquals($this->generate('<a><node>1</node><node>2</node><node>3</node></a>'), trim($converter->convert(array('a' => array(1, 2, 3)))->saveXML())); $this->assertEquals($this->generate('<node><![CDATA[a]]></node><node>2</node><node>1</node>'), trim($converter->convert(array('a', 2, 1))->saveXML())); }
<?php /** * PHP Rocker * --------------------------------- * * @package rocker/server * @author Victor Jonsson (http://victorjonsson.se) * @license MIT license (http://opensource.org/licenses/MIT) */ // Composer class loader require __DIR__ . '/vendor/autoload.php'; // Load config $config = (require __DIR__ . '/config.php'); // Initiate server $server = new \Rocker\Server($config); // Output the auto-generated documentation $docsURI = $config['application.path'] == '/' ? '/docs' : '/'; $server->get($docsURI, function () use($config, $server) { $converter = new \Rocker\Utils\XML\ArrayConverter(); $generator = new \Rocker\REST\Documentation\Generator(); // Generate documentation and convert it to an array $documentationXML = $generator->generateDocumentation($config['application.operations']); // Add $documentation to current scope, later used in the template $documentation = $converter->convertXMLToArray($documentationXML); // Generate the documentation website $template = $generator->getExampleTemplatePath(); require $template; }); // Run forrest run $server->run();