Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API phpunit 9 support #156

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/Jobs/ContentReviewNotificationJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function getJobType()
return QueuedJob::QUEUED;
}

public function setup()
public function setUp()
{
parent::setup();

Expand Down
4 changes: 2 additions & 2 deletions tests/php/ContentReviewBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract class ContentReviewBaseTest extends FunctionalTest
*/
protected $translatableEnabledBefore;

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand All @@ -39,7 +39,7 @@ protected function setUp()
}
}

protected function tearDown()
protected function tearDown(): void
{
if (class_exists(Translatable::class)) {
if ($this->translatableEnabledBefore) {
Expand Down
3 changes: 0 additions & 3 deletions tests/php/ContentReviewCMSPageEditControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
use SilverStripe\Security\Member;
use SilverStripe\SiteConfig\SiteConfig;

/**
* @mixin PHPUnit_Framework_TestCase
*/
class ContentReviewCMSPageEditControllerTest extends ContentReviewBaseTest
{
/**
Expand Down
13 changes: 5 additions & 8 deletions tests/php/ContentReviewNotificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\ContentReview\Models\ContentReviewLog;

/**
* @mixin PHPUnit_Framework_TestCase
*/
class ContentReviewNotificationTest extends SapphireTest
{
/**
* @var string
*/
protected static $fixture_file = 'ContentReviewTest.yml';

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -70,15 +67,15 @@ public function testContentReviewEmails()

$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();
}
Expand Down
3 changes: 0 additions & 3 deletions tests/php/ContentReviewSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use function date;
use Page;
use PHPUnit_Framework_TestCase;
use SilverStripe\CMS\Controllers\CMSPageEditController;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ContentReview\Extensions\ContentReviewCMSExtension;
Expand All @@ -22,8 +21,6 @@
/**
* This class tests that settings are inherited correctly based on the inherited,
* custom or disabled settings.
*
* @mixin PHPUnit_Framework_TestCase
*/
class ContentReviewSettingsTest extends SapphireTest
{
Expand Down
13 changes: 5 additions & 8 deletions tests/php/Extensions/ContentReviewCMSExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand All @@ -29,21 +30,17 @@ public function testReviewContentForm()
$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)
Expand Down
7 changes: 3 additions & 4 deletions tests/php/Forms/ReviewContentHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use SilverStripe\Forms\HiddenField;
use SilverStripe\Forms\TextareaField;
use SilverStripe\Security\Member;
use SilverStripe\ORM\ValidationException;

class ReviewContentHandlerTest extends SapphireTest
{
Expand All @@ -37,12 +38,10 @@ public function testForm()
$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']);
}

Expand Down
3 changes: 0 additions & 3 deletions tests/php/SiteTreeContentReviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\Versioned\Versioned;

/**
* @mixin PHPUnit_Framework_TestCase
*/
class SiteTreeContentReviewTest extends ContentReviewBaseTest
{
protected $usesTransactions = false;
Expand Down