@@ 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 |
|
@@ 401-414 (lines=14) @@ | ||
398 | /** |
|
399 | * @depends testDaoGeneration |
|
400 | */ |
|
401 | public function testJointureDeleteBeforeGetters() |
|
402 | { |
|
403 | $roleDao = new RoleDao($this->tdbmService); |
|
404 | $userDao = new UserDao($this->tdbmService); |
|
405 | $role = $roleDao->getById(1); |
|
406 | $user = $userDao->getById(1); |
|
407 | ||
408 | // We call removeUser BEFORE calling getUsers |
|
409 | // This should work as expected. |
|
410 | $role->removeUser($user); |
|
411 | $users = $role->getUsers(); |
|
412 | ||
413 | $this->assertCount(1, $users); |
|
414 | } |
|
415 | ||
416 | /** |
|
417 | * @depends testDaoGeneration |
|
@@ 495-503 (lines=9) @@ | ||
492 | * |
|
493 | * @depends testJointureSave3 |
|
494 | */ |
|
495 | public function testJointureSave4() |
|
496 | { |
|
497 | $roleDao = new RoleDao($this->tdbmService); |
|
498 | $role = $roleDao->getById(1); |
|
499 | $this->assertCount(1, $role->getUsers()); |
|
500 | $userDao = new UserDao($this->tdbmService); |
|
501 | $user = $userDao->getById(1); |
|
502 | $this->assertCount(0, $user->getRoles()); |
|
503 | } |
|
504 | ||
505 | /** |
|
506 | * Step 5: we add the role 1 from user 1 and save user 1. |
|
@@ 511-521 (lines=11) @@ | ||
508 | * |
|
509 | * @depends testJointureSave4 |
|
510 | */ |
|
511 | public function testJointureSave5() |
|
512 | { |
|
513 | $roleDao = new RoleDao($this->tdbmService); |
|
514 | $role = $roleDao->getById(1); |
|
515 | $userDao = new UserDao($this->tdbmService); |
|
516 | $user = $userDao->getById(1); |
|
517 | ||
518 | $user->addRole($role); |
|
519 | $this->assertCount(1, $user->getRoles()); |
|
520 | $userDao->save($user); |
|
521 | } |
|
522 | ||
523 | /** |
|
524 | * Step 6: we check that save was done |
|
@@ 529-537 (lines=9) @@ | ||
526 | * |
|
527 | * @depends testJointureSave5 |
|
528 | */ |
|
529 | public function testJointureSave6() |
|
530 | { |
|
531 | $roleDao = new RoleDao($this->tdbmService); |
|
532 | $role = $roleDao->getById(1); |
|
533 | $this->assertCount(2, $role->getUsers()); |
|
534 | $userDao = new UserDao($this->tdbmService); |
|
535 | $user = $userDao->getById(1); |
|
536 | $this->assertCount(1, $user->getRoles()); |
|
537 | } |
|
538 | ||
539 | /** |
|
540 | * Step 7: we add a new role to user 1 and save user 1. |