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 |
||
| 17 | class DoctrineDatabaseTest extends TestCase |
||
| 18 | { |
||
| 19 | const EXISTING_NOTIFICATION_ID = 1; |
||
| 20 | const EXISTING_NOTIFICATION_DATA = [ |
||
| 21 | 'id' => 1, |
||
| 22 | 'owner_id' => 14, |
||
| 23 | 'is_pending' => 1, |
||
| 24 | 'type' => 'Workflow:Review', |
||
| 25 | 'created' => 1529995052, |
||
| 26 | 'data' => null, |
||
| 27 | ]; |
||
| 28 | |||
| 29 | public function setUp() |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @covers \eZ\Publish\Core\Persistence\Legacy\Notification\Gateway\DoctrineDatabase::insert() |
||
| 40 | */ |
||
| 41 | public function testInsert() |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @covers \eZ\Publish\Core\Persistence\Legacy\Notification\Gateway\DoctrineDatabase::getNotificationById() |
||
| 65 | */ |
||
| 66 | public function testGetNotificationById() |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @covers \eZ\Publish\Core\Persistence\Legacy\Notification\Gateway\DoctrineDatabase::updateNotification() |
||
| 77 | */ |
||
| 78 | public function testUpdateNotification() |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @covers \eZ\Publish\Core\Persistence\Legacy\Notification\Gateway\DoctrineDatabase::countUserNotifications() |
||
| 103 | */ |
||
| 104 | public function testCountUserNotifications() |
||
| 110 | |||
| 111 | /** |
||
| 112 | * @covers \eZ\Publish\Core\Persistence\Legacy\Notification\Gateway\DoctrineDatabase::countUserPendingNotifications() |
||
| 113 | */ |
||
| 114 | public function testCountUserPendingNotifications() |
||
| 120 | |||
| 121 | /** |
||
| 122 | * @covers \eZ\Publish\Core\Persistence\Legacy\Notification\Gateway\DoctrineDatabase::loadUserNotifications() |
||
| 123 | */ |
||
| 124 | public function testLoadUserNotifications() |
||
| 159 | |||
| 160 | /** |
||
| 161 | * @covers \eZ\Publish\Core\Persistence\Legacy\Notification\Gateway\DoctrineDatabase::delete() |
||
| 162 | */ |
||
| 163 | public function testDelete() |
||
| 169 | |||
| 170 | /** |
||
| 171 | * Return a ready to test DoctrineStorage gateway. |
||
| 172 | * |
||
| 173 | * @return \eZ\Publish\Core\Persistence\Legacy\Notification\Gateway\DoctrineDatabase |
||
| 174 | */ |
||
| 175 | protected function getGateway(): DoctrineDatabase |
||
| 181 | |||
| 182 | View Code Duplication | private function loadNotification(int $id): array |
|
| 190 | } |
||
| 191 |