mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Removed reliance of sapphire/admin unit tests on SiteTree and CMSMain
This commit is contained in:
parent
9d742f02f2
commit
95dcc74c10
@ -13,13 +13,13 @@ class CMSMenuTest extends SapphireTest implements TestOnly {
|
|||||||
$this->assertTrue((empty($menuItems)), 'Menu can be cleared');
|
$this->assertTrue((empty($menuItems)), 'Menu can be cleared');
|
||||||
|
|
||||||
// Add a controller to the menu and check it is as expected
|
// Add a controller to the menu and check it is as expected
|
||||||
CMSMenu::add_controller('CMSMain');
|
CMSMenu::add_controller('CMSMenuTest_LeftAndMainController');
|
||||||
$menuItems = CMSMenu::get_menu_items();
|
$menuItems = CMSMenu::get_menu_items();
|
||||||
$menuItem = $menuItems['CMSMain'];
|
$menuItem = $menuItems['CMSMenuTest_LeftAndMainController'];
|
||||||
$this->assertType('CMSMenuItem', $menuItem, 'Controller menu item is of class CMSMenuItem');
|
$this->assertType('CMSMenuItem', $menuItem, 'Controller menu item is of class CMSMenuItem');
|
||||||
$this->assertEquals($menuItem->url, singleton('CMSMain')->Link(), 'Controller menu item has the correct link');
|
$this->assertEquals($menuItem->url, singleton('CMSMenuTest_LeftAndMainController')->Link(), 'Controller menu item has the correct link');
|
||||||
$this->assertEquals($menuItem->controller, 'CMSMain', 'Controller menu item has the correct controller class');
|
$this->assertEquals($menuItem->controller, 'CMSMenuTest_LeftAndMainController', 'Controller menu item has the correct controller class');
|
||||||
$this->assertEquals($menuItem->priority, singleton('CMSMain')->stat('menu_priority'), 'Controller menu item has the correct priority');
|
$this->assertEquals($menuItem->priority, singleton('CMSMenuTest_LeftAndMainController')->stat('menu_priority'), 'Controller menu item has the correct priority');
|
||||||
CMSMenu::clear_menu();
|
CMSMenu::clear_menu();
|
||||||
|
|
||||||
// Add a link to the menu
|
// Add a link to the menu
|
||||||
@ -38,10 +38,10 @@ class CMSMenuTest extends SapphireTest implements TestOnly {
|
|||||||
public function testCmsClassDetection() {
|
public function testCmsClassDetection() {
|
||||||
|
|
||||||
// Get CMS classes and check that:
|
// Get CMS classes and check that:
|
||||||
// 1.) CMSMain is included
|
// 1.) SecurityAdmin is included
|
||||||
// 2.) LeftAndMain & ModelAdmin are excluded
|
// 2.) LeftAndMain & ModelAdmin are excluded
|
||||||
$cmsClasses = CMSMenu::get_cms_classes();
|
$cmsClasses = CMSMenu::get_cms_classes();
|
||||||
$this->assertContains('CMSMain', $cmsClasses, 'CMSMain included in valid CMS Classes');
|
$this->assertContains('SecurityAdmin', $cmsClasses, 'SecurityAdmin included in valid CMS Classes');
|
||||||
$this->assertNotContains('LeftAndMain', $cmsClasses, 'LeftAndMain not included in valid CMS Classes');
|
$this->assertNotContains('LeftAndMain', $cmsClasses, 'LeftAndMain not included in valid CMS Classes');
|
||||||
$this->assertNotContains('ModelAdmin', $cmsClasses, 'LeftAndMain not included in valid CMS Classes');
|
$this->assertNotContains('ModelAdmin', $cmsClasses, 'LeftAndMain not included in valid CMS Classes');
|
||||||
|
|
||||||
@ -49,16 +49,16 @@ class CMSMenuTest extends SapphireTest implements TestOnly {
|
|||||||
|
|
||||||
public function testAdvancedMenuHandling() {
|
public function testAdvancedMenuHandling() {
|
||||||
|
|
||||||
// Populate from CMS Classes, check for existance of CMSMain
|
// Populate from CMS Classes, check for existance of SecurityAdmin
|
||||||
CMSMenu::clear_menu();
|
CMSMenu::clear_menu();
|
||||||
CMSMenu::populate_menu();
|
CMSMenu::populate_menu();
|
||||||
$menuItem = CMSMenu::get_menu_item('CMSMain');
|
$menuItem = CMSMenu::get_menu_item('SecurityAdmin');
|
||||||
$this->assertType('CMSMenuItem', $menuItem, 'CMSMain menu item exists');
|
$this->assertType('CMSMenuItem', $menuItem, 'SecurityAdmin menu item exists');
|
||||||
$this->assertEquals($menuItem->url, singleton('CMSMain')->Link(), 'Menu item has the correct link');
|
$this->assertEquals($menuItem->url, singleton('SecurityAdmin')->Link(), 'Menu item has the correct link');
|
||||||
$this->assertEquals($menuItem->controller, 'CMSMain', 'Menu item has the correct controller class');
|
$this->assertEquals($menuItem->controller, 'SecurityAdmin', 'Menu item has the correct controller class');
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$menuItem->priority,
|
$menuItem->priority,
|
||||||
singleton('CMSMain')->stat('menu_priority'),
|
singleton('SecurityAdmin')->stat('menu_priority'),
|
||||||
'Menu item has the correct priority'
|
'Menu item has the correct priority'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -77,3 +77,9 @@ class CMSMenuTest extends SapphireTest implements TestOnly {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CMSMenuTest_LeftAndMainController extends LeftAndMain implements TestOnly {
|
||||||
|
static $url_segment = 'CMSMenuTest_LeftAndMainController';
|
||||||
|
static $menu_title = 'CMSMenuTest_LeftAndMainController';
|
||||||
|
static $menu_priority = 50;
|
||||||
|
}
|
@ -4,7 +4,10 @@
|
|||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
*/
|
*/
|
||||||
class LeftAndMainTest extends FunctionalTest {
|
class LeftAndMainTest extends FunctionalTest {
|
||||||
static $fixture_file = 'cms/tests/CMSMainTest.yml';
|
|
||||||
|
static $fixture_file = 'sapphire/admin/tests/LeftAndMainTest.yml';
|
||||||
|
|
||||||
|
protected $extraDataObjects = array('LeftAndMainTest_Object');
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@ -14,10 +17,14 @@ class LeftAndMainTest extends FunctionalTest {
|
|||||||
CMSMenu::populate_menu();
|
CMSMenu::populate_menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note: This test would typically rely on SiteTree and CMSMain, but is mocked by
|
||||||
|
* LeftAndMain_Controller and LeftAndMain_Object here to remove this dependency.
|
||||||
|
*/
|
||||||
public function testSaveTreeNodeSorting() {
|
public function testSaveTreeNodeSorting() {
|
||||||
$this->loginWithPermission('ADMIN');
|
$this->loginWithPermission('ADMIN');
|
||||||
|
|
||||||
$rootPages = DataObject::get('SiteTree', '"ParentID" = 0'); // implicitly sorted
|
$rootPages = DataObject::get('LeftAndMainTest_Object', '"ParentID" = 0'); // implicitly sorted
|
||||||
$siblingIDs = $rootPages->column('ID');
|
$siblingIDs = $rootPages->column('ID');
|
||||||
$page1 = $rootPages->offsetGet(0);
|
$page1 = $rootPages->offsetGet(0);
|
||||||
$page2 = $rootPages->offsetGet(1);
|
$page2 = $rootPages->offsetGet(1);
|
||||||
@ -32,11 +39,11 @@ class LeftAndMainTest extends FunctionalTest {
|
|||||||
'ParentID' => 0
|
'ParentID' => 0
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $this->post('admin/savetreenode', $data);
|
$response = $this->post('LeftAndMainTest_Controller/savetreenode', $data);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$page1 = DataObject::get_by_id('SiteTree', $page1->ID, false);
|
$page1 = DataObject::get_by_id('LeftAndMainTest_Object', $page1->ID, false);
|
||||||
$page2 = DataObject::get_by_id('SiteTree', $page2->ID, false);
|
$page2 = DataObject::get_by_id('LeftAndMainTest_Object', $page2->ID, false);
|
||||||
$page3 = DataObject::get_by_id('SiteTree', $page3->ID, false);
|
$page3 = DataObject::get_by_id('LeftAndMainTest_Object', $page3->ID, false);
|
||||||
|
|
||||||
$this->assertEquals(2, $page1->Sort, 'Page1 is sorted after Page2');
|
$this->assertEquals(2, $page1->Sort, 'Page1 is sorted after Page2');
|
||||||
$this->assertEquals(1, $page2->Sort, 'Page2 is sorted before Page1');
|
$this->assertEquals(1, $page2->Sort, 'Page2 is sorted before Page1');
|
||||||
@ -46,11 +53,11 @@ class LeftAndMainTest extends FunctionalTest {
|
|||||||
public function testSaveTreeNodeParentID() {
|
public function testSaveTreeNodeParentID() {
|
||||||
$this->loginWithPermission('ADMIN');
|
$this->loginWithPermission('ADMIN');
|
||||||
|
|
||||||
$page1 = $this->objFromFixture('Page', 'page1');
|
$page1 = $this->objFromFixture('LeftAndMainTest_Object', 'page1');
|
||||||
$page2 = $this->objFromFixture('Page', 'page2');
|
$page2 = $this->objFromFixture('LeftAndMainTest_Object', 'page2');
|
||||||
$page3 = $this->objFromFixture('Page', 'page3');
|
$page3 = $this->objFromFixture('LeftAndMainTest_Object', 'page3');
|
||||||
$page31 = $this->objFromFixture('Page', 'page31');
|
$page31 = $this->objFromFixture('LeftAndMainTest_Object', 'page31');
|
||||||
$page32 = $this->objFromFixture('Page', 'page32');
|
$page32 = $this->objFromFixture('LeftAndMainTest_Object', 'page32');
|
||||||
|
|
||||||
// Move page2 into page3, between page3.1 and page 3.2
|
// Move page2 into page3, between page3.1 and page 3.2
|
||||||
$siblingIDs = array(
|
$siblingIDs = array(
|
||||||
@ -63,11 +70,11 @@ class LeftAndMainTest extends FunctionalTest {
|
|||||||
'ID' => $page2->ID,
|
'ID' => $page2->ID,
|
||||||
'ParentID' => $page3->ID
|
'ParentID' => $page3->ID
|
||||||
);
|
);
|
||||||
$response = $this->post('admin/savetreenode', $data);
|
$response = $this->post('LeftAndMainTest_Controller/savetreenode', $data);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$page2 = DataObject::get_by_id('SiteTree', $page2->ID, false);
|
$page2 = DataObject::get_by_id('LeftAndMainTest_Object', $page2->ID, false);
|
||||||
$page31 = DataObject::get_by_id('SiteTree', $page31->ID, false);
|
$page31 = DataObject::get_by_id('LeftAndMainTest_Object', $page31->ID, false);
|
||||||
$page32 = DataObject::get_by_id('SiteTree', $page32->ID, false);
|
$page32 = DataObject::get_by_id('LeftAndMainTest_Object', $page32->ID, false);
|
||||||
|
|
||||||
$this->assertEquals($page3->ID, $page2->ParentID, 'Moved page gets new parent');
|
$this->assertEquals($page3->ID, $page2->ParentID, 'Moved page gets new parent');
|
||||||
$this->assertEquals(1, $page31->Sort, 'Children pages before insertaion are unaffected');
|
$this->assertEquals(1, $page31->Sort, 'Children pages before insertaion are unaffected');
|
||||||
@ -101,7 +108,7 @@ class LeftAndMainTest extends FunctionalTest {
|
|||||||
$adminuser = $this->objFromFixture('Member','admin');
|
$adminuser = $this->objFromFixture('Member','admin');
|
||||||
$this->session()->inst_set('loggedInAs', $adminuser->ID);
|
$this->session()->inst_set('loggedInAs', $adminuser->ID);
|
||||||
|
|
||||||
$menuItems = singleton('CMSMain')->MainMenu();
|
$menuItems = singleton('LeftAndMain')->MainMenu();
|
||||||
foreach($menuItems as $menuItem) {
|
foreach($menuItems as $menuItem) {
|
||||||
$link = $menuItem->Link;
|
$link = $menuItem->Link;
|
||||||
|
|
||||||
@ -124,7 +131,7 @@ class LeftAndMainTest extends FunctionalTest {
|
|||||||
|
|
||||||
function testCanView() {
|
function testCanView() {
|
||||||
$adminuser = $this->objFromFixture('Member', 'admin');
|
$adminuser = $this->objFromFixture('Member', 'admin');
|
||||||
$assetsonlyuser = $this->objFromFixture('Member', 'assetsonlyuser');
|
$securityonlyuser = $this->objFromFixture('Member', 'securityonlyuser');
|
||||||
$allcmssectionsuser = $this->objFromFixture('Member', 'allcmssectionsuser');
|
$allcmssectionsuser = $this->objFromFixture('Member', 'allcmssectionsuser');
|
||||||
|
|
||||||
// anonymous user
|
// anonymous user
|
||||||
@ -137,21 +144,21 @@ class LeftAndMainTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// restricted cms user
|
// restricted cms user
|
||||||
$this->session()->inst_set('loggedInAs', $assetsonlyuser->ID);
|
$this->session()->inst_set('loggedInAs', $securityonlyuser->ID);
|
||||||
$menuItems = singleton('LeftAndMain')->MainMenu();
|
$menuItems = singleton('LeftAndMain')->MainMenu();
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$menuItems->column('Code'),
|
$menuItems->column('Code'),
|
||||||
array('AssetAdmin','Help'),
|
array('SecurityAdmin','Help'),
|
||||||
'Groups with limited access can only access the interfaces they have permissions for'
|
'Groups with limited access can only access the interfaces they have permissions for'
|
||||||
);
|
);
|
||||||
|
|
||||||
// all cms sections user
|
// all cms sections user
|
||||||
$this->session()->inst_set('loggedInAs', $allcmssectionsuser->ID);
|
$this->session()->inst_set('loggedInAs', $allcmssectionsuser->ID);
|
||||||
$menuItems = singleton('LeftAndMain')->MainMenu();
|
$menuItems = singleton('LeftAndMain')->MainMenu();
|
||||||
$requiredSections = array('CMSMain','AssetAdmin','SecurityAdmin','Help');
|
$this->assertContains('SecurityAdmin', $menuItems->column('Code'),
|
||||||
$this->assertEquals(
|
'Group with CMS_ACCESS_LeftAndMain permission can access all sections'
|
||||||
array_diff($requiredSections, $menuItems->column('Code')),
|
);
|
||||||
array(),
|
$this->assertContains('Help', $menuItems->column('Code'),
|
||||||
'Group with CMS_ACCESS_LeftAndMain permission can access all sections'
|
'Group with CMS_ACCESS_LeftAndMain permission can access all sections'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -159,14 +166,9 @@ class LeftAndMainTest extends FunctionalTest {
|
|||||||
$this->session()->inst_set('loggedInAs', $adminuser->ID);
|
$this->session()->inst_set('loggedInAs', $adminuser->ID);
|
||||||
$menuItems = singleton('LeftAndMain')->MainMenu();
|
$menuItems = singleton('LeftAndMain')->MainMenu();
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
'CMSMain',
|
'SecurityAdmin',
|
||||||
$menuItems->column('Code'),
|
$menuItems->column('Code'),
|
||||||
'Administrators can access CMS'
|
'Administrators can access Security Admin'
|
||||||
);
|
|
||||||
$this->assertContains(
|
|
||||||
'AssetAdmin',
|
|
||||||
$menuItems->column('Code'),
|
|
||||||
'Administrators can access Assets'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->session()->inst_set('loggedInAs', null);
|
$this->session()->inst_set('loggedInAs', null);
|
||||||
@ -174,3 +176,22 @@ class LeftAndMainTest extends FunctionalTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class LeftAndMainTest_Controller extends LeftAndMain implements TestOnly {
|
||||||
|
protected $template = 'BlankPage';
|
||||||
|
|
||||||
|
static $tree_class = 'LeftAndMainTest_Object';
|
||||||
|
}
|
||||||
|
|
||||||
|
class LeftAndMainTest_Object extends DataObject implements TestOnly {
|
||||||
|
|
||||||
|
static $db = array(
|
||||||
|
'Title' => 'Varchar',
|
||||||
|
'URLSegment' => 'Varchar',
|
||||||
|
'Sort' => 'Int',
|
||||||
|
);
|
||||||
|
|
||||||
|
static $extensions = array(
|
||||||
|
'Hierarchy'
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
Page:
|
LeftAndMainTest_Object:
|
||||||
page1:
|
page1:
|
||||||
Title: Page 1
|
Title: Page 1
|
||||||
page2:
|
page2:
|
||||||
@ -7,10 +7,10 @@ Page:
|
|||||||
Title: Page 3
|
Title: Page 3
|
||||||
page31:
|
page31:
|
||||||
Title: Page 3.1
|
Title: Page 3.1
|
||||||
Parent: =>Page.page3
|
Parent: =>LeftAndMainTest_Object.page3
|
||||||
page32:
|
page32:
|
||||||
Title: Page 3.2
|
Title: Page 3.2
|
||||||
Parent: =>Page.page3
|
Parent: =>LeftAndMainTest_Object.page3
|
||||||
page4:
|
page4:
|
||||||
Title: Page 4
|
Title: Page 4
|
||||||
page5:
|
page5:
|
||||||
@ -65,8 +65,8 @@ Group:
|
|||||||
Title: Administrators
|
Title: Administrators
|
||||||
empty:
|
empty:
|
||||||
Title: Empty Group
|
Title: Empty Group
|
||||||
assetsonly:
|
securityonly:
|
||||||
Title: assetsonly
|
Title: securityonly
|
||||||
allcmssections:
|
allcmssections:
|
||||||
Title: allcmssections
|
Title: allcmssections
|
||||||
rooteditusers:
|
rooteditusers:
|
||||||
@ -76,9 +76,9 @@ Member:
|
|||||||
Email: admin@example.com
|
Email: admin@example.com
|
||||||
Password: ZXXlkwecxz2390232233
|
Password: ZXXlkwecxz2390232233
|
||||||
Groups: =>Group.admin
|
Groups: =>Group.admin
|
||||||
assetsonlyuser:
|
securityonlyuser:
|
||||||
Email: assetsonlyuser@test.com
|
Email: securityonlyuser@test.com
|
||||||
Groups: =>Group.assetsonly
|
Groups: =>Group.securityonly
|
||||||
allcmssectionsuser:
|
allcmssectionsuser:
|
||||||
Email: allcmssectionsuser@test.com
|
Email: allcmssectionsuser@test.com
|
||||||
Groups: =>Group.allcmssections
|
Groups: =>Group.allcmssections
|
||||||
@ -89,25 +89,12 @@ Permission:
|
|||||||
admin:
|
admin:
|
||||||
Code: ADMIN
|
Code: ADMIN
|
||||||
GroupID: =>Group.admin
|
GroupID: =>Group.admin
|
||||||
assetsonly:
|
securityonly:
|
||||||
Code: CMS_ACCESS_AssetAdmin
|
Code: CMS_ACCESS_SecurityAdmin
|
||||||
GroupID: =>Group.assetsonly
|
GroupID: =>Group.securityonly
|
||||||
allcmssections:
|
allcmssections:
|
||||||
Code: CMS_ACCESS_LeftAndMain
|
Code: CMS_ACCESS_LeftAndMain
|
||||||
GroupID: =>Group.allcmssections
|
GroupID: =>Group.allcmssections
|
||||||
allcmssections2:
|
allcmssections2:
|
||||||
Code: CMS_ACCESS_LeftAndMain
|
Code: CMS_ACCESS_LeftAndMain
|
||||||
GroupID: =>Group.rooteditusers
|
GroupID: =>Group.rooteditusers
|
||||||
SiteConfig:
|
|
||||||
siteconfig1:
|
|
||||||
EditorGroups: =>Group.rooteditusers
|
|
||||||
CanCreateTopLevelType: 'OnlyTheseUsers'
|
|
||||||
SiteConfig_CreateTopLevelGroups:
|
|
||||||
createtoplevelgroups1:
|
|
||||||
SiteConfigID: =>SiteConfig.siteconfig1
|
|
||||||
GroupID: =>Group.rooteditusers
|
|
||||||
RedirectorPage:
|
|
||||||
page5:
|
|
||||||
Title: Page 5
|
|
||||||
RedirectionType: External
|
|
||||||
ExternalURL: http://www.google.com
|
|
||||||
|
@ -4,8 +4,11 @@
|
|||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
*/
|
*/
|
||||||
class SecurityAdminTest extends FunctionalTest {
|
class SecurityAdminTest extends FunctionalTest {
|
||||||
|
|
||||||
static $fixture_file = 'sapphire/admin/tests/LeftAndMainTest.yml';
|
static $fixture_file = 'sapphire/admin/tests/LeftAndMainTest.yml';
|
||||||
|
|
||||||
|
protected $extraDataObjects = array('LeftAndMainTest_Object');
|
||||||
|
|
||||||
function testGroupExport() {
|
function testGroupExport() {
|
||||||
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
|
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
|
||||||
|
|
||||||
@ -70,7 +73,7 @@ class SecurityAdminTest extends FunctionalTest {
|
|||||||
$response = $this->get('admin/security/show/' . $group->ID);
|
$response = $this->get('admin/security/show/' . $group->ID);
|
||||||
|
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
'CMS_ACCESS_CMSMain',
|
'CMS_ACCESS_SecurityAdmin',
|
||||||
$response->getBody()
|
$response->getBody()
|
||||||
);
|
);
|
||||||
$this->assertNotContains(
|
$this->assertNotContains(
|
||||||
|
@ -56,17 +56,20 @@ class ClassInfoTest extends SapphireTest {
|
|||||||
* @covers ClassInfo::ancestry()
|
* @covers ClassInfo::ancestry()
|
||||||
*/
|
*/
|
||||||
public function testAncestry() {
|
public function testAncestry() {
|
||||||
$ancestry = ClassInfo::ancestry('SiteTree');
|
$ancestry = ClassInfo::ancestry('ClassInfoTest_ChildClass');
|
||||||
$expect = ArrayLib::valuekey(array(
|
$expect = ArrayLib::valuekey(array(
|
||||||
'Object',
|
'Object',
|
||||||
'ViewableData',
|
'ViewableData',
|
||||||
'DataObject',
|
'DataObject',
|
||||||
'SiteTree'
|
'ClassInfoTest_BaseClass',
|
||||||
|
'ClassInfoTest_ChildClass',
|
||||||
));
|
));
|
||||||
$this->assertEquals($expect, $ancestry);
|
$this->assertEquals($expect, $ancestry);
|
||||||
|
|
||||||
$ancestry = ClassInfo::ancestry('SiteTree', true);
|
$ancestry = ClassInfo::ancestry('ClassInfoTest_ChildClass', true);
|
||||||
$this->assertEquals(array('SiteTree' => 'SiteTree'), $ancestry);
|
$this->assertEquals(array('ClassInfoTest_BaseClass' => 'ClassInfoTest_BaseClass'), $ancestry,
|
||||||
|
'$tablesOnly option excludes memory-only inheritance classes'
|
||||||
|
);
|
||||||
|
|
||||||
$this->setExpectedException('Exception');
|
$this->setExpectedException('Exception');
|
||||||
ClassInfo::ancestry(42);
|
ClassInfo::ancestry(42);
|
||||||
|
@ -39,8 +39,8 @@ class TableFieldTest extends SapphireTest {
|
|||||||
$tableField->setValue(array(
|
$tableField->setValue(array(
|
||||||
'new' => array(
|
'new' => array(
|
||||||
'Code' => array(
|
'Code' => array(
|
||||||
'CMS_ACCESS_CMSMain',
|
'CustomPerm1',
|
||||||
'CMS_ACCESS_AssetAdmin',
|
'CustomPerm2',
|
||||||
),
|
),
|
||||||
'Arg' => array(
|
'Arg' => array(
|
||||||
'1',
|
'1',
|
||||||
@ -53,8 +53,8 @@ class TableFieldTest extends SapphireTest {
|
|||||||
// Let's check that the 2 permissions entries have been saved
|
// Let's check that the 2 permissions entries have been saved
|
||||||
$permissions = $group->Permissions()->toDropdownMap('Arg', 'Code');
|
$permissions = $group->Permissions()->toDropdownMap('Arg', 'Code');
|
||||||
$this->assertEquals(array(
|
$this->assertEquals(array(
|
||||||
1 => 'CMS_ACCESS_CMSMain',
|
1 => 'CustomPerm1',
|
||||||
2 => 'CMS_ACCESS_AssetAdmin',
|
2 => 'CustomPerm2',
|
||||||
), $permissions);
|
), $permissions);
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ class TableFieldTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
$value['new'] = array(
|
$value['new'] = array(
|
||||||
'Code' => array(
|
'Code' => array(
|
||||||
'CMS_ACCESS_NewsletterAdmin',
|
'CustomPerm3',
|
||||||
),
|
),
|
||||||
'Arg' => array(
|
'Arg' => array(
|
||||||
'3',
|
'3',
|
||||||
@ -77,9 +77,9 @@ class TableFieldTest extends SapphireTest {
|
|||||||
// Let's check that the 2 existing permissions entries, and the 1 new one, have been saved
|
// Let's check that the 2 existing permissions entries, and the 1 new one, have been saved
|
||||||
$permissions = $group->Permissions()->toDropdownMap('Arg', 'Code');
|
$permissions = $group->Permissions()->toDropdownMap('Arg', 'Code');
|
||||||
$this->assertEquals(array(
|
$this->assertEquals(array(
|
||||||
1 => 'CMS_ACCESS_CMSMain',
|
1 => 'CustomPerm1',
|
||||||
2 => 'CMS_ACCESS_AssetAdmin',
|
2 => 'CustomPerm2',
|
||||||
3 => 'CMS_ACCESS_NewsletterAdmin',
|
3 => 'CustomPerm3',
|
||||||
), $permissions);
|
), $permissions);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,14 @@ class PermissionTest extends SapphireTest {
|
|||||||
|
|
||||||
function testPermissionAreInheritedFromOneRole() {
|
function testPermissionAreInheritedFromOneRole() {
|
||||||
$member = $this->objFromFixture('Member', 'author');
|
$member = $this->objFromFixture('Member', 'author');
|
||||||
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_CMSMain"));
|
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_MyAdmin"));
|
||||||
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_AssetAdmin"));
|
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_AssetAdmin"));
|
||||||
$this->assertFalse(Permission::checkMember($member, "CMS_ACCESS_SecurityAdmin"));
|
$this->assertFalse(Permission::checkMember($member, "CMS_ACCESS_SecurityAdmin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testPermissionAreInheritedFromMultipleRoles() {
|
function testPermissionAreInheritedFromMultipleRoles() {
|
||||||
$member = $this->objFromFixture('Member', 'access');
|
$member = $this->objFromFixture('Member', 'access');
|
||||||
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_CMSMain"));
|
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_MyAdmin"));
|
||||||
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_AssetAdmin"));
|
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_AssetAdmin"));
|
||||||
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_SecurityAdmin"));
|
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_SecurityAdmin"));
|
||||||
$this->assertTrue(Permission::checkMember($member, "EDIT_PERMISSIONS"));
|
$this->assertTrue(Permission::checkMember($member, "EDIT_PERMISSIONS"));
|
||||||
@ -41,7 +41,7 @@ class PermissionTest extends SapphireTest {
|
|||||||
$this->assertTrue(Permission::checkMember($member, "SITETREE_EDIT_ALL"));
|
$this->assertTrue(Permission::checkMember($member, "SITETREE_EDIT_ALL"));
|
||||||
|
|
||||||
// Check that roles from parent groups are there
|
// Check that roles from parent groups are there
|
||||||
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_CMSMain"));
|
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_MyAdmin"));
|
||||||
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_AssetAdmin"));
|
$this->assertTrue(Permission::checkMember($member, "CMS_ACCESS_AssetAdmin"));
|
||||||
|
|
||||||
// Check that permissions from parent groups are there
|
// Check that permissions from parent groups are there
|
||||||
|
@ -7,7 +7,7 @@ PermissionRole:
|
|||||||
PermissionRoleCode:
|
PermissionRoleCode:
|
||||||
author1:
|
author1:
|
||||||
Role: =>PermissionRole.author
|
Role: =>PermissionRole.author
|
||||||
Code: CMS_ACCESS_CMSMain
|
Code: CMS_ACCESS_MyAdmin
|
||||||
author2:
|
author2:
|
||||||
Role: =>PermissionRole.author
|
Role: =>PermissionRole.author
|
||||||
Code: CMS_ACCESS_AssetAdmin
|
Code: CMS_ACCESS_AssetAdmin
|
||||||
|
Loading…
Reference in New Issue
Block a user