<?php require __DIR__ . '/../pipes.php'; pipes\options()->views = __DIR__ . '/views'; pipes\get('/', function () { return "Hello, world!"; }); pipes\get('/form', function () { return pipes\render('form.php'); }); pipes\post('/form', function ($params) { if (empty($params->name)) { return pipes\render('form.php', array('error' => 'You must enter a name')); } else { return pipes\redirect('/' . urlencode($params->name)); } }); pipes\get('/:name', function ($params) { return "Hello, {$params->name}!"; }); pipes\run();
}); }); describe("get()", function () { it("should create a route for the GET method", function () { pipes\routes(array()); $route = pipes\get('/foo/bar', function () { }); expect($route)->to_be_a('pipes\\Route'); expect($route->options->method)->to_be('GET'); expect(pipes\routes())->to_be(array($route)); }); }); describe("post()", function () { it("should create a route for the POST method", function () { pipes\routes(array()); $route = pipes\post('/foo/bar', function () { }); expect($route)->to_be_a('pipes\\Route'); expect($route->options->method)->to_be('POST'); expect(pipes\routes())->to_be(array($route)); }); }); describe("put()", function () { it("should create a route for the PUT method", function () { pipes\routes(array()); $route = pipes\put('/foo/bar', function () { }); expect($route)->to_be_a('pipes\\Route'); expect($route->options->method)->to_be('PUT'); expect(pipes\routes())->to_be(array($route)); }); });