kristijorgji/php-test-generator

PHP test skeletons generator

v1.0.0 2018-06-19 10:23 UTC

This package is not auto-updated.

Last update: 2024-05-12 02:46:19 UTC


README

A framework for generating test boilerplate from the specified suites.

Table of Contents

Installation

composer require kristijorgji/php-test-generator

Run the following command to initialize phpTestGenerator

vendor/bin/phpTestGenerator init

This command will create in your project root folder the config file phpTestGenerator.cfg.php You need to edit that to your desired settings.

Config

The config and it's keys try to be as much self explanatory as possible. Example config:

<?php

return [
    'suites' => [
        'code' => [
            'sourcesPath' => 'app',
            'excludePatterns' => [
                'Console',
                'Constants', 
                '#.*Interface\.php$#',
                '#.*Exception\.php$#',
            ],
            'outputDirectory' => 'tests/unit/app',
            'namespace' => 'UnitTests',
            'extends' => '\Tests\Helpers\TestCase'
        ],
        'database' => [
            'sourcesPath' => 'app/Repositories',
            'excludePatterns' => [
                'Contracts'
            ],
            'outputDirectory' => 'tests/unit/app/Repositories',
            'namespace' => 'UnitTests\App\Repositories',
            'extends' => 'Tests\Helpers\FixtureTestCase'
        ],
    ]
];

The exclude patterns can be directory names (relative to suite source paths), or regular expressions. In the former case, the pattern should be defined within #, like in the example config.

License

php-test-generator is released under the MIT Licence. See the bundled LICENSE file for details.