mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Merge pull request #524 from creative-commoners/pulls/3.2/tweaks
Minor tweaks, syntax, namespace imports, docblocks, test improvements
This commit is contained in:
commit
2d62251858
10
.travis.yml
10
.travis.yml
@ -9,13 +9,13 @@ env:
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.6
|
||||
env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1
|
||||
env: DB=MYSQL INSTALLER_VERSION=4.0.x-dev PHPCS_TEST=1 PHPUNIT_TEST=1
|
||||
- php: 7.0
|
||||
env: DB=PGSQL PHPUNIT_TEST=1
|
||||
env: DB=PGSQL INSTALLER_VERSION=4.1.x-dev PHPUNIT_TEST=1
|
||||
- php: 7.1
|
||||
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
|
||||
env: DB=MYSQL INSTALLER_VERSION=4.2.x-dev PHPUNIT_COVERAGE_TEST=1
|
||||
- php: 7.2
|
||||
env: DB=MYSQL PHPUNIT_TEST=1
|
||||
env: DB=MYSQL INSTALLER_VERSION=4.x-dev PHPUNIT_TEST=1
|
||||
|
||||
before_script:
|
||||
# Init PHP
|
||||
@ -25,7 +25,7 @@ before_script:
|
||||
|
||||
# Install composer dependencies
|
||||
- composer validate
|
||||
- composer require --no-update silverstripe/installer:4.0.x-dev silverstripe/widgets:2.x-dev
|
||||
- composer require --no-update silverstripe/installer:$INSTALLER_VERSION silverstripe/widgets:2.x-dev
|
||||
- if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.0.x-dev; fi
|
||||
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
|
||||
|
||||
|
@ -4,8 +4,10 @@ namespace SilverStripe\Blog\Admin;
|
||||
|
||||
use SilverStripe\Blog\Forms\GridField\GridFieldAddByDBField;
|
||||
use SilverStripe\Blog\Model\CategorisationObject;
|
||||
use SilverStripe\Forms\GridField\GridFieldAddNewButton;
|
||||
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;
|
||||
use SilverStripe\Forms\GridField\GridFieldDataColumns;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
|
||||
class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
|
||||
{
|
||||
@ -20,7 +22,7 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
|
||||
{
|
||||
parent::__construct($itemsPerPage);
|
||||
|
||||
$this->removeComponentsByType('SilverStripe\\Forms\\GridField\\GridFieldAddNewButton');
|
||||
$this->removeComponentsByType(GridFieldAddNewButton::class);
|
||||
|
||||
$this->addComponent(
|
||||
GridFieldAddByDBField::create('buttons-before-left')
|
||||
@ -33,7 +35,7 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
|
||||
/**
|
||||
* @var GridFieldDataColumns $columns
|
||||
*/
|
||||
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
|
||||
$columns = $this->getComponentByType(GridFieldDataColumns::class);
|
||||
|
||||
$columns->setFieldFormatting(
|
||||
[
|
||||
@ -54,7 +56,7 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
|
||||
/**
|
||||
* @var GridFieldDataColumns $columns
|
||||
*/
|
||||
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
|
||||
$columns = $this->getComponentByType(GridFieldDataColumns::class);
|
||||
|
||||
$columns->setDisplayFields(
|
||||
[
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace SilverStripe\Blog\Forms\GridField;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
@ -11,6 +12,8 @@ use SilverStripe\Forms\GridField\GridField_FormAction;
|
||||
use SilverStripe\Forms\GridField\GridField_HTMLProvider;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\View\Requirements;
|
||||
@ -69,7 +72,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
||||
* @param $arguments mixed
|
||||
* @param $data array
|
||||
*
|
||||
* @return null|SS_HTTPResponse
|
||||
* @return null|HTTPResponse
|
||||
*
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
@ -154,7 +157,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
||||
*
|
||||
* @param $gridField GridField
|
||||
*
|
||||
* @return string
|
||||
* @return string[]
|
||||
*/
|
||||
public function getHTMLFragments($gridField)
|
||||
{
|
||||
@ -170,7 +173,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
||||
$obj = singleton($dataClass);
|
||||
|
||||
if (!$obj->canCreate()) {
|
||||
return '';
|
||||
return [];
|
||||
}
|
||||
|
||||
$dbField = $this->getDataObjectField();
|
||||
|
@ -8,12 +8,16 @@ use SilverStripe\Blog\Forms\GridField\GridFieldConfigBlogPost;
|
||||
use SilverStripe\CMS\Controllers\RootURLController;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\GridField\GridFieldConfig;
|
||||
use SilverStripe\Forms\ListboxField;
|
||||
use SilverStripe\Forms\LiteralField;
|
||||
use SilverStripe\Forms\NumericField;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\UnsavedRelationList;
|
||||
use SilverStripe\Security\Group;
|
||||
use SilverStripe\Security\Member;
|
||||
@ -443,12 +447,12 @@ class Blog extends Page implements PermissionProvider
|
||||
$list = Member::get();
|
||||
$this->extend('updateCandidateUsers', $list);
|
||||
return $list;
|
||||
} else {
|
||||
}
|
||||
|
||||
return Permission::get_members_by_permission(
|
||||
$this->config()->get('grant_user_permission')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if this user can edit the editors list.
|
||||
|
@ -108,7 +108,7 @@ class BlogFilter extends Lumberjack
|
||||
|
||||
$tab = Tab::create('ChildPages', $this->getLumberjackTitle(), $gridField);
|
||||
|
||||
$fields->insertBefore($tab, 'Main');
|
||||
$fields->insertBefore('Main', $tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ use SilverStripe\Forms\Tab;
|
||||
use SilverStripe\Forms\TabSet;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\View\Parsers\URLSegmentFilter;
|
||||
|
||||
|
@ -8,12 +8,15 @@ use SilverStripe\Assets\Image;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Forms\DatetimeField;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
|
||||
use SilverStripe\Forms\ListboxField;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\Forms\ToggleCompositeField;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\UnsavedRelationList;
|
||||
use SilverStripe\Security\Group;
|
||||
use SilverStripe\Security\Member;
|
||||
@ -224,7 +227,7 @@ class BlogPost extends Page
|
||||
/**
|
||||
* @var FieldList $fields
|
||||
*/
|
||||
$fields->insertAfter($uploadField, 'Content');
|
||||
$fields->insertAfter('Content', $uploadField);
|
||||
|
||||
$summary = HtmlEditorField::create('Summary', false);
|
||||
$summary->setRows(5);
|
||||
@ -243,7 +246,7 @@ class BlogPost extends Page
|
||||
$summaryHolder->setHeadingLevel(4);
|
||||
$summaryHolder->addExtraClass('custom-summary');
|
||||
|
||||
$fields->insertAfter($summaryHolder, 'FeaturedImage');
|
||||
$fields->insertAfter('FeaturedImage', $summaryHolder);
|
||||
|
||||
$urlSegment = $fields->dataFieldByName('URLSegment');
|
||||
$urlSegment->setURLPrefix($this->Parent()->RelativeLink());
|
||||
@ -605,7 +608,7 @@ class BlogPost extends Page
|
||||
*/
|
||||
public function Excerpt($wordsToDisplay = 30)
|
||||
{
|
||||
/** @var HTMLText $content */
|
||||
/** @var DBHTMLText $content */
|
||||
$content = $this->dbObject('Content');
|
||||
|
||||
return $content->Summary($wordsToDisplay);
|
||||
|
@ -23,7 +23,8 @@ class BlogPostFilter extends DataExtension
|
||||
/**
|
||||
* Augment queries so that we don't fetch unpublished articles.
|
||||
*
|
||||
* @param SQLQuery $query
|
||||
* @param SQLSelect $query
|
||||
* @param DataQuery $query
|
||||
*/
|
||||
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
|
||||
{
|
||||
|
@ -5,11 +5,13 @@ namespace SilverStripe\Blog\Widgets;
|
||||
use SilverStripe\Blog\Model\Blog;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\NumericField;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\FieldType\DBDate;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\FieldType\DBEnum;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\View\ArrayData;
|
||||
@ -76,7 +78,7 @@ class BlogArchiveWidget extends Widget
|
||||
{
|
||||
$this->beforeUpdateCMSFields(function ($fields) {
|
||||
/**
|
||||
* @var Enum $archiveType
|
||||
* @var DBEnum $archiveType
|
||||
*/
|
||||
$archiveType = $this->dbObject('ArchiveType');
|
||||
|
||||
|
@ -2,10 +2,6 @@
|
||||
|
||||
namespace SilverStripe\Blog\Widgets;
|
||||
|
||||
if (!class_exists('\\SilverStripe\\Widgets\\Model\\Widget')) {
|
||||
return;
|
||||
}
|
||||
|
||||
use SilverStripe\Blog\Model\Blog;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
@ -14,6 +10,10 @@ use SilverStripe\Forms\NumericField;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\Widgets\Model\Widget;
|
||||
|
||||
if (!class_exists(Widget::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method Blog Blog()
|
||||
*/
|
||||
|
@ -2,16 +2,17 @@
|
||||
|
||||
namespace SilverStripe\Blog\Widgets;
|
||||
|
||||
if (!class_exists('\\SilverStripe\\Widgets\\Model\\Widget')) {
|
||||
return;
|
||||
}
|
||||
|
||||
use SilverStripe\Blog\Model\Blog;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\NumericField;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\Widgets\Model\Widget;
|
||||
|
||||
if (!class_exists(Widget::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method Blog Blog()
|
||||
*
|
||||
@ -72,7 +73,7 @@ class BlogRecentPostsWidget extends Widget
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return array|DataList
|
||||
*/
|
||||
public function getPosts()
|
||||
{
|
||||
|
@ -2,10 +2,6 @@
|
||||
|
||||
namespace SilverStripe\Blog\Widgets;
|
||||
|
||||
if (!class_exists('\\SilverStripe\\Widgets\\Model\\Widget')) {
|
||||
return;
|
||||
}
|
||||
|
||||
use SilverStripe\Blog\Model\Blog;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
@ -14,6 +10,10 @@ use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Widgets\Model\Widget;
|
||||
|
||||
if (!class_exists(Widget::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method Blog Blog()
|
||||
*/
|
||||
|
@ -2,17 +2,18 @@
|
||||
|
||||
namespace SilverStripe\Blog\Widgets;
|
||||
|
||||
if (!class_exists('\\SilverStripe\\Widgets\\Model\\Widget')) {
|
||||
return;
|
||||
}
|
||||
|
||||
use SilverStripe\Blog\Model\Blog;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\NumericField;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\Widgets\Model\Widget;
|
||||
|
||||
if (!class_exists(Widget::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method Blog Blog()
|
||||
*/
|
||||
|
@ -5,7 +5,7 @@
|
||||
<% include SilverStripe\\Blog\\MemberDetails %>
|
||||
|
||||
<% if $PaginatedList.Exists %>
|
||||
<h2>Posts by $CurrentProfile.FirstName $CurrentProfile.Surname for $Title:</h2>
|
||||
<h2><%t SilverStripe\\Blog\\Model\\Blog.PostsByUser 'Posts by {firstname} {surname} for {title}' firstname=$CurrentProfile.FirstName surname=$CurrentProfile.Surname title=$Title %></h2>
|
||||
<% loop $PaginatedList %>
|
||||
<% include SilverStripe\\Blog\\PostSummary %>
|
||||
<% end_loop %>
|
||||
|
@ -5,7 +5,6 @@ namespace SilverStripe\Blog\Tests;
|
||||
use SilverStripe\Blog\Model\Blog;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Security;
|
||||
|
||||
/**
|
||||
|
@ -3,24 +3,22 @@
|
||||
namespace SilverStripe\Blog\Tests;
|
||||
|
||||
use SilverStripe\Blog\Model\BlogPost;
|
||||
use SilverStripe\CommentNotifications\Extensions\CommentNotifier;
|
||||
use SilverStripe\Comments\Model\Comment;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
class BlogPostNotificationsTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @var string
|
||||
*/
|
||||
protected static $fixture_file = 'blog.yml';
|
||||
|
||||
public function testUpdateNotificationRecipients()
|
||||
{
|
||||
if (!class_exists('CommentNotifier')) {
|
||||
if (!class_exists(CommentNotifier::class)) {
|
||||
$this->markTestSkipped('Comments Notification module is not installed');
|
||||
}
|
||||
|
||||
$blogPost = $this->objFromFixture(BlogPost::class, 'PostC');
|
||||
$comment = new \SilverStripe\Comments\Model\Comment();
|
||||
$comment = new Comment();
|
||||
$comment->Comment = 'This is a comment';
|
||||
$comment->write();
|
||||
$recipients = $blogPost->notificationRecipients(
|
||||
@ -41,11 +39,11 @@ class BlogPostNotificationsTest extends SapphireTest
|
||||
|
||||
public function testUpdateNotificationSubject()
|
||||
{
|
||||
if (!class_exists('CommentNotifier')) {
|
||||
if (!class_exists(CommentNotifier::class)) {
|
||||
$this->markTestSkipped('Comments Notification module is not installed');
|
||||
}
|
||||
$blogPost = $this->objFromFixture(BlogPost::class, 'PostC');
|
||||
$comment = new \SilverStripe\Comments\Model\Comment();
|
||||
$comment = new Comment();
|
||||
$comment->Comment = 'This is a comment';
|
||||
$comment->write();
|
||||
$recipients = $blogPost->notificationRecipients(
|
||||
|
@ -11,16 +11,9 @@ use SilverStripe\Versioned\Versioned;
|
||||
|
||||
class BlogPostTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @var string
|
||||
*/
|
||||
protected static $fixture_file = 'blog.yml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
DBDatetime::clear_mock_now();
|
||||
parent::tearDown();
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Blog\Tests;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use SilverStripe\Blog\Model\Blog;
|
||||
use SilverStripe\Blog\Model\BlogPost;
|
||||
use SilverStripe\Blog\Model\BlogTag;
|
||||
@ -17,26 +18,16 @@ use SilverStripe\Security\Security;
|
||||
*/
|
||||
class BlogTagTest extends FunctionalTest
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @var string
|
||||
*/
|
||||
protected static $fixture_file = 'blog.yml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
DBDatetime::set_mock_now('2013-10-10 20:00:00');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
DBDatetime::clear_mock_now();
|
||||
|
||||
|
@ -7,6 +7,7 @@ use SilverStripe\Blog\Widgets\BlogTagsCloudWidget;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Widgets\Model\Widget;
|
||||
|
||||
class BlogTagsCloudWidgetTest extends SapphireTest
|
||||
{
|
||||
@ -17,7 +18,7 @@ class BlogTagsCloudWidgetTest extends SapphireTest
|
||||
|
||||
public function testGetCMSFields()
|
||||
{
|
||||
if (!class_exists('SilverStripe\\Widgets\\Model\\Widget')) {
|
||||
if (!class_exists(Widget::class)) {
|
||||
$this->markTestSkipped('Widgets module not installed');
|
||||
}
|
||||
|
||||
@ -34,7 +35,7 @@ class BlogTagsCloudWidgetTest extends SapphireTest
|
||||
|
||||
public function testGetTags()
|
||||
{
|
||||
if (!class_exists('SilverStripe\\Widgets\\Model\\Widget')) {
|
||||
if (!class_exists(Widget::class)) {
|
||||
$this->markTestSkipped('Widgets module not installed');
|
||||
}
|
||||
$widget = new BlogTagsCloudWidget();
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Blog\Tests;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use SilverStripe\Blog\Model\Blog;
|
||||
use SilverStripe\Blog\Model\BlogController;
|
||||
use SilverStripe\Blog\Model\BlogPost;
|
||||
@ -9,62 +10,43 @@ use SilverStripe\CMS\Controllers\ContentController;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\DataModel;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Security;
|
||||
|
||||
/**
|
||||
* @mixin PHPUnit_Framework_TestCase
|
||||
*/
|
||||
class BlogTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected static $fixture_file = 'blog.yml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Config::nest();
|
||||
DBDatetime::set_mock_now('2013-10-10 20:00:00');
|
||||
|
||||
/**
|
||||
* @var Blog $blog
|
||||
*/
|
||||
$blog = $this->objFromFixture(Blog::class, 'FirstBlog');
|
||||
|
||||
$blog->publish('Stage', 'Live');
|
||||
$blog->publishRecursive();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
DBDatetime::clear_mock_now();
|
||||
Config::unnest();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testGetExcludedSiteTreeClassNames()
|
||||
{
|
||||
$member = Security::getCurrentUser();
|
||||
|
||||
if ($member) {
|
||||
Security::setCurrentUser(null);
|
||||
}
|
||||
$this->logOut();
|
||||
|
||||
/**
|
||||
* @var Blog $blog
|
||||
@ -84,11 +66,7 @@ class BlogTest extends SapphireTest
|
||||
|
||||
public function testGetArchivedBlogPosts()
|
||||
{
|
||||
$member = Security::getCurrentUser();
|
||||
|
||||
if ($member) {
|
||||
Security::setCurrentUser(null);
|
||||
}
|
||||
$this->logOut();
|
||||
|
||||
/**
|
||||
* @var Blog $blog
|
||||
@ -349,23 +327,17 @@ class BlogTest extends SapphireTest
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \SilverStripe\Control\HTTPResponse_Exception
|
||||
* @expectedExceptionCode 404
|
||||
*/
|
||||
public function testDisabledProfiles()
|
||||
{
|
||||
Config::modify()->set(BlogController::class, 'disable_profiles', true);
|
||||
|
||||
try {
|
||||
$controller = BlogController::create();
|
||||
$controller->setRequest(Controller::curr()->getRequest());
|
||||
$controller->profile();
|
||||
|
||||
$this->fail('The "profile" action should throw a HTTPResponse_Exception when disable_profiles is enabled');
|
||||
} catch (HTTPResponse_Exception $e) {
|
||||
$this->assertEquals(
|
||||
404,
|
||||
$e->getResponse()->getStatusCode(),
|
||||
'The response status code should be 404 Not Found'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user