save() public method

Saves the domain object via the associated mapper
public save ( )
Beispiel #1
0
 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'));
 }
Beispiel #2
0
 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);
 }