3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the MIT license.
18 namespace PHPRouterTest\Test;
21 use PHPUnit_Framework_TestCase;
23 class RouteTest extends PHPUnit_Framework_TestCase
25 private $routeWithParameters;
27 protected function setUp()
29 $this->routeWithParameters = new Route(
32 '_controller' => 'PHPRouter\Test\SomeController::page',
36 'target' => 'thisIsAString',
42 public function testGetUrl()
44 $this->assertEquals('/page/:page_id', $this->routeWithParameters->getUrl());
47 public function testSetUrl()
49 $this->routeWithParameters->setUrl('/pages/:page_name/');
50 $this->assertEquals('/pages/:page_name/', $this->routeWithParameters->getUrl());
52 $this->routeWithParameters->setUrl('/pages/:page_name');
53 $this->assertEquals('/pages/:page_name/', $this->routeWithParameters->getUrl());
56 public function testGetMethods()
58 $this->assertEquals(array('GET'), $this->routeWithParameters->getMethods());
61 public function testSetMethods()
63 $this->routeWithParameters->setMethods(array('POST'));
64 $this->assertEquals(array('POST'), $this->routeWithParameters->getMethods());
66 $this->routeWithParameters->setMethods(array('GET', 'POST', 'PUT', 'DELETE'));
67 $this->assertEquals(array('GET', 'POST', 'PUT', 'DELETE'), $this->routeWithParameters->getMethods());
70 public function testGetTarget()
72 $this->assertEquals('thisIsAString', $this->routeWithParameters->getTarget());
75 public function testSetTarget()
77 $this->routeWithParameters->setTarget('ThisIsAnotherString');
78 $this->assertEquals('ThisIsAnotherString', $this->routeWithParameters->getTarget());
81 public function testGetName()
83 $this->assertEquals('page', $this->routeWithParameters->getName());
86 public function testSetName()
88 $this->routeWithParameters->setName('pageroute');
89 $this->assertEquals('pageroute', $this->routeWithParameters->getName());
92 public function testGetAction()
94 $this->assertEquals('page', $this->routeWithParameters->getAction());