public function testFind() { list($conn, $query) = $this->getMocks(); $instance = new AudioRepository($conn); $id = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'; $conn->shouldReceive('table')->once()->andReturn($query); $query->shouldReceive('where')->once()->with('id', $id)->andReturnSelf(); $query->shouldReceive('first')->once()->andReturn((object) ['foo' => 'bar', 'baz' => 'qux']); $meta = $instance->find($id); $this->assertEquals('bar', $meta['foo']); $this->assertEquals('qux', $meta->baz); }
/** * media 객체로 반환 * * @param File $file file instance * @return Audio * @throws NotAvailableException */ public function make(File $file) { if ($this->isAvailable($file->getMime()) !== true) { throw new NotAvailableException(); } if (!($meta = $this->repo->find($file->getId()))) { $meta = $this->extractInformation($file); $meta->dataEncode(Audio::getJsonType()); $meta = $this->repo->insert($meta); } return $this->createModel($file, $meta); }