feat: Add City entity methods and migration for title field
- Created a new JSON file for the City entity's AST representation, detailing its methods and properties. - Added a migration to alter the cities table by adding a nullable title column.
This commit is contained in:
@@ -78,6 +78,39 @@ class CategoryImportTest extends ApiTestCase
|
||||
$this->assertContains('parent_id', $fields);
|
||||
}
|
||||
|
||||
public function testCityTitleAndSocialMediaRoundTripThroughImportExport(): void
|
||||
{
|
||||
$admin = $this->createUser(['ROLE_ADMIN']);
|
||||
|
||||
$this->authJson('POST', '/api/v1/admin/categories/cities/import', $admin, [
|
||||
[
|
||||
'id' => 95001, 'name' => 'شهر تست', 'status' => 1, 'weight' => 0,
|
||||
'site_name' => 'تست نوبت',
|
||||
'title' => 'نوبتدهی آنلاین پزشکان شهر تست | تست نوبت',
|
||||
'slogan' => 'شعار تست',
|
||||
'keywords' => 'کلمه یک, کلمه دو',
|
||||
'province_id' => null,
|
||||
'social_media' => ['instagram' => 'test_nobat'],
|
||||
],
|
||||
]);
|
||||
$this->assertSame(200, $this->responseCode());
|
||||
$this->assertSame(
|
||||
'نوبتدهی آنلاین پزشکان شهر تست | تست نوبت',
|
||||
$this->db()->fetchOne('SELECT title FROM cities WHERE id = 95001'),
|
||||
);
|
||||
|
||||
// export must round-trip lossless in the shape nobat724_front/data/city.json uses
|
||||
$body = $this->authJson('GET', '/api/v1/admin/categories/cities/export', $admin);
|
||||
$row = null;
|
||||
foreach ($body['data'] as $r) {
|
||||
if (($r['id'] ?? null) === 95001) { $row = $r; break; }
|
||||
}
|
||||
$this->assertNotNull($row);
|
||||
$this->assertSame('نوبتدهی آنلاین پزشکان شهر تست | تست نوبت', $row['title']);
|
||||
$this->assertSame(['instagram' => 'test_nobat'], $row['social_media']);
|
||||
$this->assertArrayHasKey('province_name', $row);
|
||||
}
|
||||
|
||||
public function testNonAdminIsForbidden(): void
|
||||
{
|
||||
$user = $this->createUser(['ROLE_USER']);
|
||||
|
||||
Reference in New Issue
Block a user