Beispiel #1
0
 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());
 }
 /**
  * Simple test to ensure that namespaced classes and polymorphic relations work together
  */
 public function testPolymorphicNamespacedRelations()
 {
     $parent = new \DataObjectTest\NamespacedClass();
     $parent->Name = 'New Parent';
     $parent->write();
     $child = new \DataObjectTest\RelationClass();
     $child->Title = 'New Child';
     $child->write();
     $parent->Relations()->add($child);
     $this->assertEquals(1, $parent->Relations()->count());
     $this->assertEquals(array('New Child'), $parent->Relations()->column('Title'));
     $this->assertEquals('New Parent', $child->Parent()->Name);
 }