mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Merge pull request #329 from creative-commoners/pulls/3/sapphire-test-nine
API phpunit 9 support
This commit is contained in:
commit
7eb8ebedf4
@ -13,7 +13,8 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"silverstripe/framework": "^4.2",
|
||||
"php": "^7.3 || ^8.0",
|
||||
"silverstripe/framework": "^4.10",
|
||||
"colymba/gridfield-bulk-editing-tools": "^3.0.0-beta4"
|
||||
},
|
||||
"suggest": {
|
||||
@ -21,7 +22,7 @@
|
||||
"silverstripe/cms": "The SilverStripe Content Management System"
|
||||
},
|
||||
"require-dev": {
|
||||
"sminnee/phpunit": "^5.7",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"squizlabs/php_codesniffer": "^3.0"
|
||||
},
|
||||
"extra": {
|
||||
|
@ -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>
|
||||
|
@ -31,7 +31,7 @@ class CommentingControllerTest extends FunctionalTest
|
||||
|
||||
protected $securityEnabled;
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if ($this->securityEnabled) {
|
||||
SecurityToken::inst()->enable();
|
||||
@ -41,7 +41,7 @@ class CommentingControllerTest extends FunctionalTest
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->securityEnabled = SecurityToken::inst()->is_enabled();
|
||||
@ -194,7 +194,7 @@ class CommentingControllerTest extends FunctionalTest
|
||||
// specific page
|
||||
$response = $this->get('comments/rss/SilverStripe-Comments-Tests-Stubs-CommentableItem/'.$item->ID);
|
||||
$this->assertEquals(1, substr_count($response->getBody(), "<item>"));
|
||||
$this->assertContains('<dc:creator>FA</dc:creator>', $response->getBody());
|
||||
$this->assertStringContainsString('<dc:creator>FA</dc:creator>', $response->getBody());
|
||||
|
||||
// test accessing comments on a type that doesn't exist
|
||||
$response = $this->get('comments/rss/Fake');
|
||||
|
@ -32,7 +32,7 @@ class CommentsExtensionTest extends FunctionalTest
|
||||
],
|
||||
];
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
@ -262,44 +262,44 @@ class CommentsExtensionTest extends FunctionalTest
|
||||
$item = $this->objFromFixture(CommentableItem::class, 'first');
|
||||
|
||||
// The comments form is HTML to do assertions by contains
|
||||
$cf = $item->CommentsForm();
|
||||
$cf = (string) $item->CommentsForm();
|
||||
$expected = '/comments/CommentsForm/" method="post" enctype="application/x-www-form-urlencoded">';
|
||||
|
||||
$this->assertContains($expected, $cf);
|
||||
$this->assertContains('<h4>Post your comment</h4>', $cf);
|
||||
$this->assertStringContainsString($expected, $cf);
|
||||
$this->assertStringContainsString('<h4>Post your comment</h4>', $cf);
|
||||
// check the comments form exists
|
||||
$expected = '<input type="text" name="Name"';
|
||||
$this->assertContains($expected, $cf);
|
||||
$this->assertStringContainsString($expected, $cf);
|
||||
|
||||
$expected = '<input type="email" name="Email"';
|
||||
$this->assertContains($expected, $cf);
|
||||
$this->assertStringContainsString($expected, $cf);
|
||||
|
||||
$expected = '<input type="text" name="URL"';
|
||||
$this->assertContains($expected, $cf);
|
||||
$this->assertStringContainsString($expected, $cf);
|
||||
|
||||
$expected = '<input type="hidden" name="ParentID"';
|
||||
$this->assertContains($expected, $cf);
|
||||
$this->assertStringContainsString($expected, $cf);
|
||||
|
||||
$expected = '<textarea name="Comment"';
|
||||
$this->assertContains($expected, $cf);
|
||||
$this->assertStringContainsString($expected, $cf);
|
||||
|
||||
$expected = '<input type="submit" name="action_doPostComment" value="Post" class="action"';
|
||||
$this->assertContains($expected, $cf);
|
||||
$this->assertStringContainsString($expected, $cf);
|
||||
|
||||
$expected = '/comments/spam/';
|
||||
$this->assertContains($expected, $cf);
|
||||
$this->assertStringContainsString($expected, $cf);
|
||||
|
||||
$expected = '<p>Reply to firstComA 1</p>';
|
||||
$this->assertContains($expected, $cf);
|
||||
$this->assertStringContainsString($expected, $cf);
|
||||
|
||||
$expected = '/comments/delete';
|
||||
$this->assertContains($expected, $cf);
|
||||
$this->assertStringContainsString($expected, $cf);
|
||||
|
||||
$expected = '<p>Reply to firstComA 2</p>';
|
||||
$this->assertContains($expected, $cf);
|
||||
$this->assertStringContainsString($expected, $cf);
|
||||
|
||||
$expected = '<p>Reply to firstComA 3</p>';
|
||||
$this->assertContains($expected, $cf);
|
||||
$this->assertStringContainsString($expected, $cf);
|
||||
}
|
||||
|
||||
public function testAttachedToSiteTree()
|
||||
|
@ -37,7 +37,7 @@ class CommentsGridFieldActionTest extends SapphireTest
|
||||
/** @var Form */
|
||||
protected $form;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->list = new DataList(Team::class);
|
||||
@ -96,27 +96,27 @@ class CommentsGridFieldActionTest extends SapphireTest
|
||||
$record->write();
|
||||
$recordID = $record->ID;
|
||||
$html = $action->getColumnContent($this->gridField, $record, Comment::class);
|
||||
$this->assertContains('data-url="admin/comments/mockform/field/testfield', $html);
|
||||
$this->assertStringContainsString('data-url="admin/comments/mockform/field/testfield', $html);
|
||||
|
||||
$this->assertContains('value="Spam"', $html);
|
||||
$this->assertContains('id="action_CustomAction' . $recordID . 'Spam"', $html);
|
||||
$this->assertStringContainsString('value="Spam"', $html);
|
||||
$this->assertStringContainsString('id="action_CustomAction' . $recordID . 'Spam"', $html);
|
||||
|
||||
$this->assertContains('value="Approve"', $html);
|
||||
$this->assertContains('id="action_CustomAction' . $recordID . 'Approve"', $html);
|
||||
$this->assertStringContainsString('value="Approve"', $html);
|
||||
$this->assertStringContainsString('id="action_CustomAction' . $recordID . 'Approve"', $html);
|
||||
|
||||
// If marked as spam, only the approve button should be available
|
||||
$record->markSpam();
|
||||
$record->write();
|
||||
$html = $action->getColumnContent($this->gridField, $record, Comment::class);
|
||||
$this->assertContains('value="Approve"', $html);
|
||||
$this->assertNotContains('value="Spam"', $html);
|
||||
$this->assertStringContainsString('value="Approve"', $html);
|
||||
$this->assertStringNotContainsString('value="Spam"', $html);
|
||||
|
||||
// If marked as spam, only the approve button should be available
|
||||
$record->markApproved();
|
||||
$record->write();
|
||||
$html = $action->getColumnContent($this->gridField, $record, Comment::class);
|
||||
$this->assertNotContains('value="Approve"', $html);
|
||||
$this->assertContains('value="Spam"', $html);
|
||||
$this->assertStringNotContainsString('value="Approve"', $html);
|
||||
$this->assertStringContainsString('value="Spam"', $html);
|
||||
}
|
||||
|
||||
public function testGetActions()
|
||||
|
@ -26,7 +26,7 @@ class CommentsTest extends FunctionalTest
|
||||
CommentableItemDisabled::class,
|
||||
];
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
@ -235,7 +235,7 @@ class CommentsTest extends FunctionalTest
|
||||
$comment = $this->objFromFixture(Comment::class, 'firstComA');
|
||||
$commentID = $comment->ID;
|
||||
$adminComment1Link = $comment->DeleteLink();
|
||||
$this->assertContains('comments/delete/' . $commentID . '?t=', $adminComment1Link);
|
||||
$this->assertStringContainsString('comments/delete/' . $commentID . '?t=', $adminComment1Link);
|
||||
|
||||
// Test that this link can't be shared / XSS exploited
|
||||
$this->logInAs('commentadmin2');
|
||||
@ -275,7 +275,7 @@ class CommentsTest extends FunctionalTest
|
||||
$comment = $this->objFromFixture(Comment::class, 'firstComA');
|
||||
$commentID = $comment->ID;
|
||||
$adminComment1Link = $comment->SpamLink();
|
||||
$this->assertContains('comments/spam/' . $commentID . '?t=', $adminComment1Link);
|
||||
$this->assertStringContainsString('comments/spam/' . $commentID . '?t=', $adminComment1Link);
|
||||
|
||||
// Test that this link can't be shared / XSS exploited
|
||||
$this->logInAs('commentadmin2');
|
||||
@ -318,7 +318,7 @@ class CommentsTest extends FunctionalTest
|
||||
$comment = $this->objFromFixture(Comment::class, 'secondComC');
|
||||
$commentID = $comment->ID;
|
||||
$adminComment1Link = $comment->HamLink();
|
||||
$this->assertContains('comments/ham/' . $commentID . '?t=', $adminComment1Link);
|
||||
$this->assertStringContainsString('comments/ham/' . $commentID . '?t=', $adminComment1Link);
|
||||
|
||||
// Test that this link can't be shared / XSS exploited
|
||||
$this->logInAs('commentadmin2');
|
||||
@ -361,7 +361,7 @@ class CommentsTest extends FunctionalTest
|
||||
$comment = $this->objFromFixture(Comment::class, 'secondComB');
|
||||
$commentID = $comment->ID;
|
||||
$adminComment1Link = $comment->ApproveLink();
|
||||
$this->assertContains('comments/approve/' . $commentID . '?t=', $adminComment1Link);
|
||||
$this->assertStringContainsString('comments/approve/' . $commentID . '?t=', $adminComment1Link);
|
||||
|
||||
// Test that this link can't be shared / XSS exploited
|
||||
$this->logInAs('commentadmin2');
|
||||
@ -775,30 +775,30 @@ class CommentsTest extends FunctionalTest
|
||||
$method = $this->getMethod('ActionLink');
|
||||
|
||||
// test with starts of strings and tokens and salts change each time
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
'/comments/theaction/' . $comment->ID,
|
||||
$method->invokeArgs($comment, array('theaction'))
|
||||
);
|
||||
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
'/comments/delete/' . $comment->ID,
|
||||
$comment->DeleteLink()
|
||||
);
|
||||
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
'/comments/spam/' . $comment->ID,
|
||||
$comment->SpamLink()
|
||||
);
|
||||
|
||||
$comment->markSpam();
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
'/comments/ham/' . $comment->ID,
|
||||
$comment->HamLink()
|
||||
);
|
||||
|
||||
//markApproved
|
||||
$comment->markUnapproved();
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
'/comments/approve/' . $comment->ID,
|
||||
$comment->ApproveLink()
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user