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