public function testCreate() { $tree = new Tree(); $this->assertEquals($tree->getRoot(), null); $this->assertEquals($tree->infixeList(), [0 => null]); }
/** * Simple recursive visualisation. * * @param Tree $tree * @return string */ public function render(Tree $tree) { echo '<!doctype html> <html> <head> <meta charset="utf-8"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <style type="text/css"> .node { border: 1px solid #0f0; border-radius: 50px; height: 90px; width: 90px; padding: 10px; text-align: center; } .spacer { height: 100px; } .black { border-color: #000; } .red { border-color: #F00; } .leaf { background: #eee2c1; } .top, .bottom { height: 20px; } .left, .right { display: inline-block; } .parent, .root { border: 1px solid; height: 24px; width: 24px; padding: 2px; border-radius: 12px; text-align: center; display: inline-block; } .parent, .root, .glyphicon-remove { color: #999; } .parent { border-color: #ccc; background: #eee; } .root { border-color: #aad; background: #ccf; color: #aad; } </style> </head> <body> <table class="table"> <tr> '; $this->infixeRender($tree->getRoot()); echo ' </tr> </table> </body> </html> '; }