save() public method

The object will be entered into the database as a result of this operation.
public save ( object $object ) : boolean
$object object The instance to persist to storage.
return boolean
Exemplo n.º 1
0
 /**
  * @depends testInsert
  */
 public function testUpdate()
 {
     $app = $this->getApp();
     $entityName = 'Bolt\\Storage\\Entity\\Users';
     $this->runListenCount($app, 'preSave');
     $this->runListenCount($app, 'postSave');
     $em = new EntityManager($app['db'], $app['dispatcher'], $app['storage.metadata']);
     $repo = $em->getRepository($entityName);
     $existing = $repo->findOneBy(['displayname' => 'Test User']);
     $existing->setUsername('testupdated');
     $em->save($existing);
     $existing2 = $repo->findOneBy(['displayname' => 'Test User']);
     $this->assertEquals('testupdated', $existing2->getUsername());
     $this->assertEquals(1, $this->eventCount['preSave']);
     $this->assertEquals(1, $this->eventCount['postSave']);
 }