public function testFind() { list($conn, $keygen, $query) = $this->getMocks(); $instance = new DraftRepository($conn, $keygen); $conn->shouldReceive('table')->andReturn($query); $query->shouldReceive('where')->once()->with('id', 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')->andReturnSelf(); $query->shouldReceive('first')->once()->andReturn(['id' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 'key' => 'someKey', 'val' => 'baz', 'etc' => 'a:1:{s:3:"foo";s:3:"bar";}']); $draft = $instance->find('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'); $array = $draft->jsonSerialize(); $this->assertEquals('baz', $array['val']); $this->assertEquals('bar', $array['etc']['foo']); }
/** * 아이디에 해당 하는 데이터 반환 * * @param string $id 임시저장 아이디 * @return DraftEntity */ public function getById($id) { return $this->repo->find($id); }