| @@ 270-279 (lines=10) @@ | ||
| 267 | /** |
|
| 268 | * @depends testDaoGeneration |
|
| 269 | */ |
|
| 270 | public function testAssigningExistingRelationship() |
|
| 271 | { |
|
| 272 | $userDao = new UserDao($this->tdbmService); |
|
| 273 | $user = $userDao->getById(1); |
|
| 274 | $countryDao = new CountryDao($this->tdbmService); |
|
| 275 | $country = $countryDao->getById(2); |
|
| 276 | ||
| 277 | $user->setCountry($country); |
|
| 278 | $this->assertEquals(TDBMObjectStateEnum::STATE_DIRTY, $user->_getStatus()); |
|
| 279 | } |
|
| 280 | ||
| 281 | /** |
|
| 282 | * @depends testDaoGeneration |
|
| @@ 403-416 (lines=14) @@ | ||
| 400 | /** |
|
| 401 | * @depends testDaoGeneration |
|
| 402 | */ |
|
| 403 | public function testJointureDeleteBeforeGetters() |
|
| 404 | { |
|
| 405 | $roleDao = new RoleDao($this->tdbmService); |
|
| 406 | $userDao = new UserDao($this->tdbmService); |
|
| 407 | $role = $roleDao->getById(1); |
|
| 408 | $user = $userDao->getById(1); |
|
| 409 | ||
| 410 | // We call removeUser BEFORE calling getUsers |
|
| 411 | // This should work as expected. |
|
| 412 | $role->removeUser($user); |
|
| 413 | $users = $role->getUsers(); |
|
| 414 | ||
| 415 | $this->assertCount(1, $users); |
|
| 416 | } |
|
| 417 | ||
| 418 | /** |
|
| 419 | * @depends testDaoGeneration |
|
| @@ 497-505 (lines=9) @@ | ||
| 494 | * |
|
| 495 | * @depends testJointureSave3 |
|
| 496 | */ |
|
| 497 | public function testJointureSave4() |
|
| 498 | { |
|
| 499 | $roleDao = new RoleDao($this->tdbmService); |
|
| 500 | $role = $roleDao->getById(1); |
|
| 501 | $this->assertCount(1, $role->getUsers()); |
|
| 502 | $userDao = new UserDao($this->tdbmService); |
|
| 503 | $user = $userDao->getById(1); |
|
| 504 | $this->assertCount(0, $user->getRoles()); |
|
| 505 | } |
|
| 506 | ||
| 507 | /** |
|
| 508 | * Step 5: we add the role 1 from user 1 and save user 1. |
|
| @@ 513-523 (lines=11) @@ | ||
| 510 | * |
|
| 511 | * @depends testJointureSave4 |
|
| 512 | */ |
|
| 513 | public function testJointureSave5() |
|
| 514 | { |
|
| 515 | $roleDao = new RoleDao($this->tdbmService); |
|
| 516 | $role = $roleDao->getById(1); |
|
| 517 | $userDao = new UserDao($this->tdbmService); |
|
| 518 | $user = $userDao->getById(1); |
|
| 519 | ||
| 520 | $user->addRole($role); |
|
| 521 | $this->assertCount(1, $user->getRoles()); |
|
| 522 | $userDao->save($user); |
|
| 523 | } |
|
| 524 | ||
| 525 | /** |
|
| 526 | * Step 6: we check that save was done |
|
| @@ 531-539 (lines=9) @@ | ||
| 528 | * |
|
| 529 | * @depends testJointureSave5 |
|
| 530 | */ |
|
| 531 | public function testJointureSave6() |
|
| 532 | { |
|
| 533 | $roleDao = new RoleDao($this->tdbmService); |
|
| 534 | $role = $roleDao->getById(1); |
|
| 535 | $this->assertCount(2, $role->getUsers()); |
|
| 536 | $userDao = new UserDao($this->tdbmService); |
|
| 537 | $user = $userDao->getById(1); |
|
| 538 | $this->assertCount(1, $user->getRoles()); |
|
| 539 | } |
|
| 540 | ||
| 541 | /** |
|
| 542 | * Step 7: we add a new role to user 1 and save user 1. |
|