示例#1
0
 /**
  * Convert data into jsonpatch query and save it in the data source
  * @return mixed
  */
 public function persist()
 {
     $this->validate();
     if (!is_array($this->data)) {
         $this->data = [$this->data];
     }
     $append = $this instanceof StreamCollectorInterface;
     $patches = $this->jsonPatch->generateArrayAdd($this->getPath(), $this->data, $append);
     $this->dataSource->save($this->process, $patches);
     $this->data = [];
 }
示例#2
0
 public function testSave()
 {
     $process = Process::build();
     $this->datasource->save($process, ['foo' => 'bar']);
     $this->assertEquals(1, $this->datasource->count());
     $profile = $this->datasource->getProcess($process->getId());
     $this->assertInstanceOf(\Generator::class, $profile);
     $profile = json_decode(current(iterator_to_array($profile)));
     $this->assertInstanceOf(\stdClass::class, $profile);
     $this->assertObjectHasAttribute('foo', $profile);
     $this->assertEquals('bar', $profile->foo);
 }
示例#3
0
 public function testSave()
 {
     $process = Process::build();
     $this->datasource->save($process, ['foo' => 'bar']);
     $this->assertEquals(0, $this->datasource->count());
 }