mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR: Add test using a namespaced class for DataList::filter() and DataList::exclude()
This commit is contained in:
parent
119da09549
commit
fd881d6a4c
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
13
tests/model/DataObjectTest_Namespaced.php
Normal file
13
tests/model/DataObjectTest_Namespaced.php
Normal 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',
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user