-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Примерный bootstrap.php & phpunit.xml.dist
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
$documentRootEnvName = 'DOCUMENT_ROOT'; | ||
$documentRoot = getenv($documentRootEnvName); | ||
|
||
if ($documentRoot === false) { | ||
$documentRoot = dirname(dirname(__DIR__)); | ||
if (!is_dir($documentRoot . '/bitrix/') || !is_file($documentRoot . '/bitrix/modules/main/include.php')) { | ||
throw new RuntimeException(sprintf('Bitrix not found. Setup environment variable `%s`', $documentRootEnvName)); | ||
} | ||
} | ||
|
||
if (!is_dir($documentRoot)) { | ||
throw new RuntimeException( | ||
sprintf( | ||
'Document root folder doesn`t exist: %s', | ||
$documentRoot | ||
) | ||
); | ||
} | ||
|
||
$_SERVER['DOCUMENT_ROOT'] = $documentRoot; | ||
|
||
define('LANGUAGE_ID', 'pa'); | ||
define('NO_KEEP_STATISTIC', true); | ||
define('NOT_CHECK_PERMISSIONS', true); | ||
define('LOG_FILENAME', 'php://stderr'); | ||
define('BX_NO_ACCELERATOR_RESET', true); | ||
define('STOP_STATISTICS', true); | ||
define('NO_AGENT_STATISTIC', 'Y'); | ||
define('DisableEventsCheck', true); | ||
define('NO_AGENT_CHECK', true); | ||
|
||
require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php'); | ||
|
||
// Альтернативный способ вывода ошибок типа "DB query error.": | ||
$GLOBALS['DB']->debug = true; | ||
|
||
global $DB; | ||
$app = \Bitrix\Main\Application::getInstance(); | ||
$con = $app->getConnection(); | ||
$DB->db_Conn = $con->getResource(); | ||
|
||
// "authorizing" as admin | ||
$_SESSION['SESS_AUTH']['USER_ID'] = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap/bootstrap.php" colors="true" executionOrder="random" resolveDependencies="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Tests"> | ||
<!-- Директории с тестами --> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<server name='HTTP_HOST' value='localhost' /> | ||
<server name='SERVER_NAME' value='localhost' /> | ||
<!-- Так можно напрямую задать DOCUMENT_ROOT --> | ||
<!--<env name='DOCUMENT_ROOT' value='/path/to/root' /> --> | ||
</php> | ||
</phpunit> |