added tests to main repository.
This commit is contained in:
45
tests/suite/RouteFilterTest.php
Normal file
45
tests/suite/RouteFilterTest.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
class RouteFilerTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
$filters = array(
|
||||
'test' => function() {return 'test';},
|
||||
'vars' => function($var) {return $var;},
|
||||
'vars2' => function($var1, $var2) {return $var1.$var2;},
|
||||
);
|
||||
|
||||
System\Route\Filter::$filters = $filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testCallingUndefinedFilterThrowsException()
|
||||
{
|
||||
System\Route\Filter::call('not-found');
|
||||
}
|
||||
|
||||
public function testCallingFilterWithoutOverrideReturnsNull()
|
||||
{
|
||||
$this->assertNull(System\Route\Filter::call('test'));
|
||||
}
|
||||
|
||||
public function testCallingFilterWithOverrideReturnsResult()
|
||||
{
|
||||
$this->assertEquals(System\Route\Filter::call('test', array(), true), 'test');
|
||||
}
|
||||
|
||||
public function testCallingFilterWithParametersPassesParametersToFilter()
|
||||
{
|
||||
$this->assertEquals(System\Route\Filter::call('vars', array('test'), true), 'test');
|
||||
$this->assertEquals(System\Route\Filter::call('vars2', array('test1', 'test2'), true), 'test1test2');
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
System\Route\Filter::$filters = require APP_PATH.'filters'.EXT;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user