MINOR: Add test using a namespaced class for DataList::filter() and DataList::exclude()

This commit is contained in:
Sam Minnee 2012-06-25 10:43:37 +12:00
parent 119da09549
commit fd881d6a4c
2 changed files with 24 additions and 1 deletions

View File

@ -14,7 +14,8 @@ class DataListTest extends SapphireTest {
'DataObjectTest_FieldlessSubTable',
'DataObjectTest_ValidatedObject',
'DataObjectTest_Player',
'DataObjectTest_TeamComment'
'DataObjectTest_TeamComment',
'DataObjectTest\NamespacedClass',
);
public function testSubtract(){
@ -406,6 +407,15 @@ class DataListTest extends SapphireTest {
$list = DataObjectTest_SubTeam::get();
$this->assertEquals(3, count($list));
$this->assertEquals(2, count($list->exclude('ID', $id)));
// Check that classes with namespaces work.
$obj = new DataObjectTest\NamespacedClass();
$obj->Name = "Test";
$obj->write();
$list = DataObjectTest\NamespacedClass::get()->filter('ID', $obj->ID);
$this->assertEquals('Test', $list->First()->Name);
$this->assertEquals(0, $list->exclude('ID', $obj->ID)->count());
}
/**

View File

@ -0,0 +1,13 @@
<?php
namespace DataObjectTest;
/**
* Right now this is only used in DataListTest, but extending it to DataObjectTest in the future would make sense.
* Note that it was deliberated named to include "\N" to try and trip bad code up.
*/
class NamespacedClass extends \DataObject {
static $db = array(
'Name' => 'Varchar',
);
}