2009-07-08 00:11:11 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package blog
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class BlogHolderFunctionalTest extends FunctionalTest {
|
|
|
|
|
|
|
|
static $fixture_file = 'blog/tests/BlogHolderFunctionalTest.yml';
|
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$blogHolder = $this->objFromFixture('BlogHolder', 'blogholder');
|
2009-07-08 02:33:31 +02:00
|
|
|
$blogHolder->publish('Stage', 'Live');
|
2009-07-08 00:11:11 +02:00
|
|
|
$blogEntry = $this->objFromFixture('BlogEntry', 'entry1');
|
2009-07-08 02:33:31 +02:00
|
|
|
$blogEntry->publish('Stage', 'Live');
|
2009-07-08 00:11:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function testFrontendBlogPostRequiresPermission() {
|
|
|
|
// get valid SecurityID (from comments form, would usually be copy/pasted)
|
|
|
|
$blogEntry = $this->objFromFixture('BlogEntry', 'entry1');
|
2010-04-28 13:40:25 +02:00
|
|
|
$response = $this->get($blogEntry->RelativeLink());
|
2009-07-08 00:11:11 +02:00
|
|
|
$securityID = Session::get('SecurityID');
|
|
|
|
|
|
|
|
// without login
|
|
|
|
$data = array(
|
|
|
|
'Title'=>'Disallowed',
|
|
|
|
'Author'=>'Disallowed',
|
|
|
|
'Content'=>'Disallowed',
|
|
|
|
'action_postblog' => 'Post blog entry',
|
|
|
|
'SecurityID' => $securityID
|
|
|
|
);
|
|
|
|
$response = $this->post('blog/BlogEntryForm', $data);
|
2010-04-01 01:14:52 +02:00
|
|
|
$this->assertFalse(DataObject::get_one('BlogEntry', sprintf("\"Title\" = 'Disallowed'")));
|
2009-07-08 00:11:11 +02:00
|
|
|
|
|
|
|
// with login
|
|
|
|
$blogEditor = $this->objFromFixture('Member', 'blog_editor');
|
2009-09-10 09:04:40 +02:00
|
|
|
$this->session()->inst_set('loggedInAs', $blogEditor->ID);
|
|
|
|
Permission::flush_permission_cache();
|
2009-07-08 00:11:11 +02:00
|
|
|
$data = array(
|
|
|
|
'Title'=>'Allowed',
|
|
|
|
'Author'=>'Allowed',
|
|
|
|
'Content'=>'Allowed',
|
|
|
|
'action_postblog' => 'Post blog entry',
|
|
|
|
'SecurityID' => $securityID
|
|
|
|
);
|
|
|
|
$response = $this->post('blog/BlogEntryForm', $data);
|
2009-09-10 09:04:40 +02:00
|
|
|
|
2010-04-01 01:14:52 +02:00
|
|
|
$this->assertType('BlogEntry', DataObject::get_one('BlogEntry', sprintf("\"Title\" = 'Allowed'")));
|
2009-07-08 00:11:11 +02:00
|
|
|
}
|
2010-04-28 13:40:25 +02:00
|
|
|
}
|