示例#1
0
文件: MergerTest.php 项目: seytar/psx
 public function testMerge()
 {
     $left = new Object(['id' => 1, 'foo' => 'bar']);
     $right = new Object(['foo' => 'foo']);
     $result = Merger::merge($left, $right);
     $this->assertInstanceOf('PSX\\Data\\RecordInterface', $result);
     $this->assertEquals(['id' => 1, 'foo' => 'foo'], $result->getRecordInfo()->getData());
 }
示例#2
0
 protected function doUpdate(RecordInterface $record, Version $version)
 {
     $table = $this->getTable();
     $data = $table->get($record->getRecordInfo()->getField($table->getPrimaryKey()));
     if (empty($data)) {
         throw new StatusCode\NotFoundException('Record not found');
     }
     $table->update(Merger::merge($data, $record));
     return array('success' => true, 'message' => sprintf('%s successful updated', ucfirst($table->getDisplayName())));
 }