Getting rid of call to collect helper method.

Posted 6 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.

Reply to

Use Markdown with GitHub-flavored code blocks.