| @@ 199-214 (lines=16) @@ | ||
| 196 | /** |
|
| 197 | * @depends testDaoGeneration |
|
| 198 | */ |
|
| 199 | public function testForeignKeyInBean() |
|
| 200 | { |
|
| 201 | $userDao = new UserDao($this->tdbmService); |
|
| 202 | $userBean = $userDao->getById(1); |
|
| 203 | $country = $userBean->getCountry(); |
|
| 204 | ||
| 205 | $this->assertEquals('UK', $country->getLabel()); |
|
| 206 | ||
| 207 | $userBean2 = $userDao->getById(1); |
|
| 208 | $this->assertTrue($userBean === $userBean2); |
|
| 209 | ||
| 210 | $contactDao = new ContactDao($this->tdbmService); |
|
| 211 | $contactBean = $contactDao->getById(1); |
|
| 212 | ||
| 213 | $this->assertTrue($userBean === $contactBean); |
|
| 214 | } |
|
| 215 | ||
| 216 | /** |
|
| 217 | * @depends testDaoGeneration |
|
| @@ 545-566 (lines=22) @@ | ||
| 542 | * |
|
| 543 | * @depends testJointureSave7 |
|
| 544 | */ |
|
| 545 | public function testJointureSave8() |
|
| 546 | { |
|
| 547 | $roleDao = new RoleDao($this->tdbmService); |
|
| 548 | $userDao = new UserDao($this->tdbmService); |
|
| 549 | $user = $userDao->getById(1); |
|
| 550 | ||
| 551 | $roles = $user->getRoles(); |
|
| 552 | foreach ($roles as $role) { |
|
| 553 | if ($role->getName() === 'my new role') { |
|
| 554 | $selectedRole = $role; |
|
| 555 | break; |
|
| 556 | } |
|
| 557 | } |
|
| 558 | $this->assertNotNull($selectedRole); |
|
| 559 | ||
| 560 | $this->assertCount(2, $user->getRoles()); |
|
| 561 | ||
| 562 | // Expected: relationship removed! |
|
| 563 | $roleDao->delete($selectedRole); |
|
| 564 | ||
| 565 | $this->assertCount(1, $user->getRoles()); |
|
| 566 | } |
|
| 567 | ||
| 568 | /** |
|
| 569 | * Step 9: Let's test the setXXX method. |
|