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