Completed
Push — master ( 1b5410...64fdd0 )
by Jean C.
28s
created

EscrowTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 17
rs 10
c 2
b 0
f 0
wmc 1
lcom 1
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A testShouldReleaseEscrow() 0 14 1
1
<?php
2
3
namespace Moip\Tests\Resource;
4
5
use Moip\Tests\TestCase;
6
7
class EscrowTest extends TestCase
8
{
9
    public function testShouldReleaseEscrow()
10
    {
11
        $this->mockHttpSession($this->body_order);
12
        $order = $this->createOrder()->create();
13
        $cc = '5555666677778884';
14
        $this->mockHttpSession($this->body_cc_pay_pci_escrow);
15
        $payment = $order->payments()
0 ignored issues
show
Bug introduced by
The method payments does only exist in Moip\Resource\Orders, but not in stdClass.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
16
            ->setCreditCard(5, 2018, $cc, 123, $this->createCustomer(), false)
17
            ->setEscrow('teste de descricao')
18
            ->execute();
19
        $this->mockHttpSession($this->body_release_escrow);
20
        $escrow = $payment->escrows()->release();
21
        $this->assertEquals('RELEASED', $escrow->getStatus());
22
    }
23
}
24