YvesBootstrap   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 12
c 0
b 0
f 0
dl 0
loc 44
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A _beforeSuite() 0 3 1
A _initialize() 0 3 1
A loadApplication() 0 14 2
1
<?php
2
3
/**
4
 * This file is part of the Spryker Commerce OS.
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
declare(strict_types = 1);
9
10
namespace PyzTest\Shared\Testify\Helper;
11
12
use Codeception\Exception\ModuleConfigException;
13
use Codeception\Lib\Framework;
14
use Pyz\Yves\ShopApplication\YvesBootstrap as PyzYvesBootstrap;
15
use Symfony\Component\HttpFoundation\Request;
16
use Symfony\Component\HttpKernel\HttpKernelBrowser;
17
18
class YvesBootstrap extends Framework
19
{
20
    /**
21
     * @var \Pyz\Yves\ShopApplication\YvesBootstrap
22
     */
23
    private $yvesBootstrap;
24
25
    /**
26
     * @return void
27
     */
28
    public function _initialize(): void
29
    {
30
        $this->loadApplication();
31
    }
32
33
    /**
34
     * @param array $settings
35
     *
36
     * @return void
37
     */
38
    public function _beforeSuite($settings = []): void // phpcs:ignore
39
    {
40
        $this->client = new HttpKernelBrowser($this->yvesBootstrap->boot());
0 ignored issues
show
Bug introduced by
$this->yvesBootstrap->boot() of type Spryker\Shared\Application\ApplicationInterface is incompatible with the type Symfony\Component\HttpKernel\HttpKernelInterface expected by parameter $kernel of Symfony\Component\HttpKe...lBrowser::__construct(). ( Ignorable by Annotation )

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

40
        $this->client = new HttpKernelBrowser(/** @scrutinizer ignore-type */ $this->yvesBootstrap->boot());
Loading history...
41
    }
42
43
    /**
44
     * @throws \Codeception\Exception\ModuleConfigException
45
     *
46
     * @return void
47
     */
48
    protected function loadApplication(): void
49
    {
50
        $this->yvesBootstrap = new PyzYvesBootstrap();
51
52
        $requestFactory = function (array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null) {
53
            $request = new Request($query, $request, $attributes, $cookies, $files, $server, $content);
54
            $request->server->set('SERVER_NAME', 'localhost');
55
56
            return $request;
57
        };
58
        Request::setFactory($requestFactory);
59
60
        if ($this->yvesBootstrap === null) {
61
            throw new ModuleConfigException(self::class, 'Application instance was not received from bootstrap file');
62
        }
63
    }
64
}
65