public function testPrimaryKeyPersistAfterSave_Bug57() { $object = DomainObject::create(array('value' => 'llama')); $this->assertEquals(1, $object->id); $found = DomainObject::byId(1); $found->value = 'alpaca'; $found->save(); $this->assertEquals(1, $found->id); }
public function testEventsBoundToObject() { $this->mapper->shouldReceive('save')->times(2); $events = array(); $this->initialize('Pheasant\\DomainObject', function ($builder) { $builder->properties(array('test' => new Types\StringType())); }); $do1 = new DomainObject(); $do2 = new DomainObject(); $do1->events(array('afterSave' => function ($e) use(&$events) { $events[] = "do1.{$e}"; })); $do2->events(array('afterSave' => function ($e) use(&$events) { $events[] = "do2.{$e}"; })); $do1->save(); $do2->save(); $this->assertEquals($events, array('do1.afterSave', 'do2.afterSave')); }
public function testDecimalTypesAreMarshalledCorrectInLocale() { $prevLocale = setlocale(LC_ALL, ''); /** * Locale with decimal_point = "," * So a float 88.5 becomes 88,5. */ setlocale(LC_ALL, 'nl_NL'); $object = new DomainObject(array('type' => 'Llama', 'weight' => 88.5)); $object->save(); $llamaById = DomainObject::byId(1); $this->assertSame($llamaById->weight, 88.5); setlocale(LC_ALL, $prevLocale); }