public function testGetByBand() { $albums = $this->albumRepository->findByBand(1); self::assertNotEmpty($albums); $album = current($albums); /* @var $album Album */ self::assertNotNull($album); $band = $album->getBand(); self::assertNotNull($band); self::assertInstanceOf('\\DateTime', $album->getReleaseDate()); $albums2 = $this->albumRepository->findByBand($band); self::assertNotEmpty($albums2); }
public function updateAction($json) { $albumDto = $this->parseJson($json); $userAlbum = $this->userAlbumRepository->find($albumDto->id); $userBand = $userAlbum->getBand(); $this->albumHelper->populateUserAlbumWithDto($userAlbum, $albumDto); $album = $this->albumRepository->findOneByBandAndTitle($userBand->getGlobalBand(), $userAlbum->getTitle()); if ($album == null) { $album = $this->albumHelper->convertDtoToAlbum($albumDto); $this->albumRepository->persist($album); } $userAlbum->setAlbum($album); $this->userAlbumRepository->flush(); $resultDto = $this->albumHelper->convertUserAlbumToDto($userAlbum); return new JsonViewModel($resultDto, $this->jsonUtils); }