-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,6 +194,6 @@ public function testExecute() | |
|
||
public function tearDown() | ||
{ | ||
$this->view = null; | ||
$this->app = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
/** | ||
* Utopia PHP Framework | ||
* | ||
* @package Framework | ||
* @subpackage Tests | ||
* | ||
* @link https://github.com/utopia-php/framework | ||
* @author Appwrite Team <[email protected]> | ||
* @version 1.0 RC4 | ||
* @license The MIT License (MIT) <http://www.opensource.org/licenses/mit-license.php> | ||
*/ | ||
|
||
namespace Utopia; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Utopia\Validator\Text; | ||
|
||
class RouteTest extends TestCase | ||
{ | ||
/** | ||
* @var Route | ||
*/ | ||
protected $route = null; | ||
|
||
public function setUp() | ||
{ | ||
$this->route = new Route('GET', '/'); | ||
} | ||
|
||
public function testMethod() | ||
{ | ||
$this->assertEquals('GET', $this->route->getMethod()); | ||
} | ||
|
||
public function testURL() | ||
{ | ||
$this->assertEquals('/', $this->route->getURL()); | ||
|
||
$this->route->URL('/path'); | ||
|
||
$this->assertEquals('/path', $this->route->getURL()); | ||
} | ||
|
||
public function testDesc() | ||
{ | ||
$this->assertEquals('', $this->route->getDesc()); | ||
|
||
$this->route->desc('new route'); | ||
|
||
$this->assertEquals('new route', $this->route->getDesc()); | ||
} | ||
|
||
public function testGroups() | ||
{ | ||
$this->assertEquals([], $this->route->getGroups()); | ||
|
||
$this->route->groups(['api', 'homepage']); | ||
|
||
$this->assertEquals(['api', 'homepage'], $this->route->getGroups()); | ||
} | ||
|
||
public function testAction() | ||
{ | ||
$this->assertEquals(null, $this->route->getAction()); | ||
|
||
$this->route->action(function() {return 'hello world';}); | ||
|
||
$this->assertEquals('hello world', $this->route->getAction()()); | ||
} | ||
|
||
public function testParam() | ||
{ | ||
$this->assertEquals([], $this->route->getParams()); | ||
|
||
$this->route | ||
->param('x', '', new Text(10)) | ||
->param('y', '', new Text(10)) | ||
; | ||
|
||
$this->assertCount(2, $this->route->getParams()); | ||
} | ||
|
||
public function testLabel() | ||
{ | ||
$this->assertEquals('default', $this->route->getLabel('key', 'default')); | ||
|
||
$this->route->label('key', 'value'); | ||
|
||
$this->assertEquals('value', $this->route->getLabel('key', 'default')); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
$this->route = null; | ||
} | ||
} |