diff --git a/composer.json b/composer.json index f9f78b5..b86dc28 100644 --- a/composer.json +++ b/composer.json @@ -20,18 +20,16 @@ } ], "require": { + "php": "^7.3 || ^8.0", "silverstripe/vendor-plugin": "^1", - "silverstripe/framework": "^4.2", + "silverstripe/framework": "^4.10", "silverstripe/cms": "^4.2", "silverstripe/reports": "^4.2", "silverstripe/siteconfig": "^4.2" }, "require-dev": { - "sminnee/phpunit": "^5.7", - "squizlabs/php_codesniffer": "^3", - "silverstripe/behat-extension": "^3", - "silverstripe/serve": "^2", - "se/selenium-server-standalone": "2.41.0" + "silverstripe/recipe-testing": "^2", + "squizlabs/php_codesniffer": "^3" }, "suggest": { "symbiote/silverstripe-queuedjobs": "Automatically schedules content review emails to be sent, only requiring one crontask to be created" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 965f16a..7e35d22 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,9 @@ - - tests/php/ - + + + tests/php/ + + src/ diff --git a/src/Jobs/ContentReviewNotificationJob.php b/src/Jobs/ContentReviewNotificationJob.php index 85d1d23..c04871a 100644 --- a/src/Jobs/ContentReviewNotificationJob.php +++ b/src/Jobs/ContentReviewNotificationJob.php @@ -80,7 +80,7 @@ class ContentReviewNotificationJob extends AbstractQueuedJob implements QueuedJo return QueuedJob::QUEUED; } - public function setup() + public function setUp() { parent::setup(); diff --git a/tests/php/ContentReviewBaseTest.php b/tests/php/ContentReviewBaseTest.php index 8dcc48f..717c0d5 100644 --- a/tests/php/ContentReviewBaseTest.php +++ b/tests/php/ContentReviewBaseTest.php @@ -18,7 +18,7 @@ abstract class ContentReviewBaseTest extends FunctionalTest */ protected $translatableEnabledBefore; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -39,7 +39,7 @@ abstract class ContentReviewBaseTest extends FunctionalTest } } - protected function tearDown() + protected function tearDown(): void { if (class_exists(Translatable::class)) { if ($this->translatableEnabledBefore) { diff --git a/tests/php/ContentReviewCMSPageEditControllerTest.php b/tests/php/ContentReviewCMSPageEditControllerTest.php index afcb051..5f5e048 100644 --- a/tests/php/ContentReviewCMSPageEditControllerTest.php +++ b/tests/php/ContentReviewCMSPageEditControllerTest.php @@ -17,9 +17,6 @@ use SilverStripe\Security\Group; use SilverStripe\Security\Member; use SilverStripe\SiteConfig\SiteConfig; -/** - * @mixin PHPUnit_Framework_TestCase - */ class ContentReviewCMSPageEditControllerTest extends ContentReviewBaseTest { /** diff --git a/tests/php/ContentReviewNotificationTest.php b/tests/php/ContentReviewNotificationTest.php index 019fa4a..d2e7aca 100644 --- a/tests/php/ContentReviewNotificationTest.php +++ b/tests/php/ContentReviewNotificationTest.php @@ -18,9 +18,6 @@ use SilverStripe\Security\Member; use SilverStripe\SiteConfig\SiteConfig; use SilverStripe\ContentReview\Models\ContentReviewLog; -/** - * @mixin PHPUnit_Framework_TestCase - */ class ContentReviewNotificationTest extends SapphireTest { /** @@ -28,7 +25,7 @@ class ContentReviewNotificationTest extends SapphireTest */ protected static $fixture_file = 'ContentReviewTest.yml'; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -70,15 +67,15 @@ class ContentReviewNotificationTest extends SapphireTest $email = $this->findEmail($ToEmail, null, $Subject); $this->assertNotNull($email, "Email haven't been sent."); - $this->assertContains( + $this->assertStringContainsString( "

$Subject

". "

There are $PagesCount pages that are due for review today by you, $ToFirstName.

". "

This email was sent to $ToEmail

", $email['HtmlContent'] ); - $this->assertContains('Staff', $email['HtmlContent']); - $this->assertContains('Contact Us', $email['HtmlContent']); - $this->assertContains('Contact Us Child', $email['HtmlContent']); + $this->assertStringContainsString('Staff', $email['HtmlContent']); + $this->assertStringContainsString('Contact Us', $email['HtmlContent']); + $this->assertStringContainsString('Contact Us Child', $email['HtmlContent']); DBDatetime::clear_mock_now(); } diff --git a/tests/php/ContentReviewSettingsTest.php b/tests/php/ContentReviewSettingsTest.php index f9b364a..1c35c50 100644 --- a/tests/php/ContentReviewSettingsTest.php +++ b/tests/php/ContentReviewSettingsTest.php @@ -4,7 +4,6 @@ namespace SilverStripe\ContentReview\Tests; use function date; use Page; -use PHPUnit_Framework_TestCase; use SilverStripe\CMS\Controllers\CMSPageEditController; use SilverStripe\CMS\Model\SiteTree; use SilverStripe\ContentReview\Extensions\ContentReviewCMSExtension; @@ -22,8 +21,6 @@ use SilverStripe\SiteConfig\SiteConfig; /** * This class tests that settings are inherited correctly based on the inherited, * custom or disabled settings. - * - * @mixin PHPUnit_Framework_TestCase */ class ContentReviewSettingsTest extends SapphireTest { diff --git a/tests/php/Extensions/ContentReviewCMSExtensionTest.php b/tests/php/Extensions/ContentReviewCMSExtensionTest.php index b060a90..d53abd8 100644 --- a/tests/php/Extensions/ContentReviewCMSExtensionTest.php +++ b/tests/php/Extensions/ContentReviewCMSExtensionTest.php @@ -5,6 +5,7 @@ namespace SilverStripe\ContentReview\Tests\Extensions; use SilverStripe\ContentReview\Extensions\ContentReviewCMSExtension; use SilverStripe\ContentReview\Forms\ReviewContentHandler; use SilverStripe\Control\Controller; +use SilverStripe\Control\HTTPResponse_Exception; use SilverStripe\Control\HTTPRequest; use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\Form; @@ -29,21 +30,17 @@ class ContentReviewCMSExtensionTest extends SapphireTest $this->assertTrue($result); } - /** - * @expectedException SilverStripe\Control\HTTPResponse_Exception - * @expectedExceptionMessage Bad record ID #1234 - */ public function testGetReviewContentFormThrowsExceptionWhenPageNotFound() { + $this->expectException(HTTPResponse_Exception::class); + $this->expectExceptionMessage('Bad record ID #1234'); (new ContentReviewCMSExtension)->getReviewContentForm(1234); } - /** - * @expectedException SilverStripe\Control\HTTPResponse_Exception - * @expectedExceptionMessage It seems you don't have the necessary permissions to review this content - */ public function testGetReviewContentFormThrowsExceptionWhenObjectCannotBeReviewed() { + $this->expectException(HTTPResponse_Exception::class); + $this->expectExceptionMessage('It seems you don\'t have the necessary permissions to review this content'); $this->logOut(); $mock = $this->getMockBuilder(ContentReviewCMSExtension::class) diff --git a/tests/php/Forms/ReviewContentHandlerTest.php b/tests/php/Forms/ReviewContentHandlerTest.php index 7561224..8b01163 100644 --- a/tests/php/Forms/ReviewContentHandlerTest.php +++ b/tests/php/Forms/ReviewContentHandlerTest.php @@ -14,6 +14,7 @@ use SilverStripe\Forms\Form; use SilverStripe\Forms\HiddenField; use SilverStripe\Forms\TextareaField; use SilverStripe\Security\Member; +use SilverStripe\ORM\ValidationException; class ReviewContentHandlerTest extends SapphireTest { @@ -37,12 +38,10 @@ class ReviewContentHandlerTest extends SapphireTest $this->assertTrue($saveAction->hasClass('review-content__action')); } - /** - * @expectedException SilverStripe\ORM\ValidationException - * @expectedExceptionMessage It seems you don't have the necessary permissions to submit a content review - */ public function testExceptionThrownWhenSubmittingReviewForInvalidObject() { + $this->expectException(ValidationException::class); + $this->expectExceptionMessage('It seems you don\'t have the necessary permissions to submit a content review'); ReviewContentHandler::create()->submitReview(new Member, ['foo' => 'bar']); } diff --git a/tests/php/SiteTreeContentReviewTest.php b/tests/php/SiteTreeContentReviewTest.php index aefebd5..395947d 100644 --- a/tests/php/SiteTreeContentReviewTest.php +++ b/tests/php/SiteTreeContentReviewTest.php @@ -17,9 +17,6 @@ use SilverStripe\Security\Member; use SilverStripe\SiteConfig\SiteConfig; use SilverStripe\Versioned\Versioned; -/** - * @mixin PHPUnit_Framework_TestCase - */ class SiteTreeContentReviewTest extends ContentReviewBaseTest { protected $usesTransactions = false;