mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Use ::class for class_exists checks on Widget, fix setUp/tearDown method visibility
This commit is contained in:
parent
7c4574ba78
commit
86c0f56620
@ -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()
|
||||
*/
|
||||
|
@ -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;
|
||||
@ -24,36 +25,24 @@ use SilverStripe\Security\Security;
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user