Permalink
Browse files

MINOR Fixed tests for GridFieldToolbarHeaderTest

  • Loading branch information...
1 parent 9b4b34c commit e78419cef1e1dc0f74f53ed0b47da1428e9a48de @halkyon halkyon committed Mar 9, 2012
@@ -1,14 +1,19 @@
<?php
class GridFieldToolbarHeaderTest extends SapphireTest {
+ static $fixture_file = 'GridFieldToolbarHeaderTest.yml';
+
+ protected $extraDataObjects = array(
+ 'GridFieldDetailFormTest_Company',
+ );
public function testGridTitleAddNewEnabled() {
$this->logInWithPermission('ADMIN');
//construct a fake form field to render out the grid field within it
$config = new GridFieldConfig();
$config->addComponent($titleField = new GridFieldToolbarHeader());
$actions = new FieldList();
- $grid = new GridField('TestField', 'Test Field', new DataList('Company'),$config);
+ $grid = new GridField('TestField', 'Test Field', new DataList('GridFieldDetailFormTest_Company'),$config);
$fields = new FieldList($rootTab = new TabSet("Root",$tabMain = new Tab('Main',$grid)));
$form = new Form(Controller::curr(), "TestForm", $fields, $actions);
@@ -23,7 +28,7 @@ public function testGridTitleAddNewDisabled() {
$config = new GridFieldConfig();
$config->addComponent($titleField = new GridFieldToolbarHeader());
$actions = new FieldList();
- $grid = new GridField('TestField', 'Test Field', new DataList('Company'),$config);
+ $grid = new GridField('TestField', 'Test Field', new DataList('GridFieldDetailFormTest_Company'),$config);
$fields = new FieldList($rootTab = new TabSet("Root",$tabMain = new Tab('Main',$grid)));
$form = new Form(Controller::curr(), "TestForm", $fields, $actions);
@@ -36,11 +41,18 @@ public function testGridTitleAddNewWithoutPermission() {
if(Member::currentUser()) { Member::currentUser()->logOut(); }
$config = new GridFieldConfig();
$config->addComponent($titleField = new GridFieldToolbarHeader());
- $grid = new GridField('TestField', 'Test Field', new DataList('Company'),$config);
+ $grid = new GridField('TestField', 'Test Field', new DataList('GridFieldDetailFormTest_Company'),$config);
$fields = new FieldList(new TabSet("Root",$tabMain = new Tab('Main',$grid)));
$form = new Form(Controller::curr(), "TestForm", $fields, new FieldList());
$html = $form->forTemplate();
$this->assertNotContains('data-icon="add"', $html, "HTML should not contain the 'add new' button");
}
-}
+}
+class GridFieldDetailFormTest_Company extends DataObject implements TestOnly {
+
+ public static $db = array(
+ 'Name' => 'Varchar(100)'
+ );
+
+}
@@ -0,0 +1,5 @@
+GridFieldDetailFormTest_Company:
+ test-company-1:
+ Name: Test company 1
+ test-company-2:
+ Name: Test company 2

0 comments on commit e78419c

Please sign in to comment.