public function testCopyFrom() { $original = new VirtualPageTest_ClassA(); $original->MyInitiallyCopiedField = 'original'; $original->MyVirtualField = 'original'; $original->MyNonVirtualField = 'original'; $original->write(); $virtual = new VirtualPage(); $virtual->CopyContentFromID = $original->ID; $virtual->write(); $virtual->copyFrom($original); // Using getField() to avoid side effects from an overloaded __get() $this->assertEquals('original', $virtual->getField('MyInitiallyCopiedField'), 'Fields listed in $initially_copied_fields are copied on first copyFrom() invocation'); $this->assertEquals('original', $virtual->getField('MyVirtualField'), 'Fields not listed in $initially_copied_fields are copied in copyFrom()'); $this->assertNull($virtual->getField('MyNonVirtualField'), 'Fields listed in $non_virtual_fields are not copied in copyFrom()'); $original->MyInitiallyCopiedField = 'changed'; $original->write(); $virtual->copyFrom($original); $this->assertEquals('original', $virtual->MyInitiallyCopiedField, 'Fields listed in $initially_copied_fields are not copied on subsequent copyFrom() invocations'); }