public function testLockingAnUnsavedInstanceThrowsExceptions() { $animal = new Animal(); $animal->type = 'llama'; $this->setExpectedException('\\Pheasant\\Locking\\LockingException'); $animal->transaction(function ($animal) { $animal->lock(); }); }
public function testIdentityAsString() { $animal = new Animal(array('id' => 1, 'type' => 'llama')); $this->assertEquals("Pheasant\\Tests\\Examples\\Animal[id=1]", $animal->identity()->__toString()); }
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); }
public function testNonExistantProperty() { $this->setExpectedException('BadMethodCallException'); Animal::all()->llamas(); }
public function testAggregateFunctions() { $this->assertEquals(3, Animal::all()->max('id')); $this->assertEquals(1, Animal::all()->min('id')); $this->assertEquals(6, Animal::all()->sum('id')); }