function testManyManyAssociationWithDecorator() { $parent = new DataObjectDecoratorTest_MyObject(); $parent->Title = 'My Title'; $parent->write(); $this->assertEquals(0, $parent->Faves()->Count()); $homepage = $this->objFromFixture('Page', 'home'); $firstpage = $this->objFromFixture('Page', 'page1'); $parent->Faves()->add($homepage->ID); $this->assertEquals(1, $parent->Faves()->Count()); $parent->Faves()->add($firstpage->ID); $this->assertEquals(2, $parent->Faves()->Count()); $parent->Faves()->remove($firstpage->ID); $this->assertEquals(1, $parent->Faves()->Count()); }
function testDecoratorCanBeAppliedToDataObject() { $do = new DataObject(); $mo = new DataObjectDecoratorTest_MyObject(); $this->assertTrue($do->hasMethod('testMethodApplied')); $this->assertTrue($mo->hasMethod('testMethodApplied')); $this->assertEquals("hello world", $mo->testMethodApplied()); $this->assertEquals("hello world", $do->testMethodApplied()); }