PHPUNIT testing failing

Published 3 months ago by nhayder

phpUnit testing

    /** @test */
    public function a_user_can_browse_single_thread()
    {
        $thread = factory('App\Thread')->create();

    $response = $this->get('/threads/', $thread->id);
 
        $response->assertSee($thread->title);
        $response->assertSee($thread->body);

    }

error

MacBook-$ ./vendor/phpunit/phpunit/phpunit
PHPUnit 7.1.5 by Sebastian Bergmann and contributors.

.E                                                                  2 / 2 (100%)

Time: 190 ms, Memory: 18.00MB

There was 1 error:

1) Tests\Feature\ThreadsTest::a_user_can_browse_single_thread
TypeError: Argument 2 passed to Illuminate\Foundation\Testing\TestCase::get() must be of the type array, integer given, called in /Applications/MAMP/htdocs/tests/Feature/ThreadsTest.php on line 37

/Applications/MAMP/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:164
/Applications/MAMP/htdocs/tests/Feature/ThreadsTest.php:37

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

Best Answer (As Selected By nhayder)
tykus
$this->get("/threads/{$thread->id}")

You used a comma instead of a period whenever you were trying to concatenate the variable to the string. I tend to prefer string interpolation rather than concatenation.

nhayder

@tykus Would you like to have a look at this new error

tykus
tykus
3 months ago (659,440 XP)
$this->get("/threads/{$thread->id}")

You used a comma instead of a period whenever you were trying to concatenate the variable to the string. I tend to prefer string interpolation rather than concatenation.

nhayder

@tykus Thanx man

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