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