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

SubscriptionTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Importance

Changes 0
Metric Value
wmc 5
dl 41
loc 41
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\Resources\Subscription;
5
use Tests\UnitTestCase;
6
7
class SubscriptionTest extends UnitTestCase
8
{
9
    public function testInstantiation()
10
    {
11
        $this->assertInstanceOf('Lyal\Checkr\Entities\Resources\Subscription', $this->getSubscription());
12
    }
13
14
    public function testSetId()
15
    {
16
        $subscription = $this->getSubscription();
17
        $subscription->id = 'e44aa283528e6fde7d542194';
18
        $this->assertSame('e44aa283528e6fde7d542194',$subscription->id);
19
    }
20
21
    public function testFields()
22
    {
23
        $values = [
24
            'id' => '4722c07dd9a10c3985ae432a',
25
            'object' => 'subscription',
26
            'uri' => '/v1/subscriptions/4722c07dd9a10c3985ae432a',
27
            'status' => 'active',
28
            'created_at' => '2014-01-18T12:34:00Z',
29
            'canceled_at' => NULL,
30
            'package' => 'driver_pro',
31
            'interval_count' => 1,
32
            'interval_unit' => 'month',
33
            'start_date' => '2014-06-10',
34
            'candidate_id' => 'e44aa283528e6fde7d542194',
35
        ];
36
37
        $subscription = $this->getSubscription($values);
38
39
        foreach ($values as $key => $value) {
40
            $this->assertEquals($value, $subscription->{$key});
41
        }
42
43
    }
44
45
    protected function getSubscription($values = NULL)
46
    {
47
        return new Subscription($values,$this->getClient());
48
    }
49
}