2016-05-27 05:10:14 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2019-07-23 15:19:31 +02:00
|
|
|
* @mixin PHPUnit_Framework_TestCase
|
2016-05-27 05:10:14 +02:00
|
|
|
*/
|
|
|
|
class SubsiteXHRControllerTest extends FunctionalTest
|
|
|
|
{
|
|
|
|
protected static $fixture_file = 'SubsiteTest.yml';
|
|
|
|
|
|
|
|
public function testCanView() {
|
|
|
|
// Test unauthenticated access
|
|
|
|
Session::clear('MemberID');
|
|
|
|
$result = $this->get('SubsiteXHRController', null, array(
|
|
|
|
'X-Pjax' => 'SubsiteList',
|
|
|
|
'X-Requested-With' => 'XMLHttpRequest'
|
|
|
|
));
|
|
|
|
$this->assertEquals(403, $result->getStatusCode());
|
|
|
|
|
|
|
|
// Login with NO permissions
|
|
|
|
$this->logInWithPermission('NOT_CMS_PERMISSION');
|
|
|
|
$result = $this->get('SubsiteXHRController', null, array(
|
|
|
|
'X-Pjax' => 'SubsiteList',
|
|
|
|
'X-Requested-With' => 'XMLHttpRequest'
|
|
|
|
));
|
|
|
|
$this->assertEquals(403, $result->getStatusCode());
|
|
|
|
|
|
|
|
// Test cms user
|
|
|
|
$this->logInWithPermission('CMS_ACCESS_CMSMain');
|
|
|
|
$result = $this->get('SubsiteXHRController', null, array(
|
|
|
|
'X-Pjax' => 'SubsiteList',
|
|
|
|
'X-Requested-With' => 'XMLHttpRequest'
|
|
|
|
));
|
|
|
|
$this->assertEquals(200, $result->getStatusCode());
|
2019-07-23 15:19:31 +02:00
|
|
|
$this->assertEquals('application/json', $result->getHeader('Content-Type'));
|
2016-05-27 05:10:14 +02:00
|
|
|
$body = $result->getBody();
|
|
|
|
$this->assertContains('Main site', $body);
|
|
|
|
$this->assertContains('Test 1', $body);
|
|
|
|
$this->assertContains('Test 2', $body);
|
|
|
|
$this->assertContains('Test 3', $body);
|
|
|
|
}
|
|
|
|
}
|