Skip to content

Commit

Permalink
OP-461: PHPUnit repo test
Browse files Browse the repository at this point in the history
  • Loading branch information
jkindly committed Aug 1, 2024
1 parent ff64c4e commit 432200f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
BitBag\SyliusCmsPlugin\Entity\Template:
template1:
name: 'template1-name'
type: 'page'
template2:
name: 'template2-name'
type: 'page'
template3:
name: 'template3-name'
type: 'page'
46 changes: 46 additions & 0 deletions tests/Integration/Repository/TemplateRepositoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

namespace Tests\BitBag\SyliusCmsPlugin\Integration\Repository;

use ApiTestCase\JsonApiTestCase;
use BitBag\SyliusCmsPlugin\Entity\TemplateInterface;
use BitBag\SyliusCmsPlugin\Repository\TemplateRepositoryInterface;

class TemplateRepositoryTest extends JsonApiTestCase
{
public function setUp(): void
{
parent::setUp();
}

public function test_it_finds_media_by_name_part(): void
{
$this->loadFixturesFromFile('TemplateRepositoryTest/test_it_finds_template_by_name.yml');

$repository = $this->getRepository();

$phrase = 'template';
$type = 'page';
$template = $repository->findTemplatesByNamePart($phrase, $type);

self::assertIsArray($template);
self::assertCount(3, $template);
}

private function getRepository(): TemplateRepositoryInterface
{
/** @var TemplateRepositoryInterface $repository */
$repository = $this->getEntityManager()->getRepository(TemplateInterface::class);

return $repository;
}
}

0 comments on commit 432200f

Please sign in to comment.