Code Duplication    Length = 9-14 lines in 5 locations

tests/TDBMDaoGeneratorTest.php 5 locations

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