assertStatus giving errors

Posted 1 month ago by matalina

New to testing. But not exactly sure why I'm getting this error on the frist run, and then it passes on the other two (at least that's what I'm assuming)

I have three Test classes that are identical (just the basic stub)

<?php

namespace Tests\Feature\Versirent;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class DocumentationTest extends TestCase
{
    /**
     * A basic feature test example.
     *
     * @return void
     */
    public function testExample()
    {
        $response = $this->get('/');

        $response->assertStatus(200);
    }
}

The following error happens:

PHPUnit 6.5.7 by Sebastian Bergmann and contributors.

E..                                                                 3 / 3 (100%)

Time: 467 ms, Memory: 20.00MB

There was 1 error:

1) Tests\Feature\Versirent\DocumentationTest::testExample
ErrorException: Declaration of Illuminate\Foundation\Testing\Assert::assertArraySubset($subset, $array, bool $checkForObjectIdentity = false, string $message = ''): void should be compatible with PHPUnit\Framework\Assert::assertArraySubset($subset, $array, $strict = false, $message = '')

/mnt/d/projects/intranet_api/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Assert.php:42
/mnt/d/projects/intranet_api/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:131
/mnt/d/projects/intranet_api/tests/Feature/Versirent/DocumentationTest.php:20

ERRORS!
Tests: 3, Assertions: 2, Errors: 1.

if I comment out the $response->assertStatus(200); i get the expected no assertion test and then the second class/test fails for the above reason.

Everything is default phpunit settings that came when I ran the laravel composer scripts. And I've updated through composer as well.

Any ideas? Really at a loss for this and I'd really like to use the laravel helper methods as it's cleaner code.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.