cyberpearuk / phpunit-skelgen
Tool that can generate skeleton test classes from production code classes and vice versa
Requires
- php: >=7.1
- phpunit/php-text-template: ^1.2
- sebastian/version: ^2.0
- squizlabs/php_codesniffer: *
- symfony/console: ^4.3
Requires (Dev)
- mikey179/vfsstream: ^1.6
- overtrue/phplint: ^1.1
- phpunit/phpunit: ^7 || ^8.2
This package is auto-updated.
Last update: 2024-12-21 21:14:33 UTC
README
phpunit-skelgen
is a tool that can generate skeleton test classes from production
code classes and vice versa.
This is a fork of the original sebastianbergmann/phpunit-skeleton-generator
which was abondoned at ~v4 of PHPUnit, to provide support for PHPUnit 8 and PHP7.1.
This fork is maintained by www.cyberpear.co.uk.
Installation
Composer
Simply add a development dependency on cyberpearuk/phpunit-skelgen
to your project
using Composer:
composer require --dev "cyberpearuk/phpunit-skelgen=*"
For a system-wide installation via Composer, you can run:
composer global require "cyberpearuk/phpunit-skelgen=*"
Make sure you have ~/.composer/vendor/bin/
in your path.
Usage
CLI
./vendor/bin/phpunit-skelgen --ansi generate-test <namespace> <src-file> <test-class-name> <tst-file>
./vendor/bin/phpunit-skelgen --ansi generate-test "My\Namespace" "path/to/src/class" "My\Namespace\ClassNameTest" "/path/to/tests/class"
Assertion Annotations
phpunit-skelgen
will generate a test case for each assertion defined in the
methods doc comment. For example the below will generate 4 test cases:
/** * @assert (0, 0) == 0 * @assert (0, 1) == 1 * @assert (1, 0) == 1 * @assert (1, 1) == 2 */ public function add($a, $b) { return $a + $b; }
Maintainer
This repository is maintained by Black Pear Digital.