PHPackages                             idrinth/phpunit-test-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. idrinth/phpunit-test-generator

ActiveLibrary[Testing &amp; Quality](/categories/testing)

idrinth/phpunit-test-generator
==============================

Generates tests for use with PHPunit based on an existing composer.json

511[8 issues](https://github.com/Idrinth/phpunit-test-generator/issues)[2 PRs](https://github.com/Idrinth/phpunit-test-generator/pulls)PHP

Since Apr 8Pushed 1y ago2 watchersCompare

[ Source](https://github.com/Idrinth/phpunit-test-generator)[ Packagist](https://packagist.org/packages/idrinth/phpunit-test-generator)[ RSS](/packages/idrinth-phpunit-test-generator/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (4)Used By (0)

Test-Generator for PHPUnit
==========================

[](#test-generator-for-phpunit)

[![Codacy Badge](https://camo.githubusercontent.com/5ed5d7d64885452fc4b9a98a5aac16e090cf788b81d968125c5a5cc2ee663dff/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6361626433666337306265383437643462326632386339343732353938633631)](https://www.codacy.com/app/Idrinth/phpunit-test-generator?utm_source=github.com&utm_medium=referral&utm_content=Idrinth/phpunit-test-generator&utm_campaign=Badge_Grade)[![Codacy Badge](https://camo.githubusercontent.com/94d78bfabc1874ef7b00c289a9d7ccaede7ad8629ee95607a194f53b8f359f68/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f436f7665726167652f6361626433666337306265383437643462326632386339343732353938633631)](https://www.codacy.com/app/Idrinth/phpunit-test-generator?utm_source=github.com&utm_medium=referral&utm_content=Idrinth/phpunit-test-generator&utm_campaign=Badge_Coverage)[![Build Status](https://camo.githubusercontent.com/232b97eb606c4b1b986a4bab2a3371ed3b68644ba8995fe9a5ec0378d050686a/68747470733a2f2f7472617669732d63692e6f72672f496472696e74682f706870756e69742d746573742d67656e657261746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Idrinth/phpunit-test-generator)[![CodeFactor](https://camo.githubusercontent.com/1534c2868b94f9c0026be8be90a2a119d1836ac0aadd5777e2330a7cc629dcd2/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f696472696e74682f706870756e69742d746573742d67656e657261746f722f6261646765)](https://www.codefactor.io/repository/github/idrinth/phpunit-test-generator)[![BCH compliance](https://camo.githubusercontent.com/476fd2c4cd5fc0988d75300b5234db20c72eee5ce4818a1ad51e2df8e0076b35/68747470733a2f2f626574746572636f64656875622e636f6d2f656467652f62616467652f496472696e74682f706870756e69742d746573742d67656e657261746f723f6272616e63683d6d6173746572)](https://bettercodehub.com/)

Command &amp; Options
---------------------

[](#command--options)

```
php bin/generate-tests --dir=/path/to/alternative/dir --mode=replace

```

### dir

[](#dir)

Dir is optional and will default to the current working directory. Pick the directory that the composer.json is in.

### replace (deprecated, see mode)

[](#replace-deprecated-see-mode)

If set old testfiles will be overwritten, if not set they will be renamed instead. Usually you shouldn't need this.

### mode

[](#mode)

One of replace, skip or move. Defines how to handle file conflicts and defaults to moving the old file.

### output

[](#output)

If set will be prepended to the relative paths of dev-autoload paths.

How does it work?
-----------------

[](#how-does-it-work)

The composer.json at the working directory(or the supplied dir) will pe parsed for namespaces(psr 0 and 4), the folders targeted by none-dev namespaces will be searched for classes and test classes will be generated in the appropriate development-autoloading-folder. To determine the testing class to be used, the phpunit dev-dependency is parsed, so you need to supply a constraint to make the generation work.

Generated Test - Example
------------------------

[](#generated-test---example)

This is a generated testfile for the actual Controller of this library. The intention is to generate PSR2-compatible code, obviously that might not yet be the case everywhere. If you find one where it fails, feel free to file a bug.

```
