🎉 first commit

This commit is contained in:
2026-07-18 00:01:27 +02:00
commit 78346ffece
63 changed files with 11664 additions and 0 deletions
+130
View File
@@ -0,0 +1,130 @@
<?php
namespace App\Tests\Controller;
use App\Entity\Todo;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
final class TodoControllerTest extends WebTestCase
{
private KernelBrowser $client;
private EntityManagerInterface $manager;
/** @var EntityRepository<Todo> */
private EntityRepository $todoRepository;
private string $path = '/todo/';
protected function setUp(): void
{
$this->client = static::createClient();
$this->manager = static::getContainer()->get('doctrine')->getManager();
$this->todoRepository = $this->manager->getRepository(Todo::class);
foreach ($this->todoRepository->findAll() as $object) {
$this->manager->remove($object);
}
$this->manager->flush();
}
public function testIndex(): void
{
$this->client->followRedirects();
$crawler = $this->client->request('GET', $this->path);
self::assertResponseStatusCodeSame(200);
self::assertPageTitleContains('Todo index');
// Use the $crawler to perform additional assertions e.g.
// self::assertSame('Some text on the page', $crawler->filter('.p')->first()->text());
}
public function testNew(): void
{
$this->client->request('GET', sprintf('%snew', $this->path));
self::assertResponseStatusCodeSame(200);
$this->client->submitForm('Save', [
'todo[title]' => 'Testing',
'todo[completed]' => 'Testing',
'todo[createdAt]' => 'Testing',
]);
self::assertResponseRedirects('/todo');
self::assertSame(1, $this->todoRepository->count([]));
$this->markTestIncomplete('This test was generated');
}
public function testShow(): void
{
$fixture = new Todo();
$fixture->setTitle('My Title');
$fixture->setCompleted('My Title');
$fixture->setCreatedAt('My Title');
$this->manager->persist($fixture);
$this->manager->flush();
$this->client->request('GET', sprintf('%s%s', $this->path, $fixture->getId()));
self::assertResponseStatusCodeSame(200);
self::assertPageTitleContains('Todo');
// Use assertions to check that the properties are properly displayed.
$this->markTestIncomplete('This test was generated');
}
public function testEdit(): void
{
$fixture = new Todo();
$fixture->setTitle('Value');
$fixture->setCompleted('Value');
$fixture->setCreatedAt('Value');
$this->manager->persist($fixture);
$this->manager->flush();
$this->client->request('GET', sprintf('%s%s/edit', $this->path, $fixture->getId()));
$this->client->submitForm('Update', [
'todo[title]' => 'Something New',
'todo[completed]' => 'Something New',
'todo[createdAt]' => 'Something New',
]);
self::assertResponseRedirects('/todo');
$fixture = $this->todoRepository->findAll();
self::assertSame('Something New', $fixture[0]->getTitle());
self::assertSame('Something New', $fixture[0]->getCompleted());
self::assertSame('Something New', $fixture[0]->getCreatedAt());
$this->markTestIncomplete('This test was generated');
}
public function testRemove(): void
{
$fixture = new Todo();
$fixture->setTitle('Value');
$fixture->setCompleted('Value');
$fixture->setCreatedAt('Value');
$this->manager->persist($fixture);
$this->manager->flush();
$this->client->request('GET', sprintf('%s%s', $this->path, $fixture->getId()));
$this->client->submitForm('Delete');
self::assertResponseRedirects('/todo');
self::assertSame(0, $this->todoRepository->count([]));
$this->markTestIncomplete('This test was generated');
}
}