/** * Find an entity using its id. * * getById() is a convenience method, It is equivalent to * ->findOne()->with('id', \Joomla\ORM\Operator::EQUAL, $id)->getItem() * * @param mixed $id The id value * * @return object The requested entity * * @throws EntityNotFoundException if the entity does not exist * @throws OrmException if there was an error getting the entity */ public function getById($id) { $this->updateMap(); if (!in_array($id, $this->map)) { throw new EntityNotFoundException(); } return $this->entityRepository->getById($id); }
public function testParentRelation() { $article = $this->repo->getById(2); $this->assertInstanceOf(RepositoryInterface::class, $article->children); $children = $article->children->getAll(); $this->assertEquals(2, count($children)); }
/** * @testdox getById() uses findOne() on the data mapper */ public function testGetById() { $this->dataMapper->expects($this->once())->method('findOne'); /** @noinspection PhpUnusedLocalVariableInspection */ $article = $this->repo->getById(1); }