Files
postshop-backend/tests/Feature/Api/V1/LocationTest.php
Mekan1206 c46eccb24f Refactor code for improved readability and consistency
- Removed unnecessary blank lines in various files to enhance code clarity.
- Updated comments for consistency and clarity across multiple classes and methods.
- Adjusted spacing in test files for better formatting and readability.
2026-02-08 02:24:43 +05:00

82 lines
2.1 KiB
PHP

<?php
use App\Models\Post\PostBranch;
use App\Models\System\Settings\Location\Province;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Config;
uses(RefreshDatabase::class);
beforeEach(function () {
Config::set('ecommerce.api.token', 'test-token');
});
use App\Models\System\Settings\Location\Region;
test('can list provinces', function () {
// Arrange
Province::create(['name' => ['en' => 'Province 1'], 'region' => Region::AG]);
Province::create(['name' => ['en' => 'Province 2'], 'region' => Region::MR]);
// Act
$response = $this->withHeaders([
'Api-Token' => 'test-token',
'Accept' => 'application/json',
])->getJson('/api/v1/provinces');
// Assert
$response->assertOk()
->assertJsonStructure([
'data' => [
'*' => [
'id',
'name',
'region',
],
],
]);
$this->assertCount(2, $response->json('data'));
});
test('can list post branches', function () {
// Arrange
$province = Province::create(['name' => ['en' => 'Province 1'], 'region' => Region::AG]);
PostBranch::create([
'province_id' => $province->id,
'name' => ['en' => 'Branch 1'],
'address' => ['en' => 'Address 1'],
'description' => ['en' => 'Desc 1'],
]);
PostBranch::create([
'province_id' => $province->id,
'name' => ['en' => 'Branch 2'],
'address' => ['en' => 'Address 2'],
'description' => ['en' => 'Desc 2'],
]);
// Act
$response = $this->withHeaders([
'Api-Token' => 'test-token',
'Accept' => 'application/json',
])->getJson('/api/v1/post-branches');
// Assert
$response->assertOk()
->assertJsonStructure([
'data' => [
'*' => [
'id',
'province_id',
'name',
'address',
'description',
],
],
]);
$this->assertCount(2, $response->json('data'));
});