TrackerTest   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 2
dl 0
loc 89
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 4 1
A testTrackingNumberIsInvalid1() 0 4 1
A testTrackingNumberIsInvalid2() 0 4 1
A testTrackingNumberIsInvalid3() 0 4 1
A testTrackingNumberIsInvalid4() 0 4 1
A testTrackingNumberIsInvalid5() 0 4 1
A testTrackingNumberIsValidButCredentialsAreNot() 0 4 1
A testApiResponseProcessingIsSuccessful() 0 5 1
A testApiResponseProcessingIsUnsuccessful() 0 10 1
1
<?php
2
3
use CorreiosAPI\Tracker;
4
5
class TrackerTest extends TestCase
6
{
7
  protected $tracker = null;
8
9
  public function setup()
10
  {
11
    $this->tracker = new Tracker('NOT', 'VALID');
12
  }
13
14
  /**
15
   * @expectedException              InvalidArgumentException
16
   * @expectedExceptionMessageRegExp /is not a valid tracking number/
17
   */
18
  public function testTrackingNumberIsInvalid1()
19
  {
20
    $this->tracker->track('STRINGS');
21
  }
22
23
  /**
24
   * @expectedException              InvalidArgumentException
25
   * @expectedExceptionMessageRegExp /is not a valid tracking number/
26
   */
27
  public function testTrackingNumberIsInvalid2()
28
  {
29
    $this->tracker->track('123456');
30
  }
31
32
  /**
33
   * @expectedException              InvalidArgumentException
34
   * @expectedExceptionMessageRegExp /is not a valid tracking number/
35
   */
36
  public function testTrackingNumberIsInvalid3()
37
  {
38
    $this->tracker->track('0012345678900');
39
  }
40
41
  /**
42
   * @expectedException              InvalidArgumentException
43
   * @expectedExceptionMessageRegExp /is not a valid tracking number/
44
   */
45
  public function testTrackingNumberIsInvalid4()
46
  {
47
    $this->tracker->track('RRXXXXXXXXXEE');
48
  }
49
50
  /**
51
   * @expectedException              InvalidArgumentException
52
   * @expectedExceptionMessageRegExp /is not a valid tracking number/
53
   */
54
  public function testTrackingNumberIsInvalid5()
55
  {
56
    $this->tracker->track('RR1234567890E');
57
  }
58
59
  /**
60
   * Bad test, API call should be mocked
61
   * @TODO: mock api call
62
   * @expectedException              RuntimeException
63
   */
64
  public function testTrackingNumberIsValidButCredentialsAreNot()
65
  {
66
    $this->tracker->track('RR123456789EE');
67
  }
68
69
  /**
70
   * @TODO: mock api call
71
   */
72
  public function testApiResponseProcessingIsSuccessful()
73
  {
74
    $goodResponse = '{}';
0 ignored issues
show
Unused Code introduced by
$goodResponse is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
75
    $this->markTestIncomplete('Must mock HTTP request.');
76
  }
77
78
  /**
79
   * @TODO: mock api call
80
   * @expectedException              RuntimeException
81
   * @expectedExceptionMessageRegExp /API call error/
82
   */
83
  public function testApiResponseProcessingIsUnsuccessful()
84
  {
85
    $badResponse = '<?xml version="1.0" encoding="iso-8859-1" ?>
0 ignored issues
show
Unused Code introduced by
$badResponse is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
86
                    <sroxml>
87
                       <versao>1.0</versao>
88
                         <error>falha na autenticao do usuio</error>
89
                    </sroxml>';
90
91
    $this->markTestIncomplete('Must mock HTTP request.');
92
  }
93
}
94