setName('test ' . $i); $basket->setDescription('description'); if (null === $this->user) { throw new \LogicException('Fill a user to store a new basket'); } $basket->setOwner($this->user); $manager->persist($basket); $this->baskets[] = $basket; } $this->addReference('five-basket', $basket); $manager->flush(); } }