MINOR Added DirectorTest->testURLParam() and DirectorTest->testURLParams() (from r104711)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112376 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-10-15 01:10:43 +00:00
parent 8ea659be69
commit ecb758de10

View File

@ -7,6 +7,20 @@
*/
class DirectorTest extends SapphireTest {
function setUp() {
parent::setUp();
Director::addRules(99, array(
'DirectorTestRule/$Action/$ID/$OtherID' => 'DirectorTestRequest_Controller'
));
}
function tearDown() {
// TODO Remove director rule, currently API doesnt allow this
parent::tearDown();
}
public function testFileExists() {
$tempFileName = 'DirectorTest_testFileExists.tmp';
$tempFilePath = TEMP_FOLDER . '/' . $tempFileName;
@ -147,6 +161,28 @@ class DirectorTest extends SapphireTest {
}
}
function testURLParam() {
Director::test('DirectorTestRule/myaction/myid/myotherid');
// TODO Works on the assumption that urlParam() is not unset after a test run, which is dodgy
$this->assertEquals(Director::urlParam('Action'), 'myaction');
$this->assertEquals(Director::urlParam('ID'), 'myid');
$this->assertEquals(Director::urlParam('OtherID'), 'myotherid');
}
function testURLParams() {
Director::test('DirectorTestRule/myaction/myid/myotherid');
// TODO Works on the assumption that urlParam() is not unset after a test run, which is dodgy
$this->assertEquals(
Director::urlParams(),
array(
'Controller' => 'DirectorTestRequest_Controller',
'Action' => 'myaction',
'ID' => 'myid',
'OtherID' => 'myotherid'
)
);
}
}
class DirectorTestRequest_Controller extends Controller implements TestOnly {