fetch() public method

임시저장 데이터 목록을 반환
public fetch ( array $options ) : array
$options array 검색할 조건
return array
 public function testFetch()
 {
     list($conn, $keygen, $query) = $this->getMocks();
     $instance = new DraftRepository($conn, $keygen);
     $conn->shouldReceive('table')->andReturn($query);
     $query->shouldReceive('where')->once()->with('userId', 'userId')->andReturnSelf();
     $query->shouldReceive('where')->once()->with('key', 'someKey')->andReturnSelf();
     $query->shouldReceive('get')->once()->andReturn([['id' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 'key' => 'someKey', 'val' => 'qux', 'etc' => 'a:1:{s:3:"foo";s:3:"bar";}'], ['id' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxy', 'key' => 'someKey', 'val' => 'qux1', 'etc' => 'a:1:{s:3:"foo";s:3:"baz";}']]);
     $drafts = $instance->fetch(['userId' => 'userId', 'key' => 'someKey']);
     $this->assertEquals(2, count($drafts));
 }
Ejemplo n.º 2
0
 /**
  * 자동저장으로 저장된 데이터 반환
  *
  * @param string $key 구분할 수 있는 키
  * @return DraftEntity
  */
 public function getAuto($key)
 {
     $arr = $this->repo->fetch(['userId' => $this->auth->user()->getId(), 'key' => $key, 'isAuto' => 1]);
     return array_shift($arr);
 }