Esempio n. 1
0
 public function testAttributesAreImmutableAndRemoveable()
 {
     $this->assertNull($this->server->getAttribute('foo'));
     $server = $this->server->withAttribute('foo', 'bar');
     $this->assertNotSame($this->server, $server);
     $this->assertEquals('bar', $server->getAttribute('foo'));
     $server2 = $server->withoutAttribute('foo');
     $this->assertNotSame($server, $server2);
     $this->assertNotSame($server2, $server2->withoutAttribute('foo'));
     $this->assertNull($server2->getAttribute('foo'));
 }
Esempio n. 2
0
 public function testRouteWithOptionalTokens()
 {
     $route = new Route('/foo/{bar?}/{baz?}', 'index', 'TestController@helloAction');
     list($controller, $method) = $route->getAction();
     $this->assertEquals('TestController', $controller);
     $this->assertEquals('helloAction', $method);
     $this->assertNotFalse($route->matches(Request::create('/foo')));
     $this->assertNotFalse($route->matches(Request::create('/foo/bar')));
     $this->assertNotFalse($route->matches(Request::create('/foo/bar/baz')));
     $this->assertFalse($route->matches(Request::create('/')));
     $this->assertFalse($route->matches(Request::create('/foo/bar/baz/biz')));
     $this->assertEquals('Hello, Matthew!', (string) call_user_func_array([new $controller(), $method], ['Matthew']));
 }