Test Failed
Push — master ( 6bff04...e0da10 )
by Lyal
02:14
created

CountyCriminalSearchTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 75
Duplicated Lines 100 %

Importance

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

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\CountyCriminalSearch;
5
use Tests\UnitTestCase;
6
7
class CountyCriminalSearchTest extends UnitTestCase
8
{
9
    public function testInstantiation()
10
    {
11
        $this->assertInstanceOf('Lyal\Checkr\Entities\Screenings\CountyCriminalSearch', $this->getCountyCriminalSearch());
12
    }
13
14
    public function testSetId()
15
    {
16
        $countyCriminalSearch = $this->getCountyCriminalSearch();
17
        $countyCriminalSearch->id = 'e44aa283528e6fde7d542194';
18
        $this->assertSame('e44aa283528e6fde7d542194', $countyCriminalSearch->id);
19
    }
20
21
    public function testFields()
22
    {
23
        $values = [
24
            'id' => '539fdcf335644a0ef4000001',
25
            'object' => 'county_criminal_search',
26
            'uri' => '/v1/county_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
            'county' => 'SAN FRANCISCO',
32
            'state' => 'CA',
33
            'records' => [
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
                    [
43
                        'charge' => 'Sell Cocaine',
44
                        'charge_type' => NULL,
45
                        'charge_id' => NULL,
46
                        'classification' => 'Felony',
47
                        'deposition' => NULL,
48
                        'defendant' => 'John Alfred Smith',
49
                        'plaintiff' => NULL,
50
                        'sentence' => 'Active Punishment Minimum: 10M',
51
                        'disposition' => 'Guilty',
52
                        'probation_status' => NULL,
53
                        'offense_date' => '2011-04-22',
54
                        'deposition_date' => '2014-05-27',
55
                        'arrest_date' => '2011-04-22',
56
                        'charge_date' => NULL,
57
                        'sentence_date' => '2011-06-02',
58
                        'disposition_date' => '2011-06-02',
59
                    ]
60
            ]
61
        ];
62
63
        $countyCriminalSearch = $this->getCountyCriminalSearch($values);
64
65
        foreach ($values as $key => $value) {
66
            if (is_array($value)) {
67
                $value = collect($value);
68
            }
69
70
            $this->assertEquals($value, $countyCriminalSearch->{$key});
71
        }
72
73
    }
74
75
    /**
76
     * @param null $values
77
     * @return CountyCriminalSearch
78
     */
79
    protected function getCountyCriminalSearch($values = NULL)
80
    {
81
        return new CountyCriminalSearch($values,$this->getClient());
82
    }
83
}