add order
This commit is contained in:
parent
7663f684a4
commit
1dc5306967
37 changed files with 1060 additions and 113 deletions
35
tests/DbWebTest.php
Normal file
35
tests/DbWebTest.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Tools\SchemaTool;
|
||||
use Override;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
abstract class DbWebTest extends WebTestCase
|
||||
{
|
||||
abstract public function getEntityClass(): string;
|
||||
|
||||
protected KernelBrowser $client;
|
||||
protected EntityManagerInterface $manager;
|
||||
protected EntityRepository $repository;
|
||||
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->client = static::createClient();
|
||||
$this->manager = static::getContainer()->get('doctrine')->getManager();
|
||||
(new SchemaTool($this->manager))
|
||||
->createSchema($this->manager->getMetadataFactory()->getAllMetadata());
|
||||
|
||||
$this->repository = $this->manager->getRepository($this->getEntityClass());
|
||||
foreach ($this->repository->findAll() as $object) {
|
||||
$this->manager->remove($object);
|
||||
}
|
||||
|
||||
$this->manager->flush();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue