2016-01-07 07:59:10 +01:00
|
|
|
<?php
|
|
|
|
|
2016-02-19 01:48:25 +01:00
|
|
|
class CommentsGridFieldTest extends SapphireTest
|
|
|
|
{
|
|
|
|
public function testNewRow()
|
|
|
|
{
|
|
|
|
$gridfield = new CommentsGridField('testfield', 'testfield');
|
2016-01-07 07:59:10 +01:00
|
|
|
// protected function newRow($total, $index, $record, $attributes, $content) {
|
|
|
|
$comment = new Comment();
|
2016-02-19 01:48:25 +01:00
|
|
|
$comment->Name = 'Fred Bloggs';
|
|
|
|
$comment->Comment = 'This is a comment';
|
|
|
|
$attr = array();
|
2016-01-07 07:59:10 +01:00
|
|
|
|
|
|
|
|
2016-02-19 01:48:25 +01:00
|
|
|
try {
|
2016-01-07 07:59:10 +01:00
|
|
|
$class = new ReflectionClass($gridfield);
|
|
|
|
$method = $class->getMethod('newRow');
|
|
|
|
$method->setAccessible(true);
|
2016-02-19 01:48:25 +01:00
|
|
|
} catch (ReflectionException $e) {
|
2016-01-07 07:59:10 +01:00
|
|
|
$this->fail($e->getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
$params = array(1, 1, $comment, $attr, $comment->Comment);
|
|
|
|
$newRow = $method->invokeArgs($gridfield, $params);
|
|
|
|
$this->assertEquals('<tr>This is a comment</tr>', $newRow);
|
|
|
|
|
|
|
|
$attr = array('class' => 'cssClass');
|
|
|
|
$params = array(1, 1, $comment, $attr, $comment->Comment);
|
|
|
|
$newRow = $method->invokeArgs($gridfield, $params);
|
|
|
|
$this->assertEquals('<tr class="cssClass">This is a comment</tr>', $newRow);
|
|
|
|
|
|
|
|
$comment->markSpam();
|
|
|
|
$params = array(1, 1, $comment, $attr, $comment->Comment);
|
|
|
|
$newRow = $method->invokeArgs($gridfield, $params);
|
|
|
|
$this->assertEquals('<tr class="cssClass spam">This is a comment</tr>', $newRow);
|
2016-02-19 01:48:25 +01:00
|
|
|
}
|
2016-01-07 07:59:10 +01:00
|
|
|
}
|