Testing
این محتوا هنوز به زبان شما در دسترس نیست.
This package provides a consistent set of Composer scripts for local validation.
Tool references:
- Actionlint for GitHub Actions workflow linting.
- Codespell for spelling checks.
- Composer Require Checker for dependency definition checks.
- Easy Coding Standard (ECS) for coding standards.
- EditorConfig Checker for EditorConfig compliance.
- Gitleaks for secret scanning.
- Infection for mutation testing.
- Markdownlint-cli2 for Markdown linting.
- PHPStan for static analysis.
- PHPUnit for unit tests.
- Prettier for Markdown and YAML formatting checks.
- Rector for automated refactoring.
- Yamllint for YAML linting.
- Zizmor for GitHub Actions security audits.
Automated refactoring (Rector)
Section titled “Automated refactoring (Rector)”Run Rector to apply automated code refactoring. This command modifies files.
composer rectorPreview the refactoring without modifying files.
composer rector-checkCoding standards (ECS)
Section titled “Coding standards (ECS)”Check coding standards without modifying files.
composer ecs-checkApply coding standard fixes. Review the changes before keeping them.
composer ecsDependency definition check
Section titled “Dependency definition check”Verify that runtime dependencies are correctly declared in composer.json.
composer check-dependenciesMutation testing (Infection)
Section titled “Mutation testing (Infection)”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.
bash tests/integration/run-openldap.sh composer mutationRun 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.
bash tests/integration/run-openldap.sh composer mutation-staticRepository quality checks
Section titled “Repository quality checks”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.
composer actionlintStatic analysis (PHPStan)
Section titled “Static analysis (PHPStan)”Run static analysis.
composer staticUnit tests (PHPUnit)
Section titled “Unit tests (PHPUnit)”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.
composer update --with yiisoft/yii2:2.0.55composer testsUse 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:
composer tests -- --coverage-clover runtime/coverage.xmlOpenLDAP directories
Section titled “OpenLDAP directories”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:
bash tests/integration/run-openldap.sh composer testsWithout 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.
Deployment acceptance
Section titled “Deployment acceptance”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.
Workflow security checks
Section titled “Workflow security checks”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.
composer zizmorZizmor needs GitHub API access for its online audits. Use the offline flag to run without API access.
composer zizmor -- --offlineReport hosted CI execution and its PHP/OS matrix separately from these local commands. Keep generated reports in ignored
internal/.
Passing extra arguments
Section titled “Passing extra arguments”Composer scripts support forwarding additional arguments using --.
Run PHPUnit with code coverage report generation.
composer tests -- --coverage-html internal/coverageRun PHPStan with a different memory limit.
composer static -- --memory-limit=512M