public function testFilterAndExcludeById() { $id = $this->idFromFixture('DataObjectTest_SubTeam', 'subteam1'); $list = DataObjectTest_SubTeam::get()->filter('ID', $id); $this->assertEquals($id, $list->first()->ID); $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()); }
/** * Test DataList->canSortBy() */ function testCanSortBy() { // Basic check $team = DataObjectTest_Team::get(); $this->assertTrue($team->canSortBy("Title")); $this->assertFalse($team->canSortBy("SomethingElse")); // Subclasses $subteam = DataObjectTest_SubTeam::get(); $this->assertTrue($subteam->canSortBy("Title")); $this->assertTrue($subteam->canSortBy("SubclassDatabaseField")); }