silverstripe-framework/admin/tests/SecurityAdminTest.php

76 lines
2.7 KiB
PHP
Raw Normal View History

<?php
2016-10-14 03:30:05 +02:00
namespace SilverStripe\Admin\Tests;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\FunctionalTest;
2016-10-14 03:30:05 +02:00
/**
* @package cms
* @subpackage tests
*/
class SecurityAdminTest extends FunctionalTest {
protected static $fixture_file = 'LeftAndMainTest.yml';
2014-08-15 08:53:05 +02:00
protected $extraDataObjects = array('LeftAndMainTest_Object');
// TODO Fix export feature (moved from MemberTableField to GridFieldExportButton)
// public function testGroupExport() {
// $this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
2014-08-15 08:53:05 +02:00
// /* First, open the applicable group */
// $response = $this->get('admin/security/show/' . $this->idFromFixture('Group','admin'));
// $inputs = $this->cssParser()->getBySelector('input#Form_EditForm_Title');
// $this->assertNotNull($inputs);
// $this->assertEquals('Administrators', (string)$inputs[0]['value']);
2014-08-15 08:53:05 +02:00
// /* Then load the export page */
// $this->get('admin/security/EditForm/field/Members/export');
// $lines = preg_split('/\n/', $this->content());
// $this->assertEquals(count($lines), 3, "Export with members has one content row");
// $this->assertRegExp('/"","","admin@example.com"/', $lines[1], "Member values are correctly exported");
// }
// TODO Fix export feature (moved from MemberTableField to GridFieldExportButton)
// public function testEmptyGroupExport() {
// $this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
2014-08-15 08:53:05 +02:00
// /* First, open the applicable group */
// $this->get('admin/security/show/' . $this->idFromFixture('Group','empty'));
// $inputs = $this->cssParser()->getBySelector('input#Form_EditForm_Title');
// $this->assertNotNull($inputs);
// $this->assertEquals('Empty Group', (string)$inputs[0]['value']);
2014-08-15 08:53:05 +02:00
// /* Then load the export page */
// $this->get('admin/security/EditForm/field/Members/export');
// $lines = preg_split('/\n/', $this->content());
2014-08-15 08:53:05 +02:00
// $this->assertEquals(count($lines), 2, "Empty export only has header fields and an empty row");
// $this->assertEquals($lines[1], '', "Empty export only has no content row");
// }
2014-08-15 08:53:05 +02:00
public function testPermissionFieldRespectsHiddenPermissions() {
2016-06-23 01:37:22 +02:00
$this->session()->inst_set('loggedInAs', $this->idFromFixture('SilverStripe\\Security\\Member', 'admin'));
2014-08-15 08:53:05 +02:00
2016-06-23 01:37:22 +02:00
$group = $this->objFromFixture('SilverStripe\\Security\\Group', 'admin');
2014-08-15 08:53:05 +02:00
2016-06-23 01:37:22 +02:00
Config::inst()->update('SilverStripe\\Security\\Permission', 'hidden_permissions', array('CMS_ACCESS_ReportAdmin'));
2012-05-28 02:02:47 +02:00
$response = $this->get(sprintf('admin/security/EditForm/field/Groups/item/%d/edit', $group->ID));
2014-08-15 08:53:05 +02:00
$this->assertContains(
'CMS_ACCESS_SecurityAdmin',
$response->getBody()
);
$this->assertNotContains(
'CMS_ACCESS_ReportAdmin',
$response->getBody()
);
}
}