Permalink
Browse files

MINOR: Removed database coupling from GridFieldTest.

  • Loading branch information...
1 parent c0d891c commit 65299afd2752e1b7f7439a1e4336548fa7c84e73 @sminnee sminnee committed Jan 10, 2012
Showing with 25 additions and 9 deletions.
  1. +25 −9 tests/forms/GridFieldTest.php
@@ -164,17 +164,21 @@ public function testGetColumnCount() {
* @covers GridField::getColumnContent
*/
public function testGetColumnContent() {
- $list = DataList::create('Member');
+ $list = new ArrayList(array(
+ new Member(array("ID" => 1, "Email" => "test@example.org" ))
+ ));
$obj = new GridField('testfield', 'testfield', $list);
- $this->assertEquals('ADMIN@example.org', $obj->getColumnContent($list->first(), 'Email'));
+ $this->assertEquals('test@example.org', $obj->getColumnContent($list->first(), 'Email'));
}
/**
* @covers GridField::getColumnContent
*/
public function testGetColumnContentBadArguments() {
$this->setExpectedException('InvalidArgumentException');
- $list = DataList::create('Member');
+ $list = new ArrayList(array(
+ new Member(array("ID" => 1, "Email" => "test@example.org" ))
+ ));
$obj = new GridField('testfield', 'testfield', $list);
$obj->getColumnContent($list->first(), 'non-existing');
}
@@ -183,7 +187,9 @@ public function testGetColumnContentBadArguments() {
* @covers GridField::getColumnAttributes
*/
public function testGetColumnAttributesEmptyArray() {
- $list = DataList::create('Member');
+ $list = new ArrayList(array(
+ new Member(array("ID" => 1, "Email" => "test@example.org" ))
+ ));
$obj = new GridField('testfield', 'testfield', $list);
$this->assertEquals(array(), $obj->getColumnAttributes($list->first(), 'Email'));
}
@@ -192,7 +198,9 @@ public function testGetColumnAttributesEmptyArray() {
* @covers GridField::getColumnAttributes
*/
public function testGetColumnAttributes() {
- $list = DataList::create('Member');
+ $list = new ArrayList(array(
+ new Member(array("ID" => 1, "Email" => "test@example.org" ))
+ ));
$config = GridFieldConfig::create()->addComponent(new GridFieldTest_Component);
$obj = new GridField('testfield', 'testfield', $list, $config);
$this->assertEquals(array('class'=>'css-class'), $obj->getColumnAttributes($list->first(), 'Email'));
@@ -203,15 +211,19 @@ public function testGetColumnAttributes() {
*/
public function testGetColumnAttributesBadArguments() {
$this->setExpectedException('InvalidArgumentException');
- $list = DataList::create('Member');
+ $list = new ArrayList(array(
+ new Member(array("ID" => 1, "Email" => "test@example.org" ))
+ ));
$config = GridFieldConfig::create()->addComponent(new GridFieldTest_Component);
$obj = new GridField('testfield', 'testfield', $list, $config);
$obj->getColumnAttributes($list->first(), 'Non-existing');
}
public function testGetColumnAttributesBadResponseFromComponent() {
$this->setExpectedException('LogicException');
- $list = DataList::create('Member');
+ $list = new ArrayList(array(
+ new Member(array("ID" => 1, "Email" => "test@example.org" ))
+ ));
$config = GridFieldConfig::create()->addComponent(new GridFieldTest_Component);
$obj = new GridField('testfield', 'testfield', $list, $config);
$obj->getColumnAttributes($list->first(), 'Surname');
@@ -221,7 +233,9 @@ public function testGetColumnAttributesBadResponseFromComponent() {
* @covers GridField::getColumnMetadata
*/
public function testGetColumnMetadata() {
- $list = DataList::create('Member');
+ $list = new ArrayList(array(
+ new Member(array("ID" => 1, "Email" => "test@example.org" ))
+ ));
$config = GridFieldConfig::create()->addComponent(new GridFieldTest_Component);
$obj = new GridField('testfield', 'testfield', $list, $config);
$this->assertEquals(array('metadata'=>'istrue'), $obj->getColumnMetadata('Email'));
@@ -232,7 +246,9 @@ public function testGetColumnMetadata() {
*/
public function testGetColumnMetadataBadResponseFromComponent() {
$this->setExpectedException('LogicException');
- $list = DataList::create('Member');
+ $list = new ArrayList(array(
+ new Member(array("ID" => 1, "Email" => "test@example.org" ))
+ ));
$config = GridFieldConfig::create()->addComponent(new GridFieldTest_Component);
$obj = new GridField('testfield', 'testfield', $list, $config);
$obj->getColumnMetadata('Surname');

0 comments on commit 65299af

Please sign in to comment.