Setting up automated testing in CI/CD for 1C-Bitrix

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Setting up automatic testing in CI/CD for 1C-Bitrix

Tests are written, but developers run them manually — and forget. Code goes to production without validation, tests become outdated, coverage degrades. Automatic testing in CI/CD solves the organizational problem: code cannot get to the main branch without passing tests. For Bitrix this is more complex than for Symfony or Laravel due to core dependencies and database requirements, but entirely solvable.

Pipeline architecture

A minimal CI pipeline for a Bitrix project:

  1. Checkout — get code from repository
  2. Composer install — install dependencies (PHPUnit, phpstan, php-cs-fixer)
  3. Lintphp -l for all PHP files, syntax check
  4. Static analysis — PHPStan / Psalm
  5. Unit tests — fast tests without Bitrix core
  6. Integration tests — tests with core and database connectivity
  7. Deploy (main branch only)

Docker image for CI

The main complexity — the Bitrix core. It doesn't install via Composer. Options:

Option A: core in Docker image. Create a base image with installed Bitrix, PHP and extensions. Update the image when the core is updated on the project. This is the most reliable approach.

FROM php:8.1-cli
RUN apt-get update && apt-get install -y libpq-dev libzip-dev \
    && docker-php-ext-install pdo pdo_mysql opcache zip
COPY bitrix/ /var/www/bitrix/
COPY composer.json composer.lock /var/www/
WORKDIR /var/www
RUN composer install --no-dev

Option B: core via artifact. CI downloads core from private storage (S3, GitLab Package Registry) during preparation. More flexible, but slower.

GitLab CI setup

stages:
  - lint
  - test
  - deploy

variables:
  MYSQL_DATABASE: bitrix_test
  MYSQL_ROOT_PASSWORD: test

lint:
  stage: lint
  image: php:8.1-cli
  script:
    - find local/ -name "*.php" -exec php -l {} \;
    - vendor/bin/phpstan analyse local/php_interface/classes/ --level 5

integration-tests:
  stage: test
  image: registry.example.com/bitrix-ci:latest
  services:
    - mysql:8.0
  script:
    - cp .env.ci .env
    - php local/tests/setup_db.php
    - vendor/bin/phpunit --configuration local/tests/phpunit.xml
  artifacts:
    when: always
    reports:
      junit: local/tests/report.xml

Key points:

  • services: mysql — starts MySQL container, accessible at hostname mysql inside CI
  • setup_db.php — script creating test database schema (minimal Bitrix table set)
  • artifacts: junit — GitLab/GitHub displays test results in merge request interface

For GitHub Actions

name: Tests
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    services:
      mysql:
        image: mysql:8.0
        env:
          MYSQL_DATABASE: bitrix_test
          MYSQL_ROOT_PASSWORD: test
        ports:
          - 3306:3306
    steps:
      - uses: actions/checkout@v4
      - uses: shivammathur/setup-php@v2
        with:
          php-version: '8.1'
          extensions: pdo_mysql, mbstring, zip, gd
      - run: composer install
      - run: vendor/bin/phpunit --configuration local/tests/phpunit.xml

Test database schema

Full Bitrix database contains 500+ tables. For integration tests you need a minimal set:

  • b_option, b_module, b_module_to_module — module configuration
  • b_iblock, b_iblock_type, b_iblock_element, b_iblock_section, b_iblock_property, b_iblock_element_property — iblocks
  • b_catalog_price, b_catalog_currency — catalog and currencies
  • b_sale_order, b_sale_basket, b_sale_order_props_value — orders (if testing e-commerce)

Create schema dump from production: mysqldump --no-data bitrix > schema.sql. Add to repository and update when schema changes.

What must be checked in CI

PHP Lint. Trivial, but catches syntax errors in files that aren't called in manual testing. Bitrix projects often contain files included conditionally (by agent, by cron) — errors are discovered only in production.

PHPStan level 5+. At level 5, PHPStan finds calls to non-existent methods, incorrect argument types, undefined variables. For Bitrix code you'll need a phpstan-baseline.neon file to ignore core errors — the core is untyped and generates hundreds of warnings.

HTTP smoke tests. If CI raises full environment (PHP-FPM + Nginx + MySQL), add curl checks for critical URLs:

curl -f http://localhost/
curl -f http://localhost/catalog/
curl -f http://localhost/personal/cart/

Status 200 — test passes. Any other — pipeline fails.

Execution time

Stage Time
Lint + static analysis 30-60 seconds
Unit tests (without core) 10-30 seconds
Integration tests (with core and DB) 2-10 minutes
Full pipeline 5-15 minutes

If integration tests take more than 15 minutes — split them into parallel jobs by modules. GitLab CI and GitHub Actions support parallel matrix strategies.

Setting up CI/CD for a Bitrix project is a one-day investment that pays for itself on the first prevented production bug.