@@ 265-274 (lines=10) @@ | ||
262 | /** |
|
263 | * @depends testDaoGeneration |
|
264 | */ |
|
265 | public function testAssigningExistingRelationship() |
|
266 | { |
|
267 | $userDao = new UserDao($this->tdbmService); |
|
268 | $user = $userDao->getById(1); |
|
269 | $countryDao = new CountryDao($this->tdbmService); |
|
270 | $country = $countryDao->getById(2); |
|
271 | ||
272 | $user->setCountry($country); |
|
273 | $this->assertEquals(TDBMObjectStateEnum::STATE_DIRTY, $user->_getStatus()); |
|
274 | } |
|
275 | ||
276 | /** |
|
277 | * @depends testDaoGeneration |
|
@@ 379-392 (lines=14) @@ | ||
376 | /** |
|
377 | * @depends testDaoGeneration |
|
378 | */ |
|
379 | public function testJointureDeleteBeforeGetters() |
|
380 | { |
|
381 | $roleDao = new RoleDao($this->tdbmService); |
|
382 | $userDao = new UserDao($this->tdbmService); |
|
383 | $role = $roleDao->getById(1); |
|
384 | $user = $userDao->getById(1); |
|
385 | ||
386 | // We call removeUser BEFORE calling getUsers |
|
387 | // This should work as expected. |
|
388 | $role->removeUser($user); |
|
389 | $users = $role->getUsers(); |
|
390 | ||
391 | $this->assertCount(1, $users); |
|
392 | } |
|
393 | ||
394 | /** |
|
395 | * @depends testDaoGeneration |
|
@@ 473-481 (lines=9) @@ | ||
470 | * |
|
471 | * @depends testJointureSave3 |
|
472 | */ |
|
473 | public function testJointureSave4() |
|
474 | { |
|
475 | $roleDao = new RoleDao($this->tdbmService); |
|
476 | $role = $roleDao->getById(1); |
|
477 | $this->assertCount(1, $role->getUsers()); |
|
478 | $userDao = new UserDao($this->tdbmService); |
|
479 | $user = $userDao->getById(1); |
|
480 | $this->assertCount(0, $user->getRoles()); |
|
481 | } |
|
482 | ||
483 | /** |
|
484 | * Step 5: we add the role 1 from user 1 and save user 1. |
|
@@ 489-499 (lines=11) @@ | ||
486 | * |
|
487 | * @depends testJointureSave4 |
|
488 | */ |
|
489 | public function testJointureSave5() |
|
490 | { |
|
491 | $roleDao = new RoleDao($this->tdbmService); |
|
492 | $role = $roleDao->getById(1); |
|
493 | $userDao = new UserDao($this->tdbmService); |
|
494 | $user = $userDao->getById(1); |
|
495 | ||
496 | $user->addRole($role); |
|
497 | $this->assertCount(1, $user->getRoles()); |
|
498 | $userDao->save($user); |
|
499 | } |
|
500 | ||
501 | /** |
|
502 | * Step 6: we check that save was done |
|
@@ 507-515 (lines=9) @@ | ||
504 | * |
|
505 | * @depends testJointureSave5 |
|
506 | */ |
|
507 | public function testJointureSave6() |
|
508 | { |
|
509 | $roleDao = new RoleDao($this->tdbmService); |
|
510 | $role = $roleDao->getById(1); |
|
511 | $this->assertCount(2, $role->getUsers()); |
|
512 | $userDao = new UserDao($this->tdbmService); |
|
513 | $user = $userDao->getById(1); |
|
514 | $this->assertCount(1, $user->getRoles()); |
|
515 | } |
|
516 | ||
517 | /** |
|
518 | * Step 7: we add a new role to user 1 and save user 1. |