public function testLockingAnInstanceCallsCallback() { $animal = Animal::create(array('type' => 'Llama')); $object = new \stdClass(); $object->called = false; // fudge the data in the background $this->connection()->execute('UPDATE animal SET type="walrus" WHERE id=1'); $animal->transaction(function ($animal) use($object) { $animal->lock(function ($locked) use($object) { $object->called = true; }); }); $this->assertTrue($object->called); }
public function testOverridenProperties() { $counter = 0; $llama = Animal::create(array('id' => 123)); $llama->override('type', function () use(&$counter) { $counter++; return 'llama' . $counter; }); $this->assertEquals('llama1', $llama->type); $this->assertEquals('llama2', $llama->type); $this->assertEquals('llama3', $llama->type); }