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 #42

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