public function testFind() { list($conn, $query) = $this->getMocks(); $instance = new VideoRepository($conn); $id = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'; $conn->shouldReceive('table')->andReturn($query); $query->shouldReceive('where')->once()->with('id', $id)->andReturnSelf(); $query->shouldReceive('first')->once()->andReturn(['id' => $id, 'playtime' => 30]); $meta = $instance->find($id); $this->assertInstanceOf('Xpressengine\\Media\\Meta', $meta); $query->shouldReceive('where')->once()->with('id', $id)->andReturnSelf(); $query->shouldReceive('first')->once()->andReturnNull(); $this->assertNull($instance->find($id)); }
/** * media 객체로 반환 * * @param File $file file instance * @return Video * @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(Video::getJsonType()); $meta = $this->repo->insert($meta); } return $this->createModel($file, $meta); }