Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php  | 
            ||
| 18 | class RepositoryTest extends BaseServiceMockTest  | 
            ||
| 19 | { | 
            ||
| 20 | /**  | 
            ||
| 21 | * Test for the beginTransaction() method.  | 
            ||
| 22 | *  | 
            ||
| 23 | * @covers \eZ\Publish\API\Repository\Repository::beginTransaction  | 
            ||
| 24 | */  | 
            ||
| 25 | public function testBeginTransaction()  | 
            ||
| 38 | |||
| 39 | /**  | 
            ||
| 40 | * Test for the commit() method.  | 
            ||
| 41 | *  | 
            ||
| 42 | * @covers \eZ\Publish\API\Repository\Repository::commit  | 
            ||
| 43 | */  | 
            ||
| 44 | View Code Duplication | public function testCommit()  | 
            |
| 57 | |||
| 58 | /**  | 
            ||
| 59 | * Test for the commit() method.  | 
            ||
| 60 | *  | 
            ||
| 61 | * @covers \eZ\Publish\API\Repository\Repository::commit  | 
            ||
| 62 | * @expectedException \RuntimeException  | 
            ||
| 63 | */  | 
            ||
| 64 | View Code Duplication | public function testCommitThrowsRuntimeException()  | 
            |
| 79 | |||
| 80 | /**  | 
            ||
| 81 | * Test for the rollback() method.  | 
            ||
| 82 | *  | 
            ||
| 83 | * @covers \eZ\Publish\API\Repository\Repository::rollback  | 
            ||
| 84 | */  | 
            ||
| 85 | View Code Duplication | public function testRollback()  | 
            |
| 98 | |||
| 99 | /**  | 
            ||
| 100 | * Test for the rollback() method.  | 
            ||
| 101 | *  | 
            ||
| 102 | * @covers \eZ\Publish\API\Repository\Repository::rollback  | 
            ||
| 103 | * @expectedException \RuntimeException  | 
            ||
| 104 | */  | 
            ||
| 105 | View Code Duplication | public function testRollbackThrowsRuntimeException()  | 
            |
| 120 | }  | 
            ||
| 121 |