public function testBuilderSetters() { $route = new Route(); // Path $this->assertSame('/', $route->getPath()); $result = $route->path('/foo'); $this->assertSame('/foo', $route->getPath()); $this->assertSame($result, $route); // Method $this->assertNull($route->getMethod()); $result = $route->method('POST'); $this->assertSame('POST', $route->getMethod()); $this->assertSame($result, $route); // Before $b1 = function () { }; $b2 = function () { }; $this->assertEquals([], $route->getBefore()); $result = $route->before($b1); $this->assertEquals([$b1], $route->getBefore()); $this->assertSame($result, $route); $result = $route->before($b2); $this->assertEquals([$b1, $b2], $route->getBefore()); $this->assertSame($result, $route); // After $a1 = function () { }; $a2 = function () { }; $this->assertEquals([], $route->getAfter()); $result = $route->after($a1); $this->assertEquals([$a1], $route->getAfter()); $this->assertSame($result, $route); $result = $route->after($a2); $this->assertEquals([$a1, $a2], $route->getAfter()); $this->assertSame($result, $route); // Callback $callback = function () { }; $this->assertNull($route->getCallback()); $result = $route->callback($callback); $this->assertSame($callback, $route->getCallback()); $this->assertSame($result, $route); // Prefix $prefix = '/foo'; $this->assertSame('', $route->getPrefix()); $result = $route->prefix($prefix); $this->assertSame($prefix, $route->getPrefix()); $this->assertSame($result, $route); // Assert $this->assertEquals([], $route->getAsserts()); $result = $route->assert('foo', 'foopattern'); $this->assertSame(['foo' => 'foopattern'], $route->getAsserts()); $this->assertSame($result, $route); }