Passed
Push — master ( a58ef6...fc3cb3 )
by Alex
10:58 queued 01:08
created

ServiceUnitTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCustomRoutesLoading() 0 30 1
1
<?php
2
namespace Mezon\Service\Tests;
3
4
use Mezon\Service\ServiceConsoleTransport\ServiceConsoleTransport;
5
use Mezon\Service\ServiceModel;
6
7
class ServiceUnitTest extends ServiceUnitTests
8
{
9
10
    /**
11
     * Method tests does custom routes were loaded.
12
     * Trying to read routes both from php and json file and call routes from them.
13
     */
14
    public function testCustomRoutesLoading()
15
    {
16
        $_SERVER['REQUEST_METHOD'] = 'GET';
17
18
        $transport = $this->getMockBuilder(ServiceConsoleTransport::class)
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\MockOb...ckBuilder::setMethods() has been deprecated: https://github.com/sebastianbergmann/phpunit/pull/3687 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

18
        $transport = /** @scrutinizer ignore-deprecated */ $this->getMockBuilder(ServiceConsoleTransport::class)

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

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

Loading history...
19
            ->setMethods([
20
            'die'
21
        ])
22
            ->getMock();
23
24
        $service = new TestingService(
25
            TestingLogic::class,
26
            ServiceModel::class,
27
            $this->getSecurityProvider(AS_STRING),
28
            $transport);
29
30
        // route from routes.php
31
        $_GET['r'] = 'test';
32
        $service->run();
33
34
        // route from routes.json
35
        $_GET['r'] = 'test2';
36
        $service->run();
37
38
        $_GET['r'] = 'test3';
39
        ob_start();
40
        $service->run();
41
        $content = ob_get_contents();
42
        ob_end_clean();
43
        $this->assertStringContainsString('"message"', $content);
44
    }
45
}
46