-
Notifications
You must be signed in to change notification settings - Fork 45
/
LoadUserWithServiceData.php
56 lines (46 loc) · 1.3 KB
/
LoadUserWithServiceData.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
/*
* This file is part of the Liip/TestFixturesBundle
*
* (c) Lukas Kahwe Smith <smith@pooteeweet.org>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Liip\Acme\Tests\App\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Persistence\ObjectManager;
use Liip\Acme\Tests\App\Entity\User;
use Liip\Acme\Tests\App\Service\DummyService;
/**
* @see LoadDependentUserWithServiceData::getDependencies()
*/
class LoadUserWithServiceData extends AbstractFixture
{
/** @var DummyService */
private $dummyService;
public function __construct(DummyService $dummyService)
{
$this->dummyService = $dummyService;
}
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager): void
{
$user = new User();
$user->setId(1);
$user->setName('foo bar');
$user->setEmail('foo@bar.com');
$user->setDummyText($this->dummyService->getText());
$manager->persist($user);
$manager->flush();
$user = new User();
$user->setId(2);
$user->setName('bob bar');
$user->setEmail('bob@bar.com');
$manager->persist($user);
$manager->flush();
}
}