/** * test get by document id * @return void */ public function testGetById() { $conn = $this->conn; $repo = $this->repo; $configHandler = $this->configHandler; $instanceManager = $this->instanceManager; $request = $this->request; $handler = new DocumentHandler($conn, $repo, $configHandler, $instanceManager, $request); $instanceId = 'instanceId'; $id = 'documentId'; $userId = 'userId'; $configHandler->shouldReceive('get')->andReturn($this->getConfigEntity()); $repo->shouldReceive('findById')->andReturn(['id' => $id, 'instanceId' => $instanceId, 'userId' => $userId]); $repo->shouldReceive('find')->andReturn(['id' => $id, 'instanceId' => $instanceId, 'userId' => $userId]); $result = $handler->getById($id); $this->assertInstanceOf('Xpressengine\\Document\\DocumentEntity', $result); // check handler's cache $reflection = new \ReflectionClass(get_class($handler)); $property = $reflection->getProperty('docs'); $property->setAccessible(true); $docs = $property->getValue($handler); $this->assertEquals(1, count($docs)); $this->assertInstanceOf('Xpressengine\\Document\\DocumentEntity', $docs[$id]); // get from cache $result = $handler->getById($id); $this->assertInstanceOf('Xpressengine\\Document\\DocumentEntity', $result); }