Test Failed
Push — master ( 7c4720...fd955c )
by Lyal
04:00 queued 14s
created

StateCriminalSearchTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 73
Duplicated Lines 100 %

Importance

Changes 0
Metric Value
wmc 6
dl 73
loc 73
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testFields() 52 52 3
A getStateCriminalSearch() 3 3 1
A testSetId() 5 5 1
A testInstantiation() 3 3 1

How to fix   Duplicated Code   

Duplicated Code

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
2
namespace Tests\Unit;
3
4
use Lyal\Checkr\Entities\Screenings\StateCriminalSearch;
5
use Tests\UnitTestCase;
6
7 View Code Duplication
class StateCriminalSearchTest extends UnitTestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    public function testInstantiation()
10
    {
11
        $this->assertInstanceOf('Lyal\Checkr\Entities\Screenings\StateCriminalSearch', $this->getStateCriminalSearch());
12
    }
13
14
    public function testSetId()
15
    {
16
        $stateCriminalSearch = $this->getStateCriminalSearch();
17
        $stateCriminalSearch->id = 'e44aa283528e6fde7d542194';
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on Lyal\Checkr\Entities\Scr...ngs\StateCriminalSearch. Since you implemented __set, consider adding a @property annotation.
Loading history...
18
        $this->assertSame('e44aa283528e6fde7d542194', $stateCriminalSearch->id);
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on Lyal\Checkr\Entities\Scr...ngs\StateCriminalSearch. Since you implemented __get, consider adding a @property annotation.
Loading history...
19
    }
20
21
    public function testFields()
22
    {
23
        $values = [
24
            'id' => '539fdcf335644a0ef4000001',
25
            'object' => 'state_criminal_search',
26
            'uri' => '/v1/state_criminal_searches/539fdcf335644a0ef4000001',
27
            'status' => 'consider',
28
            'created_at' => '2014-01-18T12:34:00Z',
29
            'completed_at' => '2014-01-18T12:35:30Z',
30
            'turnaround_time' => 100800,
31
            'state' => 'CA',
32
            'records' => [
33
                [
34
                    'case_number' => '24323-DA',
35
                    'file_date' => '2010-02-18',
36
                    'arresting_agency' => 'San Francisco Police Department',
37
                    'court_jurisdiction' => 'San Francisco',
38
                    'court_of_record' => NULL,
39
                    'dob' => '1970-01-22',
40
                    'full_name' => 'John Alfred Smith',
41
                    'charges' => [
42
                        ['charge' => 'Sell Cocaine',
43
                            'charge_type' => NULL,
44
                            'charge_id' => NULL,
45
                            'classification' => 'Felony',
46
                            'deposition' => NULL,
47
                            'defendant' => 'John Alfred Smith',
48
                            'plaintiff' => NULL,
49
                            'sentence' => 'Active Punishment Minimum: 10M',
50
                            'disposition' => 'Guilty',
51
                            'probation_status' => NULL,
52
                            'offense_date' => '2011-04-22',
53
                            'deposition_date' => '2014-05-27',
54
                            'arrest_date' => '2011-04-22',
55
                            'charge_date' => NULL,
56
                            'sentence_date' => '2011-06-02',
57
                            'disposition_date' => '2011-06-02',
58
                        ]
59
60
                    ]
61
                ]
62
            ]
63
        ];
64
65
        $stateCriminalSearch = $this->getStateCriminalSearch($values);
66
67
        foreach ($values as $key => $value) {
68
            if (is_array($value)) {
69
                $value = collect($value);
70
            }
71
72
            $this->assertEquals($value, $stateCriminalSearch->{$key});
73
        }
74
75
    }
76
77
    protected function getStateCriminalSearch($values = NULL)
78
    {
79
        return new StateCriminalSearch($values,$this->getClient());
80
    }
81
}