#40 add list of menuitems in foodvendor show #41

Merged
lubiana merged 1 commit from #40_show-menuitems-on-vendor-page into main 2024-07-17 19:21:07 +00:00
2 changed files with 60 additions and 0 deletions
Showing only changes of commit add3631376 - Show all commits

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;