I excute PhPUnit, The coverage report can not generate, Laravel ver: 5.2 Php ver: 7.3.11. Log output is:
PHPUnit 4.8.36 by Sebastian Bergmann and contributors. .
Time: 1.51 seconds, Memory: 22.00MB
OK (1 test, 1 assertion)
Generating code coverage report in HTML format ...count(): Parameter must be an array or an object that implements Countable
I don't know what wrong here? Here is my test source:
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Http\Response;
class TravelControllerTest extends TestCase
{
/**
* A basic functional test example.
*
* @return void
*/
public function testBasicExample()
{
$response = $this->json('GET', '/v1/abc', ['id' => 'Sally']);
$response->assertSessionHas('temporary_id', $value = 'Sally');
}
}
Upgrade the PHPUnit and PhpCodeCoverage packages would be the solution. You're packages are very outdated! It's a bug in older versions.
Here are some discussions about this topic:
https://github.com/Codeception/Codeception/issues/4703
https://github.com/sebastianbergmann/php-code-coverage/issues/551
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.