auditionadmin/tests/Feature/app/Observers/EntryFlagObserverMocksTest.php

34 lines
786 B
PHP

<?php
use App\Actions\Tabulation\DoublerSync;
use App\Models\Doubler;
use App\Models\Entry;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
beforeEach(function () {
$this->entry = Entry::factory()->create();
app()->forgetInstance(Doubler::class);
});
afterEach(function () {
Mockery::close();
\Mockery::getConfiguration()->allowMockingNonExistentMethods(true);
Cache::flush();
});
it('syncs doublers when a flag is added', function () {
$mock = Mockery::mock(DoublerSync::class);
$mock->shouldReceive('__invoke')
->once()
->andReturn(null);
// Bind the mock to the container
app()->instance(DoublerSync::class, $mock);
$this->entry->addFlag('declined');
});
// TODO Figure out how to test