Completed
Pull Request — master (#18)
by Harry
11:25 queued 05:35
created

testExceptionIncludeResponseStringAndCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of graze/gigya-client
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/gigya-client/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/gigya-client
12
 */
13
14
namespace Graze\Gigya\Test\Unit\Exception;
15
16
use Graze\Gigya\Exception\ResponseException;
17
use Graze\Gigya\Response\ResponseInterface;
18
use Graze\Gigya\Test\TestCase;
19
use Mockery as m;
20
21
class ResponseExceptionTest extends TestCase
22
{
23 View Code Duplication
    public function testInstanceOfRuntimeException()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
    {
25
        $response = m::mock(ResponseInterface::class);
26
        $response->shouldReceive('getErrorCode')
27
                 ->andReturn(0);
28
        $exception = new ResponseException($response);
29
30
        static::assertInstanceOf('RuntimeException', $exception);
31
    }
32
33
    public function testExceptionIncludeResponseStringAndCode()
34
    {
35
        $response = m::mock(ResponseInterface::class);
36
        $response->shouldReceive('getErrorCode')
37
                 ->andReturn(100001);
38
        $response->shouldReceive('__toString')
39
                 ->andReturn('some description from the response');
40
        $exception = new ResponseException($response);
41
42
        static::setExpectedException(
43
            ResponseException::class,
44
            'some description from the response',
45
            100001
46
        );
47
48
        throw $exception;
49
    }
50
51 View Code Duplication
    public function testGetResponse()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
    {
53
        $response = m::mock(ResponseInterface::class);
54
        $response->shouldReceive('getErrorCode')
55
                 ->andReturn(100001);
56
        $exception = new ResponseException($response);
57
58
        static::assertSame($response, $exception->getResponse());
59
    }
60
}
61