mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #4588 from tractorcow/fix/3.1/admin-tests
BUG Fix missing framework/admin/tests
This commit is contained in:
commit
00385792c5
@ -40,6 +40,7 @@ before_script:
|
||||
|
||||
script:
|
||||
- "if [ \"$BEHAT_TEST\" = \"\" ]; then vendor/bin/phpunit framework/tests; fi"
|
||||
- "if [ \"$BEHAT_TEST\" = \"\" ]; then vendor/bin/phpunit framework/admin/tests; fi"
|
||||
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then vendor/bin/behat @framework; fi"
|
||||
|
||||
after_failure:
|
||||
|
@ -17,7 +17,7 @@ class LeftAndMainTest extends FunctionalTest {
|
||||
|
||||
// @todo fix controller stack problems and re-activate
|
||||
//$this->autoFollowRedirection = false;
|
||||
CMSMenu::populate_menu();
|
||||
$this->resetMenu();
|
||||
|
||||
$this->backupCss = Config::inst()->get('LeftAndMain', 'extra_requirements_css');
|
||||
$this->backupJs = Config::inst()->get('LeftAndMain', 'extra_requirements_javascript');
|
||||
@ -34,6 +34,23 @@ class LeftAndMainTest extends FunctionalTest {
|
||||
Requirements::set_combined_files_enabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear menu to default state as per LeftAndMain::init()
|
||||
*/
|
||||
protected function resetMenu() {
|
||||
CMSMenu::clear_menu();
|
||||
CMSMenu::populate_menu();
|
||||
CMSMenu::add_link(
|
||||
'Help',
|
||||
_t('LeftAndMain.HELP', 'Help', 'Menu title'),
|
||||
LeftAndMain::config()->help_link,
|
||||
-2,
|
||||
array(
|
||||
'target' => '_blank'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
@ -128,12 +145,13 @@ class LeftAndMainTest extends FunctionalTest {
|
||||
$adminuser = $this->objFromFixture('Member','admin');
|
||||
$this->session()->inst_set('loggedInAs', $adminuser->ID);
|
||||
|
||||
$menuItems = singleton('LeftAndMain')->MainMenu();
|
||||
$this->resetMenu();
|
||||
$menuItems = singleton('LeftAndMain')->MainMenu(false);
|
||||
foreach($menuItems as $menuItem) {
|
||||
$link = $menuItem->Link;
|
||||
|
||||
// don't test external links
|
||||
if(preg_match('/^https?:\/\//',$link)) continue;
|
||||
if(preg_match('/^(https?:)?\/\//',$link)) continue;
|
||||
|
||||
$response = $this->get($link);
|
||||
|
||||
@ -157,6 +175,7 @@ class LeftAndMainTest extends FunctionalTest {
|
||||
|
||||
// anonymous user
|
||||
$this->session()->inst_set('loggedInAs', null);
|
||||
$this->resetMenu();
|
||||
$menuItems = singleton('LeftAndMain')->MainMenu(false);
|
||||
$this->assertEquals(
|
||||
array_map($allValsFn, $menuItems->column('Code')),
|
||||
@ -165,17 +184,23 @@ class LeftAndMainTest extends FunctionalTest {
|
||||
);
|
||||
|
||||
// restricted cms user
|
||||
$this->session()->inst_set('loggedInAs', $securityonlyuser->ID);
|
||||
$this->logInAs($securityonlyuser);
|
||||
$this->resetMenu();
|
||||
$menuItems = singleton('LeftAndMain')->MainMenu(false);
|
||||
$this->assertEquals(
|
||||
array_map($allValsFn, $menuItems->column('Code')),
|
||||
array('SecurityAdmin','Help'),
|
||||
array('CMSProfileController', 'SecurityAdmin','Help'),
|
||||
'Groups with limited access can only access the interfaces they have permissions for'
|
||||
);
|
||||
|
||||
// all cms sections user
|
||||
$this->session()->inst_set('loggedInAs', $allcmssectionsuser->ID);
|
||||
$this->logInAs($allcmssectionsuser);
|
||||
$this->resetMenu();
|
||||
$menuItems = singleton('LeftAndMain')->MainMenu(false);
|
||||
$this->assertContains('CMSProfileController',
|
||||
array_map($allValsFn, $menuItems->column('Code')),
|
||||
'Group with CMS_ACCESS_LeftAndMain permission can edit own profile'
|
||||
);
|
||||
$this->assertContains('SecurityAdmin',
|
||||
array_map($allValsFn, $menuItems->column('Code')),
|
||||
'Group with CMS_ACCESS_LeftAndMain permission can access all sections'
|
||||
@ -186,7 +211,8 @@ class LeftAndMainTest extends FunctionalTest {
|
||||
);
|
||||
|
||||
// admin
|
||||
$this->session()->inst_set('loggedInAs', $adminuser->ID);
|
||||
$this->logInAs($adminuser);
|
||||
$this->resetMenu();
|
||||
$menuItems = singleton('LeftAndMain')->MainMenu(false);
|
||||
$this->assertContains(
|
||||
'SecurityAdmin',
|
||||
@ -266,6 +292,8 @@ class LeftAndMainTest_Object extends DataObject implements TestOnly {
|
||||
'Sort' => 'Int',
|
||||
);
|
||||
|
||||
private static $default_sort = '"Sort"';
|
||||
|
||||
private static $extensions = array(
|
||||
'Hierarchy'
|
||||
);
|
||||
|
@ -732,7 +732,7 @@ class Hierarchy extends DataExtension {
|
||||
|
||||
$children = $baseClass::get()
|
||||
->filter('ParentID', (int)$this->owner->ID)
|
||||
->sort('Sort', 'ASC');
|
||||
->sort('"Sort"', 'ASC');
|
||||
if ($afterNode) {
|
||||
$children = $children->filter('Sort:GreaterThan', $afterNode->Sort);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user