Перейти к содержимому
PHP Ecosystem
Explore

Testing

Это содержимое пока не доступно на вашем языке.

This package provides a consistent set of Composer scripts for local validation.

Tool references:

Run Rector to apply automated code refactoring. This command modifies files.

Terminal window
composer rector

Preview the refactoring without modifying files.

Terminal window
composer rector-check

Check coding standards without modifying files.

Terminal window
composer ecs-check

Apply coding standard fixes. Review the changes before keeping them.

Terminal window
composer ecs

Verify that runtime dependencies are correctly declared in composer.json.

Terminal window
composer check-dependencies

Run mutation testing through the launcher described under OpenLDAP directories. Without the directories the openldap group is skipped, some mutants survive and the thresholds are not met.

Terminal window
bash tests/integration/run-openldap.sh composer mutation

Run mutation testing with PHPStan static analysis enabled. CI uses this variant and enforces the thresholds in infection.json5; some mutants are caught only by static analysis, so the plain command reports a lower score.

Terminal window
bash tests/integration/run-openldap.sh composer mutation-static

CI runs actionlint, codespell, EditorConfig Checker, markdownlint-cli2, Prettier and yamllint through the shared yii2-framework/actions quality workflow. The repository’s formatting rules stay in .editorconfig.

Make actionlint and ShellCheck available on PATH to lint workflows locally.

Terminal window
composer actionlint

Run static analysis.

Terminal window
composer static

The test suite needs the PHP LDAP extension. Without a directory server it covers configuration, registry ownership, setup ordering and failure handling, and skips the openldap group. Install dependencies for one Yii release at a time and repeat with the other version to check compatibility.

Terminal window
composer update --with yiisoft/yii2:2.0.55
composer tests

Use 22.0.x-dev in place of 2.0.55 for the Yii 22 check. To generate a Clover report with PCOV or Xdebug, run:

Terminal window
composer tests -- --coverage-clover runtime/coverage.xml

The openldap group runs against real directories: login, distinct groups for the same username, multi-page synchronization, attribute mapping, single-value membership changes, read-only LDAP ACLs, service-credential handling and rejection of an untrusted certificate even when the process-wide TLS policy is permissive.

Install the OpenLDAP server tools (slapd and slapadd) and OpenSSL. The launcher starts three temporary servers bound to loopback, generates a disposable CA and certificates, runs a command with the connection settings in its environment and cleans up on exit. It uses no existing directory or credentials. Run the whole suite with the directories available:

Terminal window
bash tests/integration/run-openldap.sh composer tests

Without a command it runs only the openldap group. With --detach it leaves the servers running and writes the settings to GITHUB_ENV, which is how the CI jobs share them with later steps.

On systems that install OpenLDAP schemas outside /etc/ldap/schema, set LDAP_SCHEMA_DIR; Arch Linux uses /etc/openldap/schema. If MDB is a shared module, set LDAP_MODULE_DIR to the OpenLDAP module directory. To use alternate binaries or ports, set SLAPD_BIN, SLAPADD_BIN, LDAP_TEST_PORT_A, LDAP_TEST_PORT_B or LDAP_TEST_PORT_C.

On Ubuntu runners tests/integration/install-openldap.sh installs slapd and allows the fixture directory in the packaged AppArmor profile when its local include is present. It does not disable the profile.

Before deployment, repeat these checks with non-privileged test accounts in your directory system. The tests above do not establish Active Directory interoperability. Verify your AD bind format, CA and hostname, plain LDAP refusal, and membership ACLs independently. Confirm that the application’s failed logins cannot create a session and that monitoring does not capture credentials. Do not use production secrets for acceptance testing.

CI runs zizmor and Gitleaks through the shared security workflow. Gitleaks uses its default rules. The Gitleaks scan requires GITLEAKS_LICENSE in the workflow.

Make zizmor available on PATH to audit the workflows locally with the same pedantic persona.

Terminal window
composer zizmor

Zizmor needs GitHub API access for its online audits. Use the offline flag to run without API access.

Terminal window
composer zizmor -- --offline

Report hosted CI execution and its PHP/OS matrix separately from these local commands. Keep generated reports in ignored internal/.

Composer scripts support forwarding additional arguments using --.

Run PHPUnit with code coverage report generation.

Terminal window
composer tests -- --coverage-html internal/coverage

Run PHPStan with a different memory limit.

Terminal window
composer static -- --memory-limit=512M

Back to documentation