Code Duplication    Length = 9-14 lines in 5 locations

tests/TDBMDaoGeneratorTest.php 5 locations

@@ 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
@@ 383-396 (lines=14) @@
380
    /**
381
     * @depends testDaoGeneration
382
     */
383
    public function testJointureDeleteBeforeGetters()
384
    {
385
        $roleDao = new RoleDao($this->tdbmService);
386
        $userDao = new UserDao($this->tdbmService);
387
        $role = $roleDao->getById(1);
388
        $user = $userDao->getById(1);
389
390
        // We call removeUser BEFORE calling getUsers
391
        // This should work as expected.
392
        $role->removeUser($user);
393
        $users = $role->getUsers();
394
395
        $this->assertCount(1, $users);
396
    }
397
398
    /**
399
     * @depends testDaoGeneration
@@ 477-485 (lines=9) @@
474
     *
475
     * @depends testJointureSave3
476
     */
477
    public function testJointureSave4()
478
    {
479
        $roleDao = new RoleDao($this->tdbmService);
480
        $role = $roleDao->getById(1);
481
        $this->assertCount(1, $role->getUsers());
482
        $userDao = new UserDao($this->tdbmService);
483
        $user = $userDao->getById(1);
484
        $this->assertCount(0, $user->getRoles());
485
    }
486
487
    /**
488
     * Step 5: we add the role 1 from user 1 and save user 1.
@@ 493-503 (lines=11) @@
490
     *
491
     * @depends testJointureSave4
492
     */
493
    public function testJointureSave5()
494
    {
495
        $roleDao = new RoleDao($this->tdbmService);
496
        $role = $roleDao->getById(1);
497
        $userDao = new UserDao($this->tdbmService);
498
        $user = $userDao->getById(1);
499
500
        $user->addRole($role);
501
        $this->assertCount(1, $user->getRoles());
502
        $userDao->save($user);
503
    }
504
505
    /**
506
     * Step 6: we check that save was done
@@ 511-519 (lines=9) @@
508
     *
509
     * @depends testJointureSave5
510
     */
511
    public function testJointureSave6()
512
    {
513
        $roleDao = new RoleDao($this->tdbmService);
514
        $role = $roleDao->getById(1);
515
        $this->assertCount(2, $role->getUsers());
516
        $userDao = new UserDao($this->tdbmService);
517
        $user = $userDao->getById(1);
518
        $this->assertCount(1, $user->getRoles());
519
    }
520
521
    /**
522
     * Step 7: we add a new role to user 1 and save user 1.