Added tests for SubsiteAdmin search

This commit is contained in:
Sam Minnee 2007-08-17 05:50:23 +00:00
parent b64b14554c
commit 55eed874f3
3 changed files with 53 additions and 3 deletions

View File

@ -47,8 +47,8 @@ class SiteTreeSubsites extends DataObjectDecorator {
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
if(strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false) {
if($context = DataObject::context_obj()) { $subsiteID = $context->SubsiteID; }
else $subsiteID = Subsite::currentSubsiteID();
if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
else $subsiteID = (int)Subsite::currentSubsiteID();
// The foreach is an ugly way of getting the first key :-)
foreach($query->from as $tableName => $info) {

View File

@ -14,6 +14,40 @@ class SubsiteAdminTest extends SapphireTest {
$this->assertTrue($templates->onlyContainsIDs($templateIDs));
}
/**
* Test searching for an intranet
*/
function testIntranetSearch() {
$cont = new SubsiteAdmin();
$cont->pushCurrent();
$member = $this->objFromFixture('Member','admin');
$member->logIn();
// Check that the logged-in member has the correct permissions
$this->assertTrue(Permission::check('ADMIN') ? true : false);
$form = $cont->SearchForm();
$searches = array(
array('Name' => 'Other'),
array('Name' => ''),
);
foreach($searches as $search) {
$response = $form->testAjaxSubmission('getResults', $search);
echo $response->getBody();
}
/*
$this->assertHasLink($response->getBody(), 'admin/intranets/show/' . $this->idFromFixture('Subsite', 'other'));
$this->assertHasntLink($response->getBody(), 'admin/intranets/show/' . $this->idFromFixture('Subsite', 'other'));
*/
$cont->popCurrent();
}
}
?>

View File

@ -35,3 +35,19 @@ Page:
# ErrorCode: 404
# SubsiteID: =>Subsite_Template.main
Group:
admin:
Title: Admin
Member:
admin:
FirstName: Admin
Surname: User
Email: admin@test.com
Password: rangi
Groups: =>Group.admin
Permission:
admin:
Code: ADMIN
GroupID: =>Group.admin