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\Module; |
13
|
|
|
use Spryker\Shared\Kernel\CodeBucket\Config\CodeBucketConfig; |
14
|
|
|
use Spryker\Shared\Kernel\CodeBucket\Config\CodeBucketConfigInterface; |
15
|
|
|
|
16
|
|
|
class Environment extends Module |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
protected const TESTING_APPLICATION_ENV_NAME = 'devtest'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @return void |
25
|
|
|
*/ |
26
|
|
|
public function _initialize(): void |
27
|
|
|
{ |
28
|
|
|
$rootDir = realpath(__DIR__ . '/../../../../../../'); |
29
|
|
|
$applicationEnv = $this->getApplicationEnv(); |
30
|
|
|
|
31
|
|
|
defined('APPLICATION_ENV') || define('APPLICATION_ENV', $applicationEnv); |
32
|
|
|
defined('APPLICATION_STORE') || define('APPLICATION_STORE', (isset($_SERVER['APPLICATION_STORE']) && $_SERVER['APPLICATION_STORE'] !== '') ? $_SERVER['APPLICATION_STORE'] : 'DE'); // phpcs:ignore SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable |
33
|
|
|
putenv('APPLICATION_STORE=' . APPLICATION_STORE); |
34
|
|
|
|
35
|
|
|
defined('APPLICATION') || define('APPLICATION', ''); |
36
|
|
|
|
37
|
|
|
defined('APPLICATION_ROOT_DIR') || define('APPLICATION_ROOT_DIR', $rootDir); |
38
|
|
|
defined('APPLICATION_SOURCE_DIR') || define('APPLICATION_SOURCE_DIR', APPLICATION_ROOT_DIR . '/src'); |
39
|
|
|
defined('APPLICATION_VENDOR_DIR') || define('APPLICATION_VENDOR_DIR', APPLICATION_ROOT_DIR . '/vendor'); |
40
|
|
|
|
41
|
|
|
defined('APPLICATION_CODE_BUCKET') || define('APPLICATION_CODE_BUCKET', $this->createCodeBucketConfig()->getCurrentCodeBucket()); |
42
|
|
|
putenv('APPLICATION_CODE_BUCKET=' . APPLICATION_CODE_BUCKET); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
protected function getApplicationEnv(): string |
49
|
|
|
{ |
50
|
|
|
if (getenv('SPRYKER_TESTING_ENABLED')) { |
51
|
|
|
return getenv('APPLICATION_ENV'); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return static::TESTING_APPLICATION_ENV_NAME; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return \Spryker\Shared\Kernel\CodeBucket\Config\CodeBucketConfigInterface |
59
|
|
|
*/ |
60
|
|
|
protected function createCodeBucketConfig(): CodeBucketConfigInterface |
61
|
|
|
{ |
62
|
|
|
return new CodeBucketConfig(); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|