Added unit test for BlogHolder_Controller's custom checkAccessAction function

This commit is contained in:
Saophalkun Ponlu 2009-07-22 03:16:06 +00:00
parent 6eebbb217c
commit 67d8a8b423
2 changed files with 13 additions and 1 deletions

View File

@ -142,7 +142,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
} }
/** /**
* TODO: this is an urgent fix to work with archive link (e.g. 2009/04) for Nelsoncc project. Replace this with something better. * TODO: this is an urgent fix to work with archive link (e.g. page_url/2009/04). Replace this with something better.
*/ */
function checkAccessAction($action) { function checkAccessAction($action) {
if (preg_match('/[0-9]{4}/', $action)) if (preg_match('/[0-9]{4}/', $action))

View File

@ -52,6 +52,18 @@ class BlogHolderTest extends SapphireTest {
$this->assertContains($entry->URLSegment, $expectedEntries); $this->assertContains($entry->URLSegment, $expectedEntries);
} }
} }
function testcheckAccessAction() {
$blogHolder = new BlogHolder_Controller();
$this->assertTrue($blogHolder->checkAccessAction('2009'));
$this->assertTrue($blogHolder->checkAccessAction('0001'));
$this->assertTrue($blogHolder->checkAccessAction('12345'));
$this->assertFalse($blogHolder->checkAccessAction('209'));
$this->assertFalse($blogHolder->checkAccessAction('123A'));
$this->assertFalse($blogHolder->checkAccessAction('ab01a'));
}
} }
?> ?>