futtern/tests/Controller/OrderItemControllerTest.php
lubiana 0726a8a8ef
All checks were successful
/ ls (pull_request) Successful in 29s
/ ls (push) Successful in 29s
fix controller tests namespace
2024-06-14 20:43:11 +02:00

97 lines
2.6 KiB
PHP

<?php declare(strict_types=1);
namespace App\Tests\Controller;
use App\Entity\OrderItem;
use App\Tests\DbWebTest;
use Override;
use function sprintf;
final class OrderItemControllerTest extends DbWebTest
{
private string $path = '/order/item/';
public function testNew(): void
{
$this->markTestIncomplete();
$this->client->request('GET', sprintf('%snew', $this->path));
self::assertResponseStatusCodeSame(200);
$this->client->submitForm('Save', [
'order_item[name]' => 'Testing',
'order_item[extras]' => 'Testing',
]);
self::assertResponseRedirects($this->path);
self::assertSame(1, $this->repository->count([]));
}
public function testShow(): void
{
$this->markTestIncomplete();
$fixture = new OrderItem;
$fixture->setName('My Title');
$fixture->setExtras('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('OrderItem');
// Use assertions to check that the properties are properly displayed.
}
public function testEdit(): void
{
$this->markTestIncomplete();
$fixture = new OrderItem;
$fixture->setName('Value');
$fixture->setExtras('Value');
$this->manager->persist($fixture);
$this->manager->flush();
$this->client->request('GET', sprintf('%s%s/edit', $this->path, $fixture->getId()));
$this->client->submitForm('Update', [
'order_item[name]' => 'Something New',
'order_item[extras]' => 'Something New',
]);
self::assertResponseRedirects('/order/item/');
$fixture = $this->repository->findAll();
self::assertSame('Something New', $fixture[0]->getName());
self::assertSame('Something New', $fixture[0]->getExtras());
}
public function testRemove(): void
{
$this->markTestIncomplete();
$fixture = new OrderItem;
$fixture->setName('Value');
$fixture->setExtras('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('/order/item/');
self::assertSame(0, $this->repository->count([]));
}
#[Override]
public function getEntityClass(): string
{
return OrderItem::class;
}
}