VOOZH about

URL: https://deepwiki.com/netgen/query-translator/7-testing-and-development

⇱ Testing and Development | netgen/query-translator | DeepWiki


Loading...
Menu

Testing and Development

Purpose and Scope

This document provides an overview of the Query Translator library's development infrastructure, including package management, testing framework, code quality tools, and the overall testing philosophy. It covers the development environment setup, available tooling, and how to work with the codebase during development.

For detailed information about the test suite structure and organization, see Test Suite. For CI/CD configuration details, see CI/CD Configuration.


Development Environment Setup

The Query Translator library uses Composer for dependency management and autoloading, supporting PHP versions 7.0 through 8.5 to ensure broad compatibility across different environments.

Package Management

The project configuration is defined in composer.json:

ConfigurationDetails
PHP Requirement^7.0||^8.0 (PHP 7.0+ and 8.0+)
LicenseMIT
TypeLibrary
AutoloadingPSR-4: QueryTranslator\lib/
Test AutoloadingPSR-4: QueryTranslator\Tests\tests/

Development Dependencies

The following development tools are required:

PackageVersionPurpose
phpunit/phpunit<10Test framework
symfony/phpunit-bridge*PHPUnit compatibility layer
friendsofphp/php-cs-fixer^2.11Code style enforcement

Sources: composer.json25-32 composer.json33-42

Development Toolchain Architecture


Sources: composer.json1-53 .gitignore1-5


Testing Infrastructure

The library uses PHPUnit as its primary testing framework, with comprehensive test coverage across all major components.

PHPUnit Configuration

Tests are executed using the PHPUnit test runner configured in phpunit.xml. The test suite is structured to mirror the library's architecture, with separate test classes for each component.

Running Tests Locally

Execute the test suite using the Composer script:


This command internally calls ./vendor/bin/phpunit as defined in the scripts section of composer.json.

Alternatively, run PHPUnit directly:


Code Coverage

Code coverage analysis is enabled during CI runs on PHP 8.2 using Xdebug:


Coverage reports are uploaded to Codecov for tracking coverage trends over time. The coverage data helps identify untested code paths and ensures comprehensive test coverage.

Sources: composer.json43-47 .github/workflows/tests.yml67-73

Testing Philosophy

The Query Translator library follows these testing principles:

  1. Comprehensive Coverage: All core components (TokenExtractor, Parser, Generators) have dedicated test suites
  2. Data-Driven Testing: Tests use PHPUnit data providers to validate behavior across multiple input scenarios
  3. Cross-Version Compatibility: Tests run across 11 PHP versions (7.0-8.5) to ensure broad compatibility
  4. Fixture-Based Testing: Test data is organized using fixtures and test data providers
  5. Inherited Test Overrides: Subclass implementations can override specific test cases when behavior differs

Sources: .github/workflows/tests.yml16-39


Code Quality Tools

PHP-CS-Fixer

The library uses PHP-CS-Fixer to enforce consistent code style based on Symfony coding standards. Configuration is defined in .php_cs.dist.

Code Style Rules

The code style configuration uses the following ruleset:

Rule CategoryConfiguration
Base Rules@Symfony, @Symfony:risky
Array SyntaxShort array syntax ([])
ConcatenationOne space around concatenation operator
Import OrderingAlphabetically ordered imports
Class ElementsOrdered class elements (properties, methods)
AlignmentNo phpdoc alignment
Useless CodeRemove useless else/return statements

Running Code Style Checks

Fix code style issues automatically:


The fixer scans all PHP files in the project directory and applies the configured rules.

Sources: .php_cs.dist1-33 composer.json28-32

PHP-CS-Fixer Configuration Details


Sources: .php_cs.dist3-32


Development Workflow

Initial Setup

  1. Clone the repository
  2. Install dependencies:
    
    
  3. Verify installation:
    
    

Development Cycle

The typical development workflow involves:

  1. Code Changes: Modify source code in lib/ directory
  2. Write Tests: Add or update tests in tests/ directory
  3. Run Tests: Execute composer test to verify changes
  4. Check Style: Run php-cs-fixer fix to ensure code style compliance
  5. Commit: Commit changes with descriptive messages

Git Ignored Files

The following files are excluded from version control:

File/DirectoryReason
composer.lockEnvironment-specific dependency resolution
.php_cs.cachePHP-CS-Fixer cache file
.phpunit.result.cachePHPUnit cache file
vendor/Third-party dependencies

These files are generated during development and should not be committed to the repository.

Sources: .gitignore1-5


Continuous Integration

The library employs GitHub Actions for continuous integration, running automated tests on every push and pull request. The CI pipeline ensures:

  • Multi-Version Compatibility: Tests run on PHP 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, and 8.5
  • Dependency Validation: composer.json is validated for correctness
  • Automated Testing: Full test suite execution on all supported PHP versions
  • Coverage Reporting: Code coverage metrics uploaded to Codecov (PHP 8.2 only)
  • Build Status: Immediate feedback on test failures

For detailed information about the CI/CD configuration, matrix strategy, and coverage reporting, see CI/CD Configuration.

Sources: .github/workflows/tests.yml1-84


Development Infrastructure Overview


Sources: composer.json1-53 .github/workflows/tests.yml1-84 .php_cs.dist1-33


Testing Namespace Structure

The test suite follows PSR-4 autoloading standards, with test classes organized under the QueryTranslator\Tests\ namespace mirroring the main library structure.


Sources: composer.json33-42


Summary

The Query Translator library maintains high code quality through a comprehensive development infrastructure:

  • Composer manages dependencies and provides PSR-4 autoloading for both production and test code
  • PHPUnit provides the testing framework with coverage analysis
  • PHP-CS-Fixer enforces consistent code style based on Symfony standards
  • GitHub Actions runs automated tests across 11 PHP versions (7.0-8.5)
  • Codecov tracks code coverage metrics over time

This infrastructure ensures the library can be safely integrated into diverse projects while maintaining backward compatibility and code quality standards.