bhushan's avatar

AssertSee multiple thing in phpunit test

/** @test */
    public function it_shows_top_ten_profiles_according_to_the_reputation_points_earned()
    {
        $users = create('App\User', [], 20);

        $sortUsers = $users->sortByDesc('reputation')->pluck('name')->take(10)->toArray();

        $this->get(route('profiles.index'))
        ->assertSee($sortUsers[0])
        ->assertSee($sortUsers[1])
        ->assertSee($sortUsers[2])
        ->assertSee($sortUsers[3])
        ->assertSee($sortUsers[4])
        ->assertSee($sortUsers[5])
        ->assertSee($sortUsers[6])
        ->assertSee($sortUsers[7])
        ->assertSee($sortUsers[8])
        ->assertSee($sortUsers[9]);
    }

it is just a work arround .. how can i refactor it more ..

0 likes
3 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

You could try

$this->get(route('profiles.index'))->assertSeeInOrder($sortUsers);
Sinnbeck's avatar

Ok so they are sorted differently on that route? Or do you only have the first 10 in the view?

Please or to participate in this conversation.