silverstripe-framework/tests/php/Forms/GridField/GridFieldLevelupTest.php
Guy Sartorelli 7073246a37
MNT Add tests for using GridField with arbitrary data
Note that the main tests are added as behat tests in the admin module
2023-12-18 14:20:33 +13:00

30 lines
836 B
PHP

<?php
namespace SilverStripe\Forms\Tests\GridField;
use LogicException;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldLevelup;
use SilverStripe\View\ArrayData;
class GridFieldLevelupTest extends SapphireTest
{
protected $usesDatabase = false;
public function testGetHTMLFragmentsThrowsException()
{
$component = new GridFieldLevelup(0);
$gridField = new GridField('dummy');
$modelClass = ArrayData::class;
$gridField->setModelClass($modelClass);
$this->expectException(LogicException::class);
$this->expectExceptionMessage(
GridFieldLevelup::class . " must be used with DataObject subclasses. Found '$modelClass'"
);
$component->getHTMLFragments($gridField);
}
}