API phpunit 9 support

This commit is contained in:
Steve Boyd 2021-11-01 14:35:22 +13:00
parent b3d8f8817c
commit 89f58ec573
10 changed files with 25 additions and 41 deletions

View File

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

View File

@ -1,7 +1,9 @@
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
<testsuite name="Default">
<directory>tests/php/</directory>
</testsuite>
<testsuites>
<testsuite name="Default">
<directory>tests/php/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>

View File

@ -80,7 +80,7 @@ class ContentReviewNotificationJob extends AbstractQueuedJob implements QueuedJo
return QueuedJob::QUEUED;
}
public function setup()
public function setUp()
{
parent::setup();

View File

@ -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) {

View File

@ -17,9 +17,6 @@ use SilverStripe\Security\Group;
use SilverStripe\Security\Member;
use SilverStripe\SiteConfig\SiteConfig;
/**
* @mixin PHPUnit_Framework_TestCase
*/
class ContentReviewCMSPageEditControllerTest extends ContentReviewBaseTest
{
/**

View File

@ -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(
"<h1>$Subject</h1>".
"<p>There are $PagesCount pages that are due for review today by you, $ToFirstName.</p>".
"<p>This email was sent to $ToEmail</p>",
$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();
}

View File

@ -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
{

View File

@ -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)

View File

@ -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']);
}

View File

@ -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;