Completed
Push — master ( 0a5acd...43aa97 )
by Guilherme Luiz Argentino
05:40
created

correiosTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 3

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructClass() 0 4 1
A testGetContent() 0 5 1
A testGetOrderShippingCostSEDEXHoje() 0 4 1
A testGetOrderShippingCostSEDEX10() 0 4 1
A testGetOrderShippingCostSEDEX() 0 4 1
A testGetOrderShppingCost() 0 8 1
1
<?php
2
3
class correiosTest extends PHPUnit_Framework_TestCase {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
    /**
6
    * Testa o construtor da classe
7
    */
8
    public function testConstructClass()
9
    {
10
        $this->assertInstanceOf('correios', new correios);
11
    }
12
13
    public function testGetContent()
14
    {
15
        $correios = new correios();
16
        $this->assertContains('submitcarrinho_correios', $correios->getContent());
17
    }
18
19
    public function testGetOrderShippingCostSEDEXHoje()
20
    {
21
        $this->testGetOrderShppingCost("4", 10, 33);
22
    }
23
24
    public function testGetOrderShippingCostSEDEX10()
25
    {
26
        $this->testGetOrderShppingCost("3", 10, 27.799999999999997);
27
    }
28
29
    public function testGetOrderShippingCostSEDEX()
30
    {
31
        $this->testGetOrderShppingCost("2", 10, 17.199999999999999);
32
    }
33
34
    public function testGetOrderShppingCost($id_carrier = "1", $shipping_cost = 10, $expected_value = 16.1)
35
    {
36
        $correios = new correios();
37
        $correios->id_carrier = $id_carrier;
38
        $params = new Params();
39
        $frete = $correios->getOrderShippingCost($params, $shipping_cost);
0 ignored issues
show
Documentation introduced by
$params is of type object<Params>, but the function expects a object<type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$shipping_cost is of type integer, but the function expects a object<type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
40
        $this->assertEquals($shipping_cost + $expected_value, $frete);
41
    }
42
}