Conditions | 4 |
Paths | 6 |
Total Lines | 40 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
27 | public function init() |
||
28 | { |
||
29 | $this->unitOfWork = EntityManagerFactory::getEntityManager([])->getUnitOfWork(); |
||
30 | |||
31 | for ($i = 1; $i <= 100; ++$i) { |
||
32 | $user = new CmsUser; |
||
33 | $user->id = $i; |
||
34 | $user->status = 'user'; |
||
35 | $user->username = 'user' . $i; |
||
36 | $user->name = 'Mr.Smith-' . $i; |
||
37 | $this->users[] = $user; |
||
38 | |||
39 | $this->unitOfWork->registerManaged( |
||
40 | $user, |
||
41 | [ |
||
42 | 'id' => $i, |
||
43 | ], |
||
44 | [ |
||
45 | 'id' => $user->id, |
||
46 | 'status' => $user->status, |
||
47 | 'username' => $user->username, |
||
48 | 'name' => $user->name, |
||
49 | 'address' => $user->address, |
||
50 | 'email' => $user->email, |
||
51 | ] |
||
52 | ); |
||
53 | } |
||
54 | |||
55 | $this->unitOfWork->computeChangeSets(); |
||
56 | |||
57 | if ($this->unitOfWork->getScheduledEntityUpdates()) { |
||
58 | throw new \LogicException('Unit of work should be clean at this stage'); |
||
59 | } |
||
60 | |||
61 | foreach ($this->users AS $user) { |
||
62 | $user->status = 'other'; |
||
63 | $user->username .= '++'; |
||
64 | $user->name = str_replace('Mr.', 'Mrs.', $user->name); |
||
65 | } |
||
66 | } |
||
67 | |||
74 |