From 779859e345fc644f4836f969593db24e76c94ab4 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Fri, 7 Jun 2024 20:08:15 +1200 Subject: [PATCH] MNT Remove tests for unsupported optional modules --- composer.json | 7 -- tests/behat/features/blog.feature | 44 ------- tests/php/BlogPostNotificationsTest.php | 58 --------- tests/php/BlogTagsCloudWidgetTest.php | 71 ----------- tests/php/Widgets/BlogArchiveWidgetTest.php | 131 -------------------- tests/php/Widgets/BlogArchiveWidgetTest.yml | 45 ------- 6 files changed, 356 deletions(-) delete mode 100644 tests/php/BlogPostNotificationsTest.php delete mode 100644 tests/php/BlogTagsCloudWidgetTest.php delete mode 100644 tests/php/Widgets/BlogArchiveWidgetTest.php delete mode 100644 tests/php/Widgets/BlogArchiveWidgetTest.yml diff --git a/composer.json b/composer.json index fcc7e6f25..86d1f8206 100755 --- a/composer.json +++ b/composer.json @@ -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/" diff --git a/tests/behat/features/blog.feature b/tests/behat/features/blog.feature index e363c03a7..21417992b 100644 --- a/tests/behat/features/blog.feature +++ b/tests/behat/features/blog.feature @@ -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 "

Content widget content

" - 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 "

Content widget content

" - 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" diff --git a/tests/php/BlogPostNotificationsTest.php b/tests/php/BlogPostNotificationsTest.php deleted file mode 100644 index 6c625657c..000000000 --- a/tests/php/BlogPostNotificationsTest.php +++ /dev/null @@ -1,58 +0,0 @@ -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 - ); - } -} diff --git a/tests/php/BlogTagsCloudWidgetTest.php b/tests/php/BlogTagsCloudWidgetTest.php deleted file mode 100644 index 00e2ca45a..000000000 --- a/tests/php/BlogTagsCloudWidgetTest.php +++ /dev/null @@ -1,71 +0,0 @@ -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); - } -} diff --git a/tests/php/Widgets/BlogArchiveWidgetTest.php b/tests/php/Widgets/BlogArchiveWidgetTest.php deleted file mode 100644 index 6e4f79391..000000000 --- a/tests/php/Widgets/BlogArchiveWidgetTest.php +++ /dev/null @@ -1,131 +0,0 @@ -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); - } - } -} diff --git a/tests/php/Widgets/BlogArchiveWidgetTest.yml b/tests/php/Widgets/BlogArchiveWidgetTest.yml deleted file mode 100644 index 03c419475..000000000 --- a/tests/php/Widgets/BlogArchiveWidgetTest.yml +++ /dev/null @@ -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