mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Merge pull request #671 from creative-commoners/pulls/3/unittest
MNT Unit test for add_default_author config
This commit is contained in:
commit
183c659318
@ -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