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