0

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');
    }
}
Amit Kumar PRO
  • 1,222
  • 2
  • 15
  • 27

1 Answers1

0

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

thmspl
  • 2,437
  • 3
  • 22
  • 48
  • Thanks for your help. So sory but I can't update PHPUnit ver. I try: "composer install" and log is: Installing dependencies (including require-dev) from lock file Package operations: 0 installs, 1 update, 0 removals - Updating phpunit/phpunit (4.8.36 => 7.0.0): Loading from cache. But when I excute test, log output is sample fist time: PHPUnit 4.8.36 by Sebastian Bergmann and contributors. – hungsonvnn Jan 16 '20 at 08:02
  • So post your `composer.json` file in your question. – thmspl Jan 16 '20 at 09:09
  • Delete the `composer.lock` file and execute `composer update --no-cache`. – thmspl Jan 16 '20 at 09:10
  • What? I can‘t understand you. – thmspl Jan 18 '20 at 09:57