Completed
Pull Request — master (#37)
by Vitaliy
07:07 queued 04:03
created

PinCodeResponseTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 4
c 1
b 1
f 0
lcom 1
cbo 3
dl 0
loc 38
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testPinCodeHasInvalidType() 0 8 1
A testPinCodeIsEmptyString() 0 8 1
A testPinCodeIsNull() 0 8 1
A testPinCodeResponse() 0 8 1
1
<?php
2
3
namespace Xsolla\SDK\Tests\Unit\Webhook\Message;
4
5
use Xsolla\SDK\Webhook\Response\PinCodeResponse;
6
7
/**
8
 * @group unit
9
 */
10
class PinCodeResponseTest extends \PHPUnit_Framework_TestCase
11
{
12
    public function testPinCodeHasInvalidType()
13
    {
14
        $this->setExpectedException(
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
15
            '\Xsolla\SDK\Exception\Webhook\XsollaWebhookException',
16
            'Pin code should be non-empty string. stdClass given'
17
        );
18
        new PinCodeResponse(new \stdClass());
1 ignored issue
show
Documentation introduced by
new \stdClass() is of type object<stdClass>, but the function expects a string.

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...
19
    }
20
21
    public function testPinCodeIsEmptyString()
22
    {
23
        $this->setExpectedException(
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
24
            '\Xsolla\SDK\Exception\Webhook\XsollaWebhookException',
25
            'Pin code should be non-empty string. NULL given'
26
        );
27
        new PinCodeResponse(null);
28
    }
29
30
    public function testPinCodeIsNull()
31
    {
32
        $this->setExpectedException(
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
33
            '\Xsolla\SDK\Exception\Webhook\XsollaWebhookException',
34
            'Pin code should be non-empty string. Empty string given'
35
        );
36
        new PinCodeResponse('');
37
    }
38
39
    public function testPinCodeResponse()
40
    {
41
        $response = new PinCodeResponse('pin_code');
42
        $this->assertJsonStringEqualsJsonString(
43
            '{"pin_code":"pin_code"}',
44
            $response->getSymfonyResponse()->getContent()
45
        );
46
    }
47
}
48