mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
FIX Add extra DataObject stub to CommentsGridFieldActionTest and update expectations
This commit is contained in:
parent
216ad8eb54
commit
75d7de9aa6
@ -12,8 +12,10 @@ use SilverStripe\Control\Controller;
|
|||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\Forms\FieldList;
|
use SilverStripe\Forms\FieldList;
|
||||||
use SilverStripe\Forms\Form;
|
use SilverStripe\Forms\Form;
|
||||||
|
use SilverStripe\Forms\GridField\GridField;
|
||||||
use SilverStripe\Forms\GridField\GridFieldDeleteAction;
|
use SilverStripe\Forms\GridField\GridFieldDeleteAction;
|
||||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Team;
|
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Team;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\ORM\DataList;
|
use SilverStripe\ORM\DataList;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
@ -21,6 +23,10 @@ class CommentsGridFieldActionTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
protected $usesDatabase = true;
|
protected $usesDatabase = true;
|
||||||
|
|
||||||
|
protected static $extra_dataobjects = [
|
||||||
|
CommentableItem::class,
|
||||||
|
];
|
||||||
|
|
||||||
/** @var ArrayList */
|
/** @var ArrayList */
|
||||||
protected $list;
|
protected $list;
|
||||||
|
|
||||||
@ -30,7 +36,7 @@ class CommentsGridFieldActionTest extends SapphireTest
|
|||||||
/** @var Form */
|
/** @var Form */
|
||||||
protected $form;
|
protected $form;
|
||||||
|
|
||||||
public function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->list = new DataList(Team::class);
|
$this->list = new DataList(Team::class);
|
||||||
@ -90,25 +96,26 @@ class CommentsGridFieldActionTest extends SapphireTest
|
|||||||
$recordID = $record->ID;
|
$recordID = $record->ID;
|
||||||
$html = $action->getColumnContent($this->gridField, $record, Comment::class);
|
$html = $action->getColumnContent($this->gridField, $record, Comment::class);
|
||||||
$this->assertContains('data-url="admin/comments/mockform/field/testfield', $html);
|
$this->assertContains('data-url="admin/comments/mockform/field/testfield', $html);
|
||||||
$spamAction = 'value="Spam" class="action" id="action_CustomAction' . $recordID . 'Spam"';
|
|
||||||
$this->assertContains($spamAction, $html);
|
|
||||||
|
|
||||||
$approveAction = 'value="Approve" class="action" id="action_CustomAction' . $recordID . 'Approve"';
|
$this->assertContains('value="Spam"', $html);
|
||||||
$this->assertContains($approveAction, $html);
|
$this->assertContains('id="action_CustomAction' . $recordID . 'Spam"', $html);
|
||||||
|
|
||||||
|
$this->assertContains('value="Approve"', $html);
|
||||||
|
$this->assertContains('id="action_CustomAction' . $recordID . 'Approve"', $html);
|
||||||
|
|
||||||
// If marked as spam, only the approve button should be available
|
// If marked as spam, only the approve button should be available
|
||||||
$record->markSpam();
|
$record->markSpam();
|
||||||
$record->write();
|
$record->write();
|
||||||
$html = $action->getColumnContent($this->gridField, $record, Comment::class);
|
$html = $action->getColumnContent($this->gridField, $record, Comment::class);
|
||||||
$this->assertContains($approveAction, $html);
|
$this->assertContains('value="Approve"', $html);
|
||||||
$this->assertNotContains($spamAction, $html);
|
$this->assertNotContains('value="Spam"', $html);
|
||||||
|
|
||||||
// If marked as spam, only the approve button should be available
|
// If marked as spam, only the approve button should be available
|
||||||
$record->markApproved();
|
$record->markApproved();
|
||||||
$record->write();
|
$record->write();
|
||||||
$html = $action->getColumnContent($this->gridField, $record, Comment::class);
|
$html = $action->getColumnContent($this->gridField, $record, Comment::class);
|
||||||
$this->assertNotContains($approveAction, $html);
|
$this->assertNotContains('value="Approve"', $html);
|
||||||
$this->assertContains($spamAction, $html);
|
$this->assertContains('value="Spam"', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetActions()
|
public function testGetActions()
|
||||||
|
Loading…
Reference in New Issue
Block a user