/** * @throws \ValidationException * @throws null */ public function testCallback_SetOnAfterWriteCallback_CallbackCalled() { $dog = new Dog(); $dog->Name = 'Jim bob'; $owner = new Human(); $owner->Name = 'Hilly Stewart'; $owner->onAfterWriteCallback(function ($owner) use($dog) { $dog->OwnerID = $owner->ID; $dog->write(); }); $owner->write(); $this->assertTrue($owner->exists()); $this->assertTrue($dog->exists()); $this->assertEquals(1, Human::get()->Count()); $this->assertEquals(1, Dog::get()->Count()); $this->assertEquals($owner->ID, $dog->OwnerID); }