Hi,
I have two files:
ApiTest.pxp:
<?php
namespace Tests\Feature;
use Illuminate\Support\Facades\Route;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
class ApiTest extends TestCase
{
public static function getData()
{
Route::getRoutes();
}
#[DataProvider("getData")]
public function testExample() {}
}
TestCase.php:
<?php
namespace Tests;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
public function createApplication()
{
$app = require __DIR__ . '/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
}
Running php artisan test returns this error:
FAILED Tests\Feature\ApiTest > example
The data provider specified for Tests\Feature\ApiTest::testExample is invalid
A facade root has not been set.
I would like to automate testing by getting every route my API consist of.
However, this error confuses me. Searching through the internet didn't help.
What is the problem and how can I solve this issue?
Does somebody have more experience with testing and may help me?
Thank you in advance!
~ Maschga