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