J
J
JastaFly2021-12-08 18:02:10
1C-Bitrix
JastaFly, 2021-12-08 18:02:10

PHPunit and Bitrix?

You need to test one of the Bitrix components using PHPunit. How to initialize the Bitrix core to use the includeComponent and similar methods?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JastaFly, 2021-12-23
@JastaFly

I was able to initialize the Bitrix core in bootstrap.php:

<?php

define("NOT_CHECK_PERMISSIONS", true);
define("NO_AGENT_CHECK", true);

$_SERVER["DOCUMENT_ROOT"] = realpath(dirname(__FILE__) . "/../../");

require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
require_once($_SERVER["DOCUMENT_ROOT"] . "/vendor/autoload.php");

function initBitrixCore()
{
    global $DB;
    $app = \Bitrix\Main\Application::getInstance();
    $con = $app->getConnection();
    $DB->db_Conn = $con->getResource();
    $_SESSION["SESS_AUTH"]["USER_ID"] = 1;
}

Thank you Vamp for your answers!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question