Total Complexity | 5 |
Total Lines | 41 |
Duplicated Lines | 100 % |
Changes | 0 |
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 |
||
13 | class InvitationTest extends UnitTestCase |
||
14 | { |
||
15 | public function testInstantiation() |
||
16 | { |
||
17 | $this->assertInstanceOf('Lyal\Checkr\Entities\Resources\Invitation', $this->getInvitation()); |
||
18 | } |
||
19 | |||
20 | public function testSetId() |
||
21 | { |
||
22 | $invitation = $this->getInvitation(); |
||
23 | $invitation->id = 'e44aa283528e6fde7d542194'; |
||
24 | $this->assertSame('e44aa283528e6fde7d542194',$invitation->id); |
||
25 | } |
||
26 | |||
27 | public function testFields() |
||
28 | { |
||
29 | $values = [ |
||
30 | 'id' => 'e44aa283528e6fde7d542194', |
||
31 | 'status' => 'pending', |
||
32 | 'uri' => '/v1/invitations/e44aa283528e6fde7d542194', |
||
33 | 'invitation_url' => 'https://www.checkr.com/invitation', |
||
34 | 'completed_at' => NULL, |
||
35 | 'deleted_at' => NULL, |
||
36 | 'expires_at' => '2015-05-21T17:45:34Z', |
||
37 | 'package' => 'package', |
||
38 | 'object' => 'invitation', |
||
39 | 'created_at' => '2015-05-14T17:45:34Z', |
||
40 | 'candidate_id' => 'e44aa283528e6fde7d542194', |
||
41 | ]; |
||
42 | |||
43 | $invitation = $this->getInvitation($values); |
||
44 | |||
45 | foreach ($values as $key => $value) { |
||
46 | $this->assertEquals($value, $invitation->{$key}); |
||
47 | } |
||
48 | |||
49 | } |
||
50 | |||
51 | protected function getInvitation($values = NULL) |
||
52 | { |
||
53 | return new Invitation($values,$this->getClient()); |
||
54 | } |
||
55 | } |