Artisan72
Artisan72

Reputation: 3600

Running PHPUnit on composer projects

I am working on a lib for composer/packagist.

While working on the PHP classes,I am parallely writing the tests for the method, to check if everything works well.

file tree:

├── composer.json
├── composer.lock
├── README.md
├── src
│   └── Resizer.php
├── tests
│   └── ResizerTests.php
└── vendor
    └── PHPUnit etc...

composer.json:

{
    "name": "eschmid1972/image-resizer",
    "description": "Library for resizing images with custom options",
    "keywords": [
        "php",
        "image",
        "imagemagick",
        "resize"
    ],
    "license": "BSD-3"
    ],
    "require": {},
    "require-dev": {
        "phpunit/phpunit": "~4.0"
    }
}

What do I need to do, so I can run the tests with the command phpunit in the project root?

Upvotes: 1

Views: 38

Answers (2)

Artisan72
Artisan72

Reputation: 3600

I've found the solution: you need to create a phpunit.xml file in the project root or the directory where you want to execute phpunit.

The documentation for the configuration is hosted at:

https://phpunit.de/manual/current/en/appendixes.configuration.html

Upvotes: 1

Tomas Votruba
Tomas Votruba

Reputation: 24280

You'd have to download it as phar distribution. Not via composer, where only vendor/bin/phpunit is available.

See PHPUnit installation.

Upvotes: 0

Related Questions