MapPointsListDTOMapperTest.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Tests;
  4. use App\Components\Balticrest\Service\Mapper\MapPointsListDTOMapper;
  5. use App\Entity\City;
  6. use App\Entity\Language;
  7. use App\Entity\Point;
  8. use App\Entity\PointLangData;
  9. use App\Entity\PointType;
  10. use Codeception\Module\Symfony;
  11. use Codeception\Test\Unit;
  12. use Doctrine\ORM\EntityManagerInterface;
  13. class MapPointsListDTOMapperTest extends Unit
  14. {
  15. private MapPointsListDTOMapper $mapper;
  16. private EntityManagerInterface $entityManager;
  17. protected function _before()
  18. {
  19. /** @var Symfony $symfony */
  20. $symfony = $this->getModule('Symfony');
  21. $this->entityManager = $symfony->grabService(EntityManagerInterface::class);
  22. $this->mapper = $symfony->grabService(MapPointsListDTOMapper::class);
  23. }
  24. public function testMapper()
  25. {
  26. $pointRuData = (new PointLangData())
  27. ->setTitle('Тестовый объект')
  28. ->setLanguage($this->entityManager->getRepository(Language::class)->findOneByCode('ru'));
  29. $point = (new Point())
  30. ->setIsActive(true)
  31. ->setUrl('testurl')
  32. ->setLat('1')
  33. ->setLon('1')
  34. ->setType($this->entityManager->getRepository(PointType::class)->findOneByCode('hotels'))
  35. ->setCity($this->entityManager->getRepository(City::class)->findOneByCode('svetlogorsk'))
  36. ->addPointLangData($pointRuData);
  37. $dto = $this->mapper->fill('zelenogradsk', [$point]);
  38. $this->assertEquals(
  39. $dto->getJsonResult(),
  40. '{"center":{"lat":54.957757,"lon":20.474495},"trans":{"point_button":"\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435"},"zoom":15,"points":[{"lat":1,"lon":1,"hint":"\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442","title":"\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442","description":"","image":"\/static\/balticrest\/images\/logo\/hotels.png","link":"http:\/\/localhost\/svetlogorsk\/hotels\/point\/testurl","icon":{"image":"\/static\/balticrest\/images\/markers\/hotels.png","size":{"width":27,"height":48}}}]}'
  41. );
  42. }
  43. }