Hello
try to add in your composer :
"scripts": {
.....
"test": "./vendor/bin/phpunit"
},
Then run
composer test
to execute your test
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I've to rectify what I said in this post.
I'm usign vendor/bin/phpunit, but I've also tried with vendor/phpunit/phpunit/phpunit. Same result.
My Composer json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.1.3",
"barryvdh/laravel-ide-helper": "^2.4",
"fideloper/proxy": "^4.0",
"laravel/browser-kit-testing": "4.0.x-dev",
"laravel/dusk": "^3.0",
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0",
"nexmo/client": "1.3.2",
"nexmo/laravel": "1.1.1",
"phpunit/phpunit": "7.1.5"
},
"require-dev": {
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\": "app/",
"Todo\": "app/Repositories/Todo/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\Foundation\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
My phpunit.xml:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit verbose="true"
bootstrap="vendor/autoload.php"
colors="true"
backupGlobals="false"
backupStaticAttributes="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="MAIL_DRIVER" value="array"/>
<env name="DB_CONNECTION" value="testing"/>
</php>
</phpunit>
assertTrue(true) nor the HTTP request test shown in the documentation (before I've said that this last one was working, but it is not). It does not execute them.
In this video guide on PHPUnit (not specifically for laravel), it does the test class by extending "PHPUnit_Framework_TestCase". I've tried and at least it considers the test functions and the assertTrue of course passes, but I cannot use this class because I want to use the TestCase with all the functionalities included for testing in Laravel.
Thanks for the help. Regards.
Hello
try to add in your composer :
"scripts": {
.....
"test": "./vendor/bin/phpunit"
},
Then run
composer test
to execute your test
Please or to participate in this conversation.