mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Added tests for SubsiteAdmin search
This commit is contained in:
parent
b64b14554c
commit
55eed874f3
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -34,4 +34,20 @@ Page:
|
||||
# Title: Page not Found
|
||||
# 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
|
Loading…
Reference in New Issue
Block a user