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