-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MNT Add tests for using GridField with arbitrary data
Note that the main tests are added as behat tests in the admin module
- Loading branch information
1 parent
72607ae
commit aa5a151
Showing
11 changed files
with
680 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
tests/php/Forms/GridField/GridFieldDetailForm_ItemRequestTest .php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace SilverStripe\Forms\Tests\GridField; | ||
|
||
use SilverStripe\Control\Controller; | ||
use SilverStripe\Dev\SapphireTest; | ||
use SilverStripe\Forms\GridField\GridField; | ||
use SilverStripe\Forms\GridField\GridFieldConfig_Base; | ||
use SilverStripe\Forms\GridField\GridFieldDetailForm; | ||
use SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest; | ||
use SilverStripe\ORM\ArrayList; | ||
use SilverStripe\View\ArrayData; | ||
|
||
class GridFieldDetailForm_ItemRequestTest extends SapphireTest | ||
{ | ||
protected $usesDatabase = false; | ||
|
||
public function testItemEditFormThrowsException() | ||
{ | ||
$gridField = new GridField('dummy', 'dummy', new ArrayList(), new GridFieldConfig_Base()); | ||
$modelClass = ArrayData::class; | ||
$gridField->setModelClass($modelClass); | ||
$itemRequest = new GridFieldDetailForm_ItemRequest($gridField, new GridFieldDetailForm(), new ArrayData(), new Controller(), ''); | ||
|
||
$this->expectException(LogicException::class); | ||
$this->expectExceptionMessage( | ||
'Cannot dynamically determine columns. Pass the fields to GridFieldDetailForm::setFields()' | ||
. " or implement a getCMSFields() method on $modelClass" | ||
); | ||
|
||
$itemRequest->ItemEditForm(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.