Archived
1
0
Fork 0

app/Models/Card.php: in getBySettings() implement support to include X number of jackpot cards in the result.

This commit is contained in:
Henrik Hautakoski 2023-02-19 17:11:46 +01:00
parent 0a80dbeb5e
commit 020645dbca
2 changed files with 37 additions and 6 deletions

View file

@ -155,4 +155,22 @@ class CardTest extends TestCase
$this->assertContains($card->role, $expected);
}
}
public function test_get_with_jackpot_cards()
{
Card::factory()->count(10)->create(['jackpot' => 1]);
$cards = Card::getBySettings(new GameSettings(), 4, 2);
$this->assertSame(4, count($cards));
$jackpot_count = 0;
foreach ($cards as $card) {
if ($card->jackpot != 0) {
$jackpot_count++;
}
}
$this->assertEquals(2, $jackpot_count);
}
}