diff --git a/application/src/Entity/Source/GroupSource.php b/application/src/Entity/Source/GroupSource.php index 1096a83..6c60fef 100644 --- a/application/src/Entity/Source/GroupSource.php +++ b/application/src/Entity/Source/GroupSource.php @@ -5,6 +5,7 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\Collection; use App\Entity\Source\Attribut\MembersAttributInterface; use App\Entity\Source\Attribut\MembersAttribut; +use Doctrine\Common\Collections\ArrayCollection; /** * @@ -22,5 +23,10 @@ final class GroupSource extends AbstractSource implements MembersAttributInterfa * @ORM\ManyToMany(targetEntity="AbstractSource") */ protected $members; + + public function __construct() { + parent::__construct(); + $this->members = new ArrayCollection(); + } } diff --git a/application/tests/unit/Entity/Source/GroupSourceTest.php b/application/tests/unit/Entity/Source/GroupSourceTest.php new file mode 100644 index 0000000..0c695e1 --- /dev/null +++ b/application/tests/unit/Entity/Source/GroupSourceTest.php @@ -0,0 +1,35 @@ +groupSource = new GroupSource(); + } + + public function testMembers(){ + $this->assertInstanceOf(Collection::class, $this->groupSource->getMembers()); + $member = new class extends AbstractSource{}; + $this->groupSource->setMembers(new ArrayCollection([$member])); + $this->assertEquals($member, $this->groupSource->getMembers()->get(0)); + } +} +