BaseTestCase   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A runApp() 0 20 2
1
<?php
2
/**
3
 * This file is part of user_management
4
 * User: Sinan TURGUT <[email protected]>
5
 * Date: 24.06.2019
6
 * php version 7.2
7
 *
8
 * @category Assessment
9
 * @package  UserManagement
10
 * @author   Sinan TURGUT <[email protected]>
11
 * @license  See LICENSE file
12
 * @link     https://dev.sinanturgut.com.tr
13
 */
14
15
namespace Tests;
16
17
use Slim\App;
0 ignored issues
show
Bug introduced by
The type Slim\App was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Slim\Http\Request;
0 ignored issues
show
Bug introduced by
The type Slim\Http\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use Slim\Http\Response;
0 ignored issues
show
Bug introduced by
The type Slim\Http\Response was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use Slim\Http\Environment;
0 ignored issues
show
Bug introduced by
The type Slim\Http\Environment was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
23
/**
24
 * Class BaseTestCase
25
 * @package Tests
26
 */
27
class BaseTestCase extends TestCase
28
{
29
30
    /**
31
     * @param $requestMethod
32
     * @param $requestUri
33
     * @param null $requestData
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $requestData is correct as it would always require null to be passed?
Loading history...
34
     * @return \Psr\Http\Message\ResponseInterface|Response
0 ignored issues
show
Bug introduced by
The type Psr\Http\Message\ResponseInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
35
     * @throws \Slim\Exception\MethodNotAllowedException
36
     * @throws \Slim\Exception\NotFoundException
37
     */
38
    public function runApp($requestMethod, $requestUri, $requestData = null)
39
    {
40
        $environment = Environment::mock(
41
            [
42
                'REQUEST_METHOD' => $requestMethod,
43
                'REQUEST_URI' => $requestUri
44
            ]
45
        );
46
        $request = Request::createFromEnvironment($environment);
47
        if (isset($requestData)) {
48
            $request = $request->withParsedBody($requestData);
49
        }
50
        $response = new Response();
51
        $settings = require __DIR__ . '/../src/settings.php';
52
        $app = new App($settings);
53
        require __DIR__ . '/../src/dependencies.php';
54
        require __DIR__ . '/../src/middleware.php';
55
        require __DIR__ . '/../src/routes.php';
56
        $response = $app->process($request, $response);
57
        return $response;
58
    }
59
60
}