Skip to content
Snippets Groups Projects
Verified Commit c94527bb authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

refactor(tests): rename command test files and update namespaces

- Renamed test files in the `tests/Feature/Console/Command` directory to `tests/Feature/Console/Commands`.
- Updated namespaces in the renamed test files to reflect the new directory structure.
- Added a new test file `ProcessIpAddressesJobTest.php` to test the `ProcessIpAddressesJob` functionality.
parent 8aaf9c7d
No related branches found
No related tags found
1 merge request!60feat: add IpAdressMetadata model and factory with migration
Pipeline #1055 passed
<?php
namespace Tests\Feature\Console\Command;
namespace Tests\Feature\Console\Commands;
use App\Console\Commands\FlushUnusedUploadedPicturesCommand;
use App\Models\UploadedPicture;
......@@ -9,7 +9,8 @@
use PHPUnit\Framework\Attributes\CoversClass;
use Tests\TestCase;
#[CoversClass(FlushUnusedUploadedPicturesCommand::class)] class FlushUnusedUploadedPicturesCommandTest extends TestCase
#[CoversClass(FlushUnusedUploadedPicturesCommand::class)]
class FlushUnusedUploadedPicturesCommandTest extends TestCase
{
use RefreshDatabase;
......
<?php
namespace Tests\Feature\Console\Command;
namespace Tests\Feature\Console\Commands;
use App\Console\Commands\OptimizeUploadedPicturesCommand;
use App\Models\UploadedPicture;
......@@ -12,7 +12,8 @@
/**
* Tests de la commande d'optimisation des images uploadées
*/
#[CoversClass(OptimizeUploadedPicturesCommand::class)] class OptimizeUploadedPicturesCommandTest extends TestCase
#[CoversClass(OptimizeUploadedPicturesCommand::class)]
class OptimizeUploadedPicturesCommandTest extends TestCase
{
use RefreshDatabase;
......
<?php
namespace Tests\Feature\Console\Command;
namespace Tests\Feature\Console\Commands;
use App\Console\Commands\ProcessIpAdressesCommand;
use App\Jobs\ProcessIpAddressesJob;
......
<?php
namespace Tests\Feature\Console\Command;
namespace Tests\Feature\Console\Commands;
use App\Console\Commands\ProcessUserAgentsCommand;
use App\Jobs\ProcessUserAgentJob;
......
<?php
namespace Tests\Feature\Console\Command;
namespace Tests\Feature\Console\Commands;
use App\Console\Commands\UpdateImageDimensionsCommand;
use App\Models\UploadedPicture;
......
<?php
namespace Tests\Feature\Jobs;
use App\Jobs\ProcessIpAddressesJob;
use App\Services\IpAddressMetadataResolverService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
use PHPUnit\Framework\Attributes\CoversClass;
use SlProjects\LaravelRequestLogger\app\Models\IpAddress;
use Tests\TestCase;
#[CoversClass(ProcessIpAddressesJob::class)]
class ProcessIpAddressesJobTest extends TestCase
{
use RefreshDatabase;
public function test_processes_ip_addresses_successfully()
{
$ip1 = IpAddress::factory()->create(['ip' => '208.80.152.201']);
$ip2 = IpAddress::factory()->create(['ip' => '24.48.0.1']);
Http::fake([
'*' => Http::response([
[
'status' => 'success',
'countryCode' => 'US',
'lat' => 37.7892,
'lon' => -122.402,
'query' => '208.80.152.201',
],
[
'status' => 'success',
'countryCode' => 'CA',
'lat' => 45.6085,
'lon' => -73.5493,
'query' => '24.48.0.1',
],
]),
]);
$job = new ProcessIpAddressesJob(collect([$ip1, $ip2]));
$job->handle(app(IpAddressMetadataResolverService::class));
$this->assertDatabaseHas('ip_address_metadata', [
'ip_address_id' => $ip1->id,
'country_code' => 'US',
'lat' => 37.7892,
'lon' => -122.402,
]);
$this->assertDatabaseHas('ip_address_metadata', [
'ip_address_id' => $ip2->id,
'country_code' => 'CA',
'lat' => 45.6085,
'lon' => -73.5493,
]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment