refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
This commit is contained in:
57
tests/Unit/Jobs/GetWeatherInformationTest.php
Normal file
57
tests/Unit/Jobs/GetWeatherInformationTest.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Jobs;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Mockery\MockInterface;
|
||||
use App\Models\Account\Place;
|
||||
use Illuminate\Bus\PendingBatch;
|
||||
use App\Jobs\GetWeatherInformation;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Illuminate\Bus\DatabaseBatchRepository;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use App\Services\Instance\Weather\GetWeatherInformation as GetWeatherInformationService;
|
||||
|
||||
class GetWeatherInformationTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/** @test */
|
||||
public function it_run_job_weather_information()
|
||||
{
|
||||
$fake = Bus::fake();
|
||||
|
||||
$place = factory(Place::class)->create([
|
||||
'latitude' => '34.112456',
|
||||
'longitude' => '-118.4270732',
|
||||
]);
|
||||
|
||||
$this->mock(GetWeatherInformationService::class, function (MockInterface $mock) use ($place) {
|
||||
$mock->shouldReceive('execute')
|
||||
->once()
|
||||
->withArgs(function ($data) use ($place) {
|
||||
$this->assertEquals([
|
||||
'account_id' => $place->account_id,
|
||||
'place_id' => $place->id,
|
||||
], $data);
|
||||
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
$pendingBatch = $fake->batch([
|
||||
$job = new GetWeatherInformation($place),
|
||||
]);
|
||||
$batch = $pendingBatch->dispatch();
|
||||
|
||||
$fake->assertBatched(function (PendingBatch $pendingBatch) {
|
||||
$this->assertCount(1, $pendingBatch->jobs);
|
||||
$this->assertInstanceOf(GetWeatherInformation::class, $pendingBatch->jobs->first());
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
$batch = app(DatabaseBatchRepository::class)->store($pendingBatch);
|
||||
$job->withBatchId($batch->id)->handle();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user