What Changed Removed per-file uses(TestCase::class ...) bindings in Unit tests to avoid Pest v4 “folder already uses the test case” discovery failure (kept RefreshDatabase where needed). Updated the backup scheduling job test to pass the newly required BulkOperationService when manually calling RunBackupScheduleJob::handle(). Where Unit (bulk cleanup across 56 files) RunBackupScheduleJobTest.php Verification ./vendor/bin/sail test → 443 passed, 5 skipped Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local> Reviewed-on: #45
64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
use App\Services\Graph\AssignmentFilterResolver;
|
|
use App\Services\Graph\GraphResponse;
|
|
use App\Services\Graph\MicrosoftGraphClient;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
uses(RefreshDatabase::class);
|
|
beforeEach(function () {
|
|
Cache::flush();
|
|
$this->graphClient = Mockery::mock(MicrosoftGraphClient::class);
|
|
$this->resolver = new AssignmentFilterResolver($this->graphClient);
|
|
});
|
|
|
|
test('resolves assignment filters by id', function () {
|
|
$filters = [
|
|
['id' => 'filter-1', 'displayName' => 'Targeted Devices'],
|
|
['id' => 'filter-2', 'displayName' => 'Excluded Devices'],
|
|
];
|
|
|
|
$response = new GraphResponse(
|
|
success: true,
|
|
data: ['value' => $filters]
|
|
);
|
|
|
|
$this->graphClient
|
|
->shouldReceive('request')
|
|
->once()
|
|
->with('GET', '/deviceManagement/assignmentFilters', [
|
|
'query' => [
|
|
'$select' => 'id,displayName',
|
|
],
|
|
])
|
|
->andReturn($response);
|
|
|
|
$result = $this->resolver->resolve(['filter-1']);
|
|
|
|
expect($result)->toHaveCount(1)
|
|
->and($result[0]['id'])->toBe('filter-1')
|
|
->and($result[0]['displayName'])->toBe('Targeted Devices');
|
|
});
|
|
|
|
test('uses cache for repeated lookups', function () {
|
|
$filters = [
|
|
['id' => 'filter-1', 'displayName' => 'Targeted Devices'],
|
|
];
|
|
|
|
$response = new GraphResponse(
|
|
success: true,
|
|
data: ['value' => $filters]
|
|
);
|
|
|
|
$this->graphClient
|
|
->shouldReceive('request')
|
|
->once()
|
|
->andReturn($response);
|
|
|
|
$result1 = $this->resolver->resolve(['filter-1']);
|
|
$result2 = $this->resolver->resolve(['filter-1']);
|
|
|
|
expect($result1)->toBe($result2);
|
|
});
|