Test Failed
Push — master ( c1559b...0edaee )
by Mauro
02:36
created

PilotApiClientTest::testLeadDataIsEmpty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 * Class PilotApiClientTest
4
 *
5
 * @author Mauro Moreno <[email protected]>
6
 */
7
namespace Zephia\PilotApiClient\Tests\Client;
8
9
use Zephia\PilotApiClient\Client\PilotApiClient;
10
use GuzzleHttp\Client;
11
use GuzzleHttp\Subscriber\Mock;
12
use GuzzleHttp\Message\Response;
13
use Zephia\PilotApiClient\Exception\InvalidArgumentException;
14
use Zephia\PilotApiClient\Model\LeadData;
15
16
/**
17
 * Class NominatimClientTest
18
 * @package MauroMoreno\Client\Tests\Client
19
 */
20
class PilotApiClientTest extends \PHPUnit_Framework_TestCase
21
{
22
    /**
23
     * Test valid client
24
     */
25
    public function testValidClient()
26
    {
27
        $client = new PilotApiClient();
28
        $this->assertInstanceOf(Client::class, $client->getGuzzleClient());
29
    }
30
31
    /**
32
     * @expectedException        InvalidArgumentException
33
     */
34
    public function testLeadDataIsEmpty()
35
    {
36
        $client = new PilotApiClient();
37
        $client->storeLead(new LeadData());
38
    }
39
40
    /**
41
     * Test storeLead, ok
42
     */
43
    public function testStoreLeadOk()
44
    {
45
        $client = new PilotApiClient();
46
        //$mock = new Mock([new Response(200)]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
47
        $client->getGuzzleClient();
0 ignored issues
show
Unused Code introduced by
The call to the method Zephia\PilotApiClient\Cl...ient::getGuzzleClient() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
48
        $response = $client->storeLead(new LeadData([
0 ignored issues
show
Unused Code introduced by
$response 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...
49
            'firstname' => 'Test',
50
            'contact_type_id' => 1,
51
            'business_type_id' => 1,
52
            'suborigin_id' => "FFFF0000",
53
        ]));
54
    }
55
}