\#40 add list of menuitems in foodvendor show
All checks were successful
/ ls (pull_request) Successful in 33s
/ ls (push) Successful in 31s
/ ls (release) Successful in 34s

This commit is contained in:
Jonas 2024-07-17 21:16:44 +02:00
parent a0d277464d
commit add3631376
Signed by: lubiana
SSH key fingerprint: SHA256:gkqM8DUX4Blf6P52fycW8ISTd+4eAHH+Uzu9iyc8hAM
2 changed files with 60 additions and 0 deletions

View file

@ -14,6 +14,15 @@
</tbody>
</table>
<section>
<h2>known menuitems</h2>
{% for item in food_vendor.menuItems %}
<code>{{ item.name }}</code>
{% endfor %}
</section>
<a href="{{ path('app_food_vendor_index') }}">back to list</a>
<a href="{{ path('app_food_vendor_edit', {'id': food_vendor.id}) }}">edit</a>

View file

@ -3,6 +3,7 @@
namespace App\Tests\Controller;
use App\Entity\FoodVendor;
use App\Entity\MenuItem;
use App\Tests\DbWebTest;
use Override;
@ -49,6 +50,56 @@ final class FoodVendorControllerTest extends DbWebTest
$this->assertSame('My Title', $nameNode->text());
}
public function testShowMenuItems(): void
{
$fixture = new FoodVendor;
$fixture->setName('My Title');
$this->manager->persist($fixture);
$this->manager->flush();
$itemOne = new MenuItem;
$itemOne->setName('Item One');
$fixture->addMenuItem($itemOne);
$this->manager->persist($itemOne);
$itemTwo = new MenuItem;
$itemTwo->setName('Item Two');
$itemTwo->setFoodVendor($fixture);
$fixture->addMenuItem($itemTwo);
$this->manager->persist($itemTwo);
$itemThree = new MenuItem;
$itemThree->setName('Item Three');
$itemThree->setFoodVendor($fixture);
$fixture->addMenuItem($itemThree);
$this->manager->persist($itemThree);
$itemFour = new MenuItem;
$itemFour->setName('Item Four');
$itemFour->setFoodVendor($fixture);
$fixture->addMenuItem($itemFour);
$this->manager->persist($itemFour);
$this->manager->flush();
$crawler = $this->client->request('GET', sprintf('%s%s', $this->path, $fixture->getId()));
$this->assertResponseIsSuccessful();
$nameNode = $crawler->filter('td')
->last();
$this->assertSame('My Title', $nameNode->text());
$itemNodes = $crawler->filter('code');
$this->assertCount(4, $itemNodes);
}
public function testEdit(): void
{
$fixture = new FoodVendor;