Permalink
Browse files

MINOR Added DirectorTest->testURLParam() and DirectorTest->testURLPar…

…ams() (from r104711)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112376 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
chillu committed Oct 15, 2010
1 parent 8ea659b commit ecb758de10b05ac723d984d469ab2997d43ffc7f
Showing with 36 additions and 0 deletions.
  1. +36 −0 tests/control/DirectorTest.php
@@ -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 @@ public function testTestRequestCarriesGlobals() {
}
}
+ 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 {

0 comments on commit ecb758d

Please sign in to comment.