Completed
Pull Request — master (#27)
by Harry
06:09
created

tests/unit/Exception/ResponseExceptionTest.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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
    /**
34
     * @expectedException \Graze\Gigya\Exception\ResponseException
35
     * @expectedExceptionCode    100001
36
     * @expectedExceptionMessage some description from the response
37
     */
38 View Code Duplication
    public function testExceptionIncludeResponseStringAndCode()
0 ignored issues
show
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...
39
    {
40
        $response = m::mock(ResponseInterface::class);
41
        $response->shouldReceive('getErrorCode')
42
                 ->andReturn(100001);
43
        $response->shouldReceive('__toString')
44
                 ->andReturn('some description from the response');
45
        $exception = new ResponseException($response);
46
47
        throw $exception;
48
    }
49
50 View Code Duplication
    public function testGetResponse()
0 ignored issues
show
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...
51
    {
52
        $response = m::mock(ResponseInterface::class);
53
        $response->shouldReceive('getErrorCode')
54
                 ->andReturn(100001);
55
        $exception = new ResponseException($response);
56
57
        static::assertSame($response, $exception->getResponse());
58
    }
59
}
60