|
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()); |
|
|
|
|
|
|
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
|
|
|
|