R
R
Roman2019-01-09 13:45:55
Software testing
Roman, 2019-01-09 13:45:55

How to conduct unit tests in 1s bitrix using codeception?

How to make codeception and 1c bitrix friends? In the __before method I include files

require_once $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php';

This file connects fine, but when running the test, an error occurs: Test code or tested code did not (only) close its own output buffers
OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 2, Risky: 1.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2019-01-09
@roman94

Problem solved. If suddenly someone has a similar

$level = ob_get_level();
        require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';
        while (ob_get_level() > $level) {
            ob_end_clean();
        }

Since Phpunit sets its own buffer, if we clear it too, it starts to swear

V
Vasek18, 2019-02-19
@Vasek18

I got up on the same problem, but no errors are given, it just doesn’t reach the tests
After "Running with seeds:" there should be messages about passing the tests, but, as you can see on the screenshot, it doesn’t get to that and the command execution just stops
Connecting prologue in a separate file:

<?php

$_SERVER['DOCUMENT_ROOT'] = realpath(__DIR__.'/..');
$DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"];

define("NO_KEEP_STATISTIC", true);
define("NOT_CHECK_PERMISSIONS", true);
define('BX_NO_ACCELERATOR_RESET', true);
define("CHK_EVENT", true);
define('SITE_ID', 's1');

$level = ob_get_level();
require_once $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php';
while (ob_get_level() > $level) {
    ob_end_clean();
}

If you remove the work with the buffer, nothing changes. Nothing changes from the list of constants either.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question