Skip to content

Commit

Permalink
Added a stress test for routing
Browse files Browse the repository at this point in the history
  • Loading branch information
jdp committed Jul 8, 2009
1 parent 672493b commit b95369b
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.markdown
Expand Up @@ -2,7 +2,7 @@

Tessera is an extremely tiny PHP framework modeled after [web.py](http://webpy.org), [Sinatra](http://sinatrarb.com), and [Juno](http://brianreily.com/project/juno/).
It allows the developer to map URIs to class methods while keeping their code DRY, and separating application logic and presentation.
Its feature set is small and strong: routes with named params, view and layout logic.
Its feature set is small and strong: routes with named params (and regular expressions and splats!); view and layout logic.

## Why?

Expand Down
72 changes: 72 additions & 0 deletions test/gauntlet.php
@@ -0,0 +1,72 @@
<?php
require '../tessera.php';

class Gauntlet extends Tessera {

function __before() {
?>
<ul>
<li><a href="gauntlet.php?/first">/first</a></li>
<li><a href="gauntlet.php?/second/foo">/second/$foo</a></li>
<li><a href="gauntlet.php?/third/foo">/third/*</a></li>
<li><a href="gauntlet.php?/fourth/foo/bar">/fourth/$foo/*</a></li>
<li><a href="gauntlet.php?/fifth/foo">^/fifth/(\w+)</a></li>
<li><a href="gauntlet.php?/sixth/foo/bar">/sixth/**</a></li>
<li><a href="gauntlet.php?/seventh/foo/baz/bar/quux/zwei">/seventh/$foo/*/$bar/**</a></li>
</ul>
<p>The current request is: <strong><?php echo $this->request_path; ?></strong></p>
<?php
}

function index() {
echo "<p>The stress test!</p>";
}

function basic() {
echo "First: PASS";
}

function named() {
echo "<p>Testing named params</p>";
echo "<pre>";
print_r($this->params);
echo "</pre>";
}

function splat() {
echo "<p>Testing splat parameters</p>";
echo "<pre>";
print_r($this->splat);
echo "</pre>";
}

function regex() {
echo "<p>Testing regular expression matches</p>";
echo "<pre>";
print_r($this->params);
echo "</pre>";
}

function mixed() {
echo "<p>Testing named params</p>";
echo "<pre>";
print_r($this->params);
echo "</pre>";
echo "<p>Testing splat parameters</p>";
echo "<pre>";
print_r($this->splat);
echo "</pre>";
}

}

$gauntlet = new Gauntlet(array(
'/' => 'index',
'/first' => 'basic',
'/second/$foo' => 'named',
'/third/*' => 'splat',
'/fourth/$foo/*' => 'mixed',
'^/fifth/(\w+)' => 'regex',
'/sixth/**' => 'splat',
'/seventh/$foo/*/$bar/**' => 'mixed'
));

0 comments on commit b95369b

Please sign in to comment.