<commit_before><?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');
		$blogHolder->publish('Stage', 'Live');
		$blogEntry = $this->objFromFixture('BlogEntry', 'entry1');
		$blogEntry->publish('Stage', 'Live');
	}
	
	function testFrontendBlogPostRequiresPermission() {
		// get valid SecurityID (from comments form, would usually be copy/pasted)
		$blogEntry = $this->objFromFixture('BlogEntry', 'entry1');
		$response = $this->get($blogEntry->URLSegment);
		$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);
		$this->assertFalse(DataObject::get_one('BlogEntry', sprintf("\"Title\" = 'Disallowed'")));
		
		// with login
		$blogEditor = $this->objFromFixture('Member', 'blog_editor');
		$this->session()->inst_set('loggedInAs', $blogEditor->ID);
		Permission::flush_permission_cache();

		$data = array(
			'Title'=>'Allowed',
			'Author'=>'Allowed',
			'Content'=>'Allowed',
			'action_postblog' => 'Post blog entry',
			'SecurityID' => $securityID
		);
		$response = $this->post('blog/BlogEntryForm', $data);

		$this->assertType('BlogEntry', DataObject::get_one('BlogEntry', sprintf("\"Title\" = 'Allowed'")));
	}
}<commit_msg>MINOR Fixed BlogHolderFunctionalTest to work with nested urls<commit_after><?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');
		$blogHolder->publish('Stage', 'Live');
		$blogEntry = $this->objFromFixture('BlogEntry', 'entry1');
		$blogEntry->publish('Stage', 'Live');
	}
	
	function testFrontendBlogPostRequiresPermission() {
		// get valid SecurityID (from comments form, would usually be copy/pasted)
		$blogEntry = $this->objFromFixture('BlogEntry', 'entry1');
		$response = $this->get($blogEntry->Link());
		$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);
		$this->assertFalse(DataObject::get_one('BlogEntry', sprintf("\"Title\" = 'Disallowed'")));
		
		// with login
		$blogEditor = $this->objFromFixture('Member', 'blog_editor');
		$this->session()->inst_set('loggedInAs', $blogEditor->ID);
		Permission::flush_permission_cache();
		$data = array(
			'Title'=>'Allowed',
			'Author'=>'Allowed',
			'Content'=>'Allowed',
			'action_postblog' => 'Post blog entry',
			'SecurityID' => $securityID
		);
		$response = $this->post('blog/BlogEntryForm', $data);

		$this->assertType('BlogEntry', DataObject::get_one('BlogEntry', sprintf("\"Title\" = 'Allowed'")));
	}
}
{'fraction_non_alphanumeric': 0.19356814701378255, 'fraction_numerical': 0.001225114854517611, 'mean_word_length': 5.391389432485323, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1668146', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1051, 'n_words': 185}