2008-04-06 05:38:27 +02:00
|
|
|
<?php
|
2008-06-15 15:33:53 +02:00
|
|
|
/**
|
|
|
|
* @package cms
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
2008-12-11 23:25:42 +01:00
|
|
|
class LeftAndMainTest extends FunctionalTest {
|
2008-11-21 02:12:30 +01:00
|
|
|
static $fixture_file = 'cms/tests/CMSMainTest.yml';
|
|
|
|
|
2008-12-11 23:25:42 +01:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
// @todo fix controller stack problems and re-activate
|
|
|
|
//$this->autoFollowRedirection = false;
|
2009-05-06 00:12:38 +02:00
|
|
|
CMSMenu::populate_menu();
|
2008-12-11 23:25:42 +01:00
|
|
|
}
|
|
|
|
|
2008-11-21 02:12:30 +01:00
|
|
|
/**
|
|
|
|
* Check that all subclasses of leftandmain can be accessed
|
|
|
|
*/
|
|
|
|
public function testLeftAndMainSubclasses() {
|
2008-12-11 23:25:42 +01:00
|
|
|
$adminuser = $this->objFromFixture('Member','admin');
|
|
|
|
$this->session()->inst_set('loggedInAs', $adminuser->ID);
|
2008-11-21 02:12:30 +01:00
|
|
|
|
2008-12-11 23:25:42 +01:00
|
|
|
$menuItems = singleton('CMSMain')->MainMenu();
|
2008-11-21 02:12:30 +01:00
|
|
|
foreach($menuItems as $menuItem) {
|
|
|
|
$link = $menuItem->Link;
|
2008-12-11 23:25:42 +01:00
|
|
|
|
|
|
|
// don't test external links
|
2008-11-21 02:12:30 +01:00
|
|
|
if(preg_match('/^https?:\/\//',$link)) continue;
|
|
|
|
|
2008-12-11 23:25:42 +01:00
|
|
|
$response = $this->get($link);
|
|
|
|
|
2008-11-21 02:12:30 +01:00
|
|
|
$this->assertType('HTTPResponse', $response, "$link should return a response object");
|
|
|
|
$this->assertEquals(200, $response->getStatusCode(), "$link should return 200 status code");
|
|
|
|
// Check that a HTML page has been returned
|
|
|
|
$this->assertRegExp('/<html[^>]*>/i', $response->getBody(), "$link should contain <html> tag");
|
|
|
|
$this->assertRegExp('/<head[^>]*>/i', $response->getBody(), "$link should contain <head> tag");
|
|
|
|
$this->assertRegExp('/<body[^>]*>/i', $response->getBody(), "$link should contain <body> tag");
|
|
|
|
}
|
2008-12-11 23:25:42 +01:00
|
|
|
|
|
|
|
$this->session()->inst_set('loggedInAs', null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testCanView() {
|
|
|
|
$adminuser = $this->objFromFixture('Member', 'admin');
|
|
|
|
$assetsonlyuser = $this->objFromFixture('Member', 'assetsonlyuser');
|
|
|
|
|
|
|
|
// anonymous user
|
|
|
|
$this->session()->inst_set('loggedInAs', null);
|
|
|
|
$menuItems = singleton('LeftAndMain')->MainMenu();
|
|
|
|
$this->assertEquals(
|
|
|
|
$menuItems->column('Code'),
|
|
|
|
array(),
|
|
|
|
'Without valid login, members cant access any menu entries'
|
|
|
|
);
|
|
|
|
|
|
|
|
// restricted cms user
|
|
|
|
$this->session()->inst_set('loggedInAs', $assetsonlyuser->ID);
|
|
|
|
$menuItems = singleton('LeftAndMain')->MainMenu();
|
|
|
|
$this->assertEquals(
|
|
|
|
$menuItems->column('Code'),
|
|
|
|
array('AssetAdmin','Help'),
|
|
|
|
'Groups with limited access can only access the interfaces they have permissions for'
|
|
|
|
);
|
|
|
|
|
|
|
|
// admin
|
|
|
|
$this->session()->inst_set('loggedInAs', $adminuser->ID);
|
|
|
|
$menuItems = singleton('LeftAndMain')->MainMenu();
|
|
|
|
$this->assertContains(
|
|
|
|
'CMSMain',
|
|
|
|
$menuItems->column('Code'),
|
|
|
|
'Administrators can access CMS'
|
|
|
|
);
|
|
|
|
$this->assertContains(
|
|
|
|
'AssetAdmin',
|
|
|
|
$menuItems->column('Code'),
|
|
|
|
'Administrators can access Assets'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->session()->inst_set('loggedInAs', null);
|
2008-11-21 02:12:30 +01:00
|
|
|
}
|
2008-04-06 05:38:27 +02:00
|
|
|
|
|
|
|
}
|
2008-11-21 02:12:30 +01:00
|
|
|
|