mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
MNT Unit test for add_default_author config
This commit is contained in:
parent
e9507b7377
commit
f74c32a61e
@ -4,9 +4,11 @@ namespace SilverStripe\Blog\Tests;
|
||||
|
||||
use SilverStripe\Blog\Model\BlogPost;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
|
||||
class BlogPostTest extends SapphireTest
|
||||
@ -184,4 +186,23 @@ class BlogPostTest extends SapphireTest
|
||||
$this->assertStringContainsString('archive/', $archiveLink);
|
||||
$this->assertStringEndsWith('/2013', $archiveLink);
|
||||
}
|
||||
|
||||
public function testAddDefaultAuthor()
|
||||
{
|
||||
$member = Security::getCurrentUser();
|
||||
$rootPage = SiteTree::create();
|
||||
$rootPage->write();
|
||||
|
||||
$blogPost = BlogPost::create(['ParentID' => $rootPage->ID]);
|
||||
$this->assertSame(0, $blogPost->Authors()->count());
|
||||
$blogPost->write();
|
||||
$this->assertSame(1, $blogPost->Authors()->count());
|
||||
$this->assertSame($member->ID, $blogPost->Authors()->first()->ID);
|
||||
|
||||
BlogPost::config()->set('add_default_author', false);
|
||||
$blogPost2 = BlogPost::create(['ParentID' => $rootPage->ID]);
|
||||
$this->assertSame(0, $blogPost2->Authors()->count());
|
||||
$blogPost2->write();
|
||||
$this->assertSame(0, $blogPost2->Authors()->count());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user