Code Duplication    Length = 9-14 lines in 5 locations

tests/TDBMDaoGeneratorTest.php 5 locations

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