Skip to content

Commit c7c8f72

Browse files
committed
improve form tests to cover one-to-many association
1 parent 8713152 commit c7c8f72

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App\Entity;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
/**
8+
* @ORM\Entity
9+
*/
10+
class Property
11+
{
12+
/**
13+
* @ORM\Column(name="id", type="integer")
14+
* @ORM\Id
15+
* @ORM\GeneratedValue(strategy="AUTO")
16+
*/
17+
private $id;
18+
19+
/**
20+
* Many Features have One Product.
21+
* @ORM\ManyToOne(targetEntity="App\Entity\SourFood", inversedBy="properties")
22+
* @ORM\JoinColumn(name="sour_food_id", referencedColumnName="id")
23+
*/
24+
private $sourFood;
25+
}

tests/fixtures/MakeFormForEntity/src/Entity/SourFood.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Entity;
44

5+
use Doctrine\Common\Collections\ArrayCollection;
56
use Doctrine\ORM\Mapping as ORM;
67

78
/**
@@ -21,6 +22,16 @@ class SourFood
2122
*/
2223
private $title;
2324

25+
/**
26+
* @ORM\OneToMany(targetEntity="App\Entity\Property", mappedBy="sourFood")
27+
*/
28+
private $properties;
29+
30+
public function __construct()
31+
{
32+
$this->properties = new ArrayCollection();
33+
}
34+
2435
/**
2536
* @return mixed
2637
*/

0 commit comments

Comments
 (0)