First version of functional tests working

This commit is contained in:
Alejandro Celaya
2017-10-23 11:20:55 +02:00
parent e282521040
commit c2feffa50c
5 changed files with 96 additions and 14 deletions

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Core\Repository;
use Shlinkio\Shlink\Core\Entity\Tag;
use Shlinkio\Shlink\Core\Repository\TagRepository;
use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
class TagRepositoryTest extends DatabaseTestCase
{
const ENTITIES_TO_EMPTY = [
Tag::class,
];
/**
* @var TagRepository
*/
private $repo;
protected function setUp()
{
$this->repo = $this->getEntityManager()->getRepository(Tag::class);
}
/**
* @test
*/
public function deleteByNameDoesNothingWhenEmptyListIsProvided()
{
$this->assertEquals(0, $this->repo->deleteByName([]));
}
/**
* @test
*/
public function allTagsWhichMatchNameAreDeleted()
{
$names = ['foo', 'bar', 'baz'];
$toDelete = ['foo', 'baz'];
foreach ($names as $name) {
$this->getEntityManager()->persist(new Tag($name));
}
$this->getEntityManager()->flush();
$this->assertEquals(2, $this->repo->deleteByName($toDelete));
}
}