#29: add more tests
This commit is contained in:
parent
c4cd275c83
commit
9afa7fe431
8 changed files with 331 additions and 184 deletions
|
@ -2,12 +2,18 @@
|
|||
|
||||
namespace App\Tests;
|
||||
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
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;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
use Symfony\Component\Uid\Ulid;
|
||||
|
||||
use function str_contains;
|
||||
|
||||
abstract class DbWebTest extends WebTestCase
|
||||
{
|
||||
|
@ -32,4 +38,22 @@ abstract class DbWebTest extends WebTestCase
|
|||
$this->repository = $this->manager->getRepository($this->getEntityClass());
|
||||
}
|
||||
}
|
||||
|
||||
protected function generateOldUlid(int $daysToSubtract = 10): Ulid
|
||||
{
|
||||
$date = (new DateTimeImmutable)->sub(new DateInterval('P' . $daysToSubtract . 'D'));
|
||||
$ulidString = Ulid::generate($date);
|
||||
return Ulid::fromString($ulidString);
|
||||
}
|
||||
|
||||
protected function assertElementContainsCount(Crawler $crawler, string $element, int $count, string $text): void
|
||||
{
|
||||
$this->assertCount(
|
||||
$count,
|
||||
$crawler->filter($element)
|
||||
->reduce(
|
||||
static fn(Crawler $node, $i): bool => str_contains($node->text(), $text),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue