Getting rid of call to collect helper method.

Posted 4 months ago by xtremer360

Any ideas on what I can do so that I don't have to wrap values for $winners, $losers, and the assertion calls in a collect helper method?

/** @test */
    public function winners_and_losers_can_be_separated_based_off_decision_of_match()
        $match = $this->createStandardMatch();
        $winners = collect($match->groupedWrestlersBySide()->first()->modelKeys());
        $losers = collect($match->wrestlers->modelKeys())->diff($winners)->values();

        $response = $this->actingAs($this->authorizedUser)
                        ->from(route('results.edit', ['event' => $match->event->id]))
                        ->patch(route('results.update', ['event' => $match->event->id]), $this->validParams([
                            'matches' => [
                                    'winners' => $winners,

        tap($match->fresh(), function ($match) use ($response, $winners, $losers) {
            $this->assertEquals(collect($match->winners->modelKeys()), $winners);
            $this->assertEquals(collect($match->losers->modelKeys()), $losers);

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.