50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
use App\Actions\Tabulation\TotalEntryScores;
|
|
use App\Models\Entry;
|
|
use App\Models\ScoreSheet;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
$this->mock = Mockery::mock(TotalEntryScores::class);
|
|
app()->instance(TotalEntryScores::class, $this->mock);
|
|
// Use Laravel's built-in facade mock
|
|
Cache::spy();
|
|
});
|
|
|
|
afterEach(function () {
|
|
Mockery::close();
|
|
});
|
|
|
|
it('totals an entries scores when a score sheet is created', function () {
|
|
$this->mock->shouldReceive('__invoke')
|
|
->once()
|
|
->with(\Mockery::type(Entry::class), true)
|
|
->andReturn(null);
|
|
Cache::shouldReceive('forget')->twice();
|
|
|
|
$sheet = ScoreSheet::factory()->create();
|
|
});
|
|
|
|
it('totals an entries scores when a score sheet is update', function () {
|
|
$this->mock->shouldReceive('__invoke')
|
|
->twice()
|
|
->with(\Mockery::type(Entry::class), true)
|
|
->andReturn(null);
|
|
Cache::shouldReceive('forget')->times(4);
|
|
$sheet = ScoreSheet::factory()->create();
|
|
$sheet->update(['seating_total' => 9]);
|
|
});
|
|
|
|
it('totals an entries scores when a score sheet is deleted', function () {
|
|
$this->mock->shouldReceive('__invoke')
|
|
->twice()
|
|
->with(\Mockery::type(Entry::class), true)
|
|
->andReturn(null);
|
|
Cache::shouldReceive('forget')->times(4);
|
|
$sheet = ScoreSheet::factory()->create();
|
|
$sheet->delete();
|
|
});
|