|
2 | 2 |
|
3 | 3 | namespace Prokl\BitrixTestingTools\Base;
|
4 | 4 |
|
5 |
| -use Bitrix\Catalog\Model\Price; |
| 5 | +use Bitrix\Main\Application; |
6 | 6 | use Exception;
|
7 | 7 | use Prokl\BitrixTestingTools\Migrations\ArrilotMigratorProcessor;
|
8 | 8 | use Prokl\BitrixTestingTools\Migrator;
|
|
13 | 13 | use Prokl\BitrixTestingTools\Traits\SprintMigrationsTrait;
|
14 | 14 | use Prokl\BitrixTestingTools\Traits\UseMigrationsTrait;
|
15 | 15 | use Prokl\TestingTools\Base\BaseTestCase;
|
| 16 | +use ReflectionClass; |
| 17 | +use ReflectionException; |
16 | 18 | use Sheerockoff\BitrixCi\Bootstrap;
|
17 | 19 |
|
18 | 20 | /**
|
@@ -100,6 +102,41 @@ protected function setupDatabaseData() : void
|
100 | 102 | putenv('MYSQL_PASSWORD=');
|
101 | 103 | }
|
102 | 104 |
|
| 105 | + /** |
| 106 | + * Эмуляция нахождения на какой-либо странице. Выставляется все, что связано с URL - как в D7, |
| 107 | + * так и в старом ядре. |
| 108 | + * |
| 109 | + * @param string $url URL. |
| 110 | + * |
| 111 | + * @return void |
| 112 | + * |
| 113 | + * @throws ReflectionException |
| 114 | + * |
| 115 | + * @since 15.06.2021 |
| 116 | + */ |
| 117 | + protected function goTo(string $url) : void |
| 118 | + { |
| 119 | + $_SERVER['REQUEST_URI'] = $url; |
| 120 | + $GLOBALS['APPLICATION']->sDirPath = GetPagePath(false, true); |
| 121 | + |
| 122 | + $application = Application::getInstance(); |
| 123 | + |
| 124 | + $reflection = new ReflectionClass($application); |
| 125 | + $reflection_property = $reflection->getProperty('isExtendedKernelInitialized'); |
| 126 | + $reflection_property->setAccessible(true); |
| 127 | + $reflection_property->setValue($application, false); |
| 128 | + |
| 129 | + $application->initializeExtendedKernel( |
| 130 | + [ |
| 131 | + 'server' => $_SERVER, |
| 132 | + 'get' => $_GET, |
| 133 | + 'post' => $_POST, |
| 134 | + 'files' => $_FILES, |
| 135 | + 'cookie' => $_COOKIE, |
| 136 | + ] |
| 137 | + ); |
| 138 | + } |
| 139 | + |
103 | 140 | /**
|
104 | 141 | * Битриксовые штучки-дрючки с буфером.
|
105 | 142 | *
|
|
0 commit comments