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

ServiceUnitTest::testCustomRoutesLoading()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 20
nc 1
nop 0
dl 0
loc 30
rs 9.6
c 0
b 0
f 0
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