mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Merge pull request #763 from creative-commoners/pulls/4.2/remove-tests
MNT Remove tests for unsupported optional modules
This commit is contained in:
commit
34255c7023
@ -18,9 +18,6 @@
|
||||
"require-dev": {
|
||||
"silverstripe/recipe-testing": "^3",
|
||||
"squizlabs/php_codesniffer": "^3",
|
||||
"silverstripe/widgets": "^3",
|
||||
"silverstripe/comments": "^4",
|
||||
"silverstripe/content-widget": "^3",
|
||||
"silverstripe/standards": "^1",
|
||||
"phpstan/extension-installer": "^1.3"
|
||||
},
|
||||
@ -44,10 +41,6 @@
|
||||
"email": "github@michaelstrong.co.uk"
|
||||
}
|
||||
],
|
||||
"suggest": {
|
||||
"silverstripe/widgets": "Some widgets come with the blog which are compatible with the widgets module.",
|
||||
"silverstripe/comments": "This module adds comments to your blog."
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "vendor/bin/phpcs src/ tests/",
|
||||
"lint-clean": "vendor/bin/phpcbf src/ tests/"
|
||||
|
@ -4,8 +4,6 @@ Feature: Create a blog
|
||||
|
||||
Background:
|
||||
Given the "group" "EDITOR" has permissions "CMS_ACCESS_CMSMain"
|
||||
And I add an extension "SilverStripe\Widgets\Extensions\WidgetPageExtension" to the "Page" class
|
||||
And I add an extension "SilverStripe\Comments\Extensions\CommentsExtension" to the "Page" class
|
||||
|
||||
And an "image" "Uploads/file1.jpg"
|
||||
And I am logged in as a member of "EDITOR" group
|
||||
@ -16,18 +14,6 @@ Feature: Create a blog
|
||||
And I select the "Blog" radio button
|
||||
And I press the "Create" button
|
||||
|
||||
# Add widgets
|
||||
And I click the "Widgets" CMS tab
|
||||
And I uncheck "Inherit Sidebar From Parent"
|
||||
And I add the "Content" widget
|
||||
And I add the "Archive" widget
|
||||
And I add the "Blog Tags" widget
|
||||
And I fill in the "Content" widget field "Title" with "My content widget title"
|
||||
And I fill in the "Content" widget HTML field "Content" with "<p>Content widget content</p>"
|
||||
And I fill in the "Archive" widget field "Title" with "My archive widget title"
|
||||
And I fill in the "Blog Tags" widget field "Title" with "My blog tags widget title"
|
||||
And I press the "Save" button
|
||||
|
||||
# Logout
|
||||
And I go to "/Security/login"
|
||||
And I press the "Log in as someone else" button
|
||||
@ -78,11 +64,6 @@ Feature: Create a blog
|
||||
Then I should see "New Blog"
|
||||
And I should see "New Post"
|
||||
|
||||
# Widgets
|
||||
And I should see "My content widget title"
|
||||
And the rendered HTML should contain "<p>Content widget content</p>"
|
||||
And I should see "My blog tags widget title"
|
||||
|
||||
# Hyperlink to "New Post"
|
||||
Then the rendered HTML should contain "href=\"/new-blog/new-post"
|
||||
|
||||
@ -99,28 +80,3 @@ Feature: Create a blog
|
||||
# Test that blog post shows in tag view
|
||||
When I go to "/new-blog/tag/my-tag"
|
||||
Then I should see "New Post"
|
||||
|
||||
# Commenting
|
||||
When I click "New Post" in the ".post-summary" element
|
||||
Then I should see "New Post"
|
||||
When I fill in "Your name" with "My Name"
|
||||
And I fill in "Email" with "hello@example.com"
|
||||
And I fill in "Comments" with "My comments"
|
||||
When I press the "Post" button
|
||||
Then I should see "New Post"
|
||||
|
||||
# Commenting is bizarly not working in behat, even though it works during manual testing on my local
|
||||
# Moderation
|
||||
# When I am logged in as a member of "EDITOR" group
|
||||
# When I go to "/admin/pages"
|
||||
# And I follow "New Blog"
|
||||
# And I click the "Blog Posts" CMS tab
|
||||
# And I click on the ".ss-gridfield-item" element
|
||||
# And I click the "Comments" CMS tab
|
||||
# Then I should see "New (1)"
|
||||
# When I click the "New (1)" CMS tab
|
||||
# Then I should see "hello@example.com"
|
||||
# When I click on the ".action-menu__toggle" element
|
||||
# And I press the "Spam" button
|
||||
# And I wait for 2 seconds
|
||||
# Then I should not see "hello@example.com"
|
||||
|
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
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
|
||||
{
|
||||
protected static $fixture_file = 'blog.yml';
|
||||
|
||||
public function testUpdateNotificationRecipients()
|
||||
{
|
||||
if (!class_exists(CommentNotifier::class)) {
|
||||
$this->markTestSkipped('Comments Notification module is not installed');
|
||||
}
|
||||
|
||||
$blogPost = $this->objFromFixture(BlogPost::class, 'PostC');
|
||||
$comment = new Comment();
|
||||
$comment->Comment = 'This is a comment';
|
||||
$comment->write();
|
||||
$recipients = $blogPost->notificationRecipients(
|
||||
$comment
|
||||
)->toArray();
|
||||
|
||||
$segments = [];
|
||||
foreach ($recipients as $recipient) {
|
||||
array_push($segments, $recipient->URLSegment);
|
||||
}
|
||||
|
||||
sort($segments);
|
||||
$this->assertEquals(
|
||||
['blog-contributor', 'blog-editor', 'blog-writer'],
|
||||
$segments
|
||||
);
|
||||
}
|
||||
|
||||
public function testUpdateNotificationSubject()
|
||||
{
|
||||
if (!class_exists(CommentNotifier::class)) {
|
||||
$this->markTestSkipped('Comments Notification module is not installed');
|
||||
}
|
||||
$blogPost = $this->objFromFixture(BlogPost::class, 'PostC');
|
||||
$comment = new Comment();
|
||||
$comment->Comment = 'This is a comment';
|
||||
$comment->write();
|
||||
$recipients = $blogPost->notificationRecipients(
|
||||
$comment
|
||||
)->toArray();
|
||||
$subject = $blogPost->notificationSubject($comment, $recipients[0]);
|
||||
$this->assertEquals(
|
||||
'A new comment has been posted on Third Post',
|
||||
$subject
|
||||
);
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Blog\Tests;
|
||||
|
||||
use SilverStripe\Blog\Model\Blog;
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected static $fixture_file = 'blog.yml';
|
||||
|
||||
public function testGetCMSFields()
|
||||
{
|
||||
if (!class_exists(Widget::class)) {
|
||||
$this->markTestSkipped('Widgets module not installed');
|
||||
}
|
||||
|
||||
$widget = new BlogTagsCloudWidget();
|
||||
$fields = $widget->getCMSFields();
|
||||
$names = [];
|
||||
foreach ($fields as $field) {
|
||||
array_push($names, $field->getName());
|
||||
}
|
||||
|
||||
$expected = ['Title', 'Enabled', 'BlogID'];
|
||||
$this->assertEquals($expected, $names);
|
||||
}
|
||||
|
||||
public function testGetTags()
|
||||
{
|
||||
if (!class_exists(Widget::class)) {
|
||||
$this->markTestSkipped('Widgets module not installed');
|
||||
}
|
||||
$widget = new BlogTagsCloudWidget();
|
||||
$blog = $this->objFromFixture(Blog::class, 'FourthBlog');
|
||||
$widget->BlogID = $blog->ID;
|
||||
$widget->write();
|
||||
$tags = $widget->getTags()->toArray();
|
||||
|
||||
$tag = $tags[0];
|
||||
$this->assertEquals('Cat', $tag->TagName);
|
||||
$this->assertEquals(Controller::join_links(Director::baseURL(), 'fourth-blog/tag/cat'), $tag->Link);
|
||||
$this->assertEquals(2, $tag->TagCount);
|
||||
$this->assertEquals(5, $tag->NormalizedTag);
|
||||
|
||||
$tag = $tags[1];
|
||||
$this->assertEquals('Cool', $tag->TagName);
|
||||
$this->assertEquals(Controller::join_links(Director::baseURL(), 'fourth-blog/tag/cool'), $tag->Link);
|
||||
$this->assertEquals(3, $tag->TagCount);
|
||||
$this->assertEquals(8, $tag->NormalizedTag);
|
||||
|
||||
$tag = $tags[2];
|
||||
$this->assertEquals('Kiwi', $tag->TagName);
|
||||
$this->assertEquals(Controller::join_links(Director::baseURL(), 'fourth-blog/tag/kiwi'), $tag->Link);
|
||||
$this->assertEquals(1, $tag->TagCount);
|
||||
$this->assertEquals(3, $tag->NormalizedTag);
|
||||
|
||||
$tag = $tags[3];
|
||||
$this->assertEquals('Popular', $tag->TagName);
|
||||
$this->assertEquals(Controller::join_links(Director::baseURL(), 'fourth-blog/tag/popular'), $tag->Link);
|
||||
$this->assertEquals(4, $tag->TagCount);
|
||||
$this->assertEquals(10, $tag->NormalizedTag);
|
||||
}
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Blog\Tests;
|
||||
|
||||
use SilverStripe\Blog\Model\Blog;
|
||||
use SilverStripe\Blog\Model\BlogPost;
|
||||
use SilverStripe\Blog\Widgets\BlogArchiveWidget;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\Widgets\Model\Widget;
|
||||
|
||||
class BlogArchiveWidgetTest extends SapphireTest
|
||||
{
|
||||
protected static $fixture_file = 'BlogArchiveWidgetTest.yml';
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
if (!class_exists(Widget::class)) {
|
||||
self::$fixture_file = null;
|
||||
parent::setUp();
|
||||
$this->markTestSkipped('Test requires silverstripe/widgets to be installed.');
|
||||
}
|
||||
|
||||
DBDatetime::set_mock_now('2017-09-20 12:00:00');
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
DBDatetime::clear_mock_now();
|
||||
}
|
||||
|
||||
public function testArchiveMonthlyFromStage()
|
||||
{
|
||||
$widgetA = $this->objFromFixture(BlogArchiveWidget::class, 'archive-monthly-a');
|
||||
$archiveA = $widgetA->getArchive();
|
||||
|
||||
$this->assertInstanceOf(SS_List::class, $archiveA);
|
||||
$this->assertCount(3, $archiveA);
|
||||
$this->assertListContains([
|
||||
['Title' => 'August 2017'],
|
||||
['Title' => 'September 2017'],
|
||||
['Title' => 'May 2015'],
|
||||
], $archiveA);
|
||||
|
||||
$widgetB = $this->objFromFixture(BlogArchiveWidget::class, 'archive-monthly-b');
|
||||
$archiveB = $widgetB->getArchive();
|
||||
|
||||
$this->assertInstanceOf(SS_List::class, $archiveB);
|
||||
$this->assertCount(2, $archiveB);
|
||||
$this->assertListContains([
|
||||
['Title' => 'March 2016'],
|
||||
['Title' => 'June 2016'],
|
||||
], $archiveB);
|
||||
}
|
||||
|
||||
public function testArchiveMonthlyFromLive()
|
||||
{
|
||||
$original = Versioned::get_stage();
|
||||
|
||||
$this->objFromFixture(BlogPost::class, 'post-b')->publishRecursive();
|
||||
$this->objFromFixture(BlogArchiveWidget::class, 'archive-monthly-a')->publishRecursive();
|
||||
Versioned::set_stage(Versioned::LIVE);
|
||||
|
||||
$widget = $this->objFromFixture(BlogArchiveWidget::class, 'archive-monthly-a');
|
||||
$archive = $widget->getArchive();
|
||||
|
||||
$this->assertCount(1, $archive);
|
||||
$this->assertListContains([
|
||||
['Title' => 'August 2017'],
|
||||
], $archive);
|
||||
|
||||
if ($original) {
|
||||
Versioned::set_stage($original);
|
||||
}
|
||||
}
|
||||
|
||||
public function testArchiveYearly()
|
||||
{
|
||||
$widgetA = $this->objFromFixture(BlogArchiveWidget::class, 'archive-yearly-a');
|
||||
$archiveA = $widgetA->getArchive();
|
||||
|
||||
$this->assertInstanceOf(SS_List::class, $archiveA);
|
||||
$this->assertCount(2, $archiveA);
|
||||
$this->assertListContains([
|
||||
['Title' => '2017'],
|
||||
['Title' => '2015'],
|
||||
], $archiveA);
|
||||
|
||||
$widgetB = $this->objFromFixture(BlogArchiveWidget::class, 'archive-yearly-b');
|
||||
$archiveB = $widgetB->getArchive();
|
||||
|
||||
$this->assertInstanceOf(SS_List::class, $archiveB);
|
||||
$this->assertCount(1, $archiveB);
|
||||
$this->assertListContains([
|
||||
['Title' => '2016'],
|
||||
], $archiveB);
|
||||
}
|
||||
|
||||
public function testArchiveMonthlyWithNewPostsAdded()
|
||||
{
|
||||
$original = Versioned::get_stage();
|
||||
Versioned::set_stage('Stage');
|
||||
|
||||
$widget = $this->objFromFixture(BlogArchiveWidget::class, 'archive-monthly-a');
|
||||
$archive = $widget->getArchive();
|
||||
|
||||
$this->assertCount(3, $archive, 'Three months are shown in the blog archive list from fixtures');
|
||||
|
||||
DBDatetime::set_mock_now('2018-01-01 12:00:00');
|
||||
|
||||
$newPost = new BlogPost;
|
||||
$newPost->ParentID = $this->objFromFixture(Blog::class, 'blog-a')->ID;
|
||||
$newPost->Title = 'My new blog post';
|
||||
$newPost->PublishDate = '2018-01-01 08:00:00'; // Same day as the mocked now, but slightly earlier
|
||||
$newPost->write();
|
||||
|
||||
$archive = $widget->getArchive();
|
||||
|
||||
$this->assertCount(4, $archive, 'Four months are shown in the blog archive list after new post added');
|
||||
|
||||
if ($original) {
|
||||
Versioned::set_stage($original);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
SilverStripe\Blog\Model\Blog:
|
||||
blog-a:
|
||||
Title: Blog A
|
||||
blog-b:
|
||||
Title: Blog B
|
||||
|
||||
SilverStripe\Blog\Model\BlogPost:
|
||||
post-a:
|
||||
Title: September Digest
|
||||
PublishDate: 2017-09-01 00:00:00
|
||||
ParentID: =>SilverStripe\Blog\Model\Blog.blog-a
|
||||
post-b:
|
||||
Title: August is Awesome
|
||||
PublishDate: 2017-08-01 00:00:00
|
||||
ParentID: =>SilverStripe\Blog\Model\Blog.blog-a
|
||||
post-c:
|
||||
Title: 2015 is so two years ago
|
||||
PublishDate: 2015-05-02 00:01:02
|
||||
ParentID: =>SilverStripe\Blog\Model\Blog.blog-a
|
||||
post-d:
|
||||
Title: Blog post on Blog B
|
||||
PublishDate: 2016-03-13 21:05:36
|
||||
ParentID: =>SilverStripe\Blog\Model\Blog.blog-b
|
||||
post-e:
|
||||
Title: Blog post 2 on Blog B
|
||||
PublishDate: 2016-06-15 10:00:00
|
||||
ParentID: =>SilverStripe\Blog\Model\Blog.blog-b
|
||||
|
||||
SilverStripe\Blog\Widgets\BlogArchiveWidget:
|
||||
archive-monthly-a:
|
||||
NumberToDisplay: 5
|
||||
ArchiveType: Monthly
|
||||
BlogID: =>SilverStripe\Blog\Model\Blog.blog-a
|
||||
archive-monthly-b:
|
||||
NumberToDisplay: 5
|
||||
ArchiveType: Monthly
|
||||
BlogID: =>SilverStripe\Blog\Model\Blog.blog-b
|
||||
archive-yearly-a:
|
||||
NumberToDisplay: 5
|
||||
ArchiveType: Yearly
|
||||
BlogID: =>SilverStripe\Blog\Model\Blog.blog-a
|
||||
archive-yearly-b:
|
||||
NumberToDisplay: 5
|
||||
ArchiveType: Yearly
|
||||
BlogID: =>SilverStripe\Blog\Model\Blog.blog-b
|
Loading…
Reference in New Issue
Block a user