Skip to content

Commit

Permalink
API phpunit 9 support
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Oct 27, 2021
1 parent 412eeac commit 7fc7c4a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"email": "[email protected]"
}],
"require": {
"php": "^7.3 || ^8.0",
"silverstripe/comments": "^3.0"
},
"require-dev": {
"sminnee/phpunit": "^5.7",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.0"
},
"autoload": {
Expand Down
9 changes: 5 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
<testsuite name="Default">
<directory>tests</directory>
</testsuite>

<testsuites>
<testsuite name="Default">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
Expand Down
4 changes: 2 additions & 2 deletions tests/CommentNotifiableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CommentNotifiableTest extends SapphireTest
CommentNotifiableTestDataObject::class
];

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

Expand All @@ -29,7 +29,7 @@ protected function setUp()
$_SERVER['HTTP_HOST'] = 'www.mysite.com';
}

protected function tearDown()
protected function tearDown(): void
{
$_SERVER['HTTP_HOST'] = $this->oldhost;

Expand Down
25 changes: 14 additions & 11 deletions tests/CommentNotifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CommentNotifierTest extends SapphireTest
CommentNotifierTestController::class
];

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

Expand All @@ -33,7 +33,7 @@ protected function setUp()
$_SERVER['HTTP_HOST'] = 'www.mysite.com';
}

protected function tearDown()
protected function tearDown(): void
{
$_SERVER['HTTP_HOST'] = $this->oldhost;

Expand All @@ -56,9 +56,9 @@ public function testSendEmail()

$email = $this->findEmail('[email protected]', '[email protected]', 'A new comment has been posted');

$this->assertContains('<li>Bob Bobberson</li>', $email['Content']);
$this->assertContains('<li>[email protected]</li>', $email['Content']);
$this->assertContains('<blockquote>Hey what a lovely comment</blockquote>', $email['Content']);
$this->assertStringContainsString('<li>Bob Bobberson</li>', $email['Content']);
$this->assertStringContainsString('<li>[email protected]</li>', $email['Content']);
$this->assertStringContainsString('<blockquote>Hey what a lovely comment</blockquote>', $email['Content']);

$this->clearEmails();

Expand All @@ -67,9 +67,12 @@ public function testSendEmail()
$this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted');

$email = $this->findEmail('[email protected]', '[email protected]', 'A new comment has been posted');
$this->assertContains('<li>Secret</li>', $email['Content']);
$this->assertContains('<li>[email protected]</li>', $email['Content']);
$this->assertContains('<blockquote>I don&#039;t want to disclose my details</blockquote>', $email['Content']);
$this->assertStringContainsString('<li>Secret</li>', $email['Content']);
$this->assertStringContainsString('<li>[email protected]</li>', $email['Content']);
$this->assertStringContainsString(
'<blockquote>I don&#039;t want to disclose my details</blockquote>',
$email['Content']
);

$this->clearEmails();

Expand All @@ -79,9 +82,9 @@ public function testSendEmail()

$email = $this->findEmail('[email protected]', '[email protected]', 'A new comment has been posted');

$this->assertContains('<li>Anonymous</li>', $email['Content']);
$this->assertContains('<li>[email protected]</li>', $email['Content']);
$this->assertContains('<blockquote>I didn&#039;t log in</blockquote>', $email['Content']);
$this->assertStringContainsString('<li>Anonymous</li>', $email['Content']);
$this->assertStringContainsString('<li>[email protected]</li>', $email['Content']);
$this->assertStringContainsString('<blockquote>I didn&#039;t log in</blockquote>', $email['Content']);

$this->clearEmails();

Expand Down

0 comments on commit 7fc7c4a

Please sign in to comment.