2011-03-18 04:17:04 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2011-03-22 10:47:26 +01:00
|
|
|
* @package cms
|
2011-03-18 04:17:04 +01:00
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class ContentControllerPermissionTest extends FunctionalTest {
|
|
|
|
|
|
|
|
protected $usesDatabase = true;
|
|
|
|
|
|
|
|
protected $autoFollowRedirection = false;
|
|
|
|
|
|
|
|
public function testCanViewStage() {
|
|
|
|
$page = new Page();
|
|
|
|
$page->URLSegment = 'testpage';
|
|
|
|
$page->write();
|
|
|
|
$page->publish('Stage', 'Live');
|
|
|
|
|
|
|
|
$response = $this->get('/testpage');
|
2011-05-19 11:26:09 +02:00
|
|
|
$this->assertEquals($response->getStatusCode(), 200, 'Doesnt require login for implicit live stage');
|
2011-03-18 04:17:04 +01:00
|
|
|
|
|
|
|
$response = $this->get('/testpage/?stage=Live');
|
2011-05-19 11:26:09 +02:00
|
|
|
$this->assertEquals($response->getStatusCode(), 200, 'Doesnt require login for explicit live stage');
|
2011-03-18 04:17:04 +01:00
|
|
|
|
|
|
|
$response = $this->get('/testpage/?stage=Stage');
|
|
|
|
// should redirect to login
|
2011-05-19 11:26:09 +02:00
|
|
|
$this->assertEquals($response->getStatusCode(), 302, 'Redirects to login page when not logged in for draft stage');
|
|
|
|
$this->assertContains('Security/login', $response->getHeader('Location'));
|
2011-03-18 04:17:04 +01:00
|
|
|
|
|
|
|
$this->logInWithPermission('CMS_ACCESS_CMSMain');
|
|
|
|
|
|
|
|
$response = $this->get('/testpage/?stage=Stage');
|
2011-05-19 11:26:09 +02:00
|
|
|
$this->assertEquals($response->getStatusCode(), 302, 'Redirects to page view in CMS when logged in for draft stage');
|
|
|
|
$this->assertNotContains('Security/login', $response->getHeader('Location'));
|
|
|
|
$this->assertContains('admin/page/edit/show/' . $page->ID, $response->getHeader('Location'));
|
2011-03-18 04:17:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|