public function testChainer() { $tmp = $this->getTmp(); copy(__DIR__ . '/../files/.src/chainer.php', $tmp . '_chainer.sbp.php'); ob_start(); sbp($tmp . '_chainer'); $contents = ob_get_contents(); ob_end_clean(); $this->assertSame("trucmachinchose", $contents); }
public function testSuperMethods() { $tmp = $this->getTmp(); Sbp::prod(); copy(__DIR__ . '/../files/.src/return.php', $tmp . '_return_prod.sbp.php'); file_put_contents($tmp . '__return_prod.php', '<?php return 1138;'); touch($tmp . '__return_prod.php', time() - 3600); $this->assertSame(1138, sbp_include_once($tmp . '_return_prod')); $this->assertSame(1138, sbp($tmp . '_return_prod')); Sbp::dev(); copy(__DIR__ . '/../files/.src/return.php', $tmp . '_return_dev.sbp.php'); file_put_contents($tmp . '__return_dev.php', '<?php return 1138;'); touch($tmp . '__return_dev.php', time() - 3600); $this->assertSame(42, sbp_include_once($tmp . '_return_dev')); $this->assertSame(42, sbp($tmp . '_return_dev')); }
public function testBenchmark() { $tmp = $this->getTmp(); copy(__DIR__ . '/../files/.src/short_tag.php', $tmp . '_short_tag.sbp.php'); sbp_benchmark(); sbp($tmp . '_short_tag'); $contents = sbp_benchmark_end(); $this->assertFalse(empty($contents), 'benchmark should provide some contents'); $this->assertTrue(preg_match('` <html[^>]*>\\s*<head>[\\s\\S]+?</head>\\s* <body>\\s* <h1>Benckmark</h1>\\s* <ul>\\s* <li>Start\\s+benchmark</li>\\s* <li><b>[^<]+</b>End\\s+benchmark</li>\\s* </ul>\\s* <p>All:\\s+<b>[^<]+</b></p>\\s* <h1>Code\\s+source</h1>\\s* <pre>Hello\\s+World!</pre>\\s* </body>\\s* </html> `x', $contents) > 0, 'benchmark return times in a HTML template'); }
<?php include_once '../../src/Sbp/Sbp.php'; sbp('main.php');
<?php sbp(__DIR__ . '/JsParseSbp.php');
<?php sbp(__DIR__ . '/CssParserSbp.php');