I have two test classes in same test suite. One is extended laravel testcase another is extended phpunit testcase. When laravel testcase is executed before phpunit testcase and phpunit testcase is testing some laravel component, causing something not found or undefind error. But, executing test in counter way can pass the test.
class FirstTest extends Tests\TestCase;
{
public function testTrue()
{
$this->assertTrue(true);
}
}
class SecondTest extends \PHPUnit\Framework\TestCase;
{
public function testIsPaginator()
{
$paginator = new \Illuminate\Pagination\Paginator([], 1);
$this->assertInstanceOf(\Illuminate\Pagination\Paginator::class, $paginator);
}
}
Digging into the laravel source code, I found Paginator using static property storing callback function and register in PaginationServiceProvider. Obviously, when running test in laravel testcase first way will storing these static value and did not reset after teardown, phpunit testcase is force to access laravel app which isn't boot then throw error.
So, in addition to attention to the order of execution carefully, does there have anyway to fix up this kind of situation?