Im having problem with phpunit, I don't know why Im having this kind of error when the file as okay, My theory is, when the test is running it will reinclude the name file instead of checking if the file was already been imported then it should not be reissued.
i tried doing require_once on CreateApplications But it causes error,
I cannot Test all test cases on one class because of the error
Cannot declare class <class omitted>, because the name is already in use in <file omitted>
<?php
namespace Tests;
use Illuminate\Contracts\Console\Kernel;
trait CreatesApplication
{
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require_once(__DIR__.'/../bootstrap/app.php');
$app->make(Kernel::class)->bootstrap();
return $app;
}
}
My question is, How to fix this error or how not to reimported the class? how to prevent it?
as of now Im using --filter option on PHPUnit in order to call specific method on the Test Class
Update
There is a custom package, which uses
includeand this causes the error, In my case, it is place on the custom package service provider, at boot methodso changing the
includetorequire_oncesolve the issue The error is not too clear on the report thats why Im having hard time questioning the theorising how it because an error :)