NewsListDTOMapperTest.php 896 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Tests;
  4. use App\Components\Balticrest\Service\Mapper\NewsListDTOMapper;
  5. use App\Entity\News;
  6. use Codeception\Module\Symfony;
  7. use Codeception\Test\Unit;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. class NewsListDTOMapperTest extends Unit
  10. {
  11. private NewsListDTOMapper $mapper;
  12. private EntityManagerInterface $entityManager;
  13. protected function _before()
  14. {
  15. /** @var Symfony $symfony */
  16. $symfony = $this->getModule('Symfony');
  17. $this->entityManager = $symfony->grabService(EntityManagerInterface::class);
  18. $this->mapper = $symfony->grabService(NewsListDTOMapper::class);
  19. }
  20. public function testMapper()
  21. {
  22. $news = $this->entityManager->getRepository(News::class)->getActivePaginatedNews();
  23. $dto = $this->mapper->fill($news);
  24. $this->assertNotEmpty($dto->getNews());
  25. }
  26. }