Skip to content

Fix: change request data for applying new method#77

Merged
zigzagdev merged 2 commits intofeature/central-asiafrom
feature/central-asia-application
Aug 25, 2025
Merged

Fix: change request data for applying new method#77
zigzagdev merged 2 commits intofeature/central-asiafrom
feature/central-asia-application

Conversation

@zigzagdev
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown
Owner Author

@zigzagdev zigzagdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@zigzagdev zigzagdev requested a review from Copilot August 25, 2025 04:47
@zigzagdev zigzagdev self-assigned this Aug 25, 2025
@zigzagdev zigzagdev linked an issue Aug 25, 2025 that may be closed by this pull request
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates test data across multiple World Heritage site test files to change from Japanese heritage sites to European/Asian transnational heritage sites, likely to support testing of a new method that handles multi-country heritage sites with state party relationships.

Key changes:

  • Updated test fixture data from Japanese heritage sites to transnational sites (Ancient Beech Forests and Silk Roads)
  • Added support for state_parties and state_parties_meta fields in DTOs and factories
  • Enhanced test setup with Country seeder and additional database table cleanup

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
WorldHeritageDtoCollectionTest.php Updated test data and added complex assertion logic for state party handling
CreateWorldHeritagesUseCaseTest.php Updated test fixtures and enhanced database cleanup
CreateWorldHeritageUseCaseTest.php Removed hardcoded ID from test data array
WorldHeritageDtoCollectionFactory.php Added state party fields to DTO construction
WorldHeritageDtoCollection.php Added state party fields to array output
WorldHeritageDto.php Fixed field name from 'state_parties' to 'state_party_codes'
WorldHeritageEntityCollectionTest.php Updated test data and removed comments

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 134 to +146
$actual = collect($dtoCollection->toArray())->map(function($item) {
if (is_array($item['statePartyCodes'])) {
$item['state_parties'] = collect($item['statePartyCodes'])->map(function($code) {
return Str::upper($code);
})->toArray();
}
return collect($item)->keyBy(function($value, $key) {
return Str::snake($key);
})->toArray();
})->toArray();

$expected = collect($data)->map(function($item) {
if (is_array($item['state_parties'])) {
Copy link

Copilot AI Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test assertion logic is overly complex with nested transformations and conditionals. Consider extracting this transformation logic into a separate helper method to improve readability and maintainability.

Suggested change
$actual = collect($dtoCollection->toArray())->map(function($item) {
if (is_array($item['statePartyCodes'])) {
$item['state_parties'] = collect($item['statePartyCodes'])->map(function($code) {
return Str::upper($code);
})->toArray();
}
return collect($item)->keyBy(function($value, $key) {
return Str::snake($key);
})->toArray();
})->toArray();
$expected = collect($data)->map(function($item) {
if (is_array($item['state_parties'])) {
$actual = $this->transformCollectionForComparison($dtoCollection->toArray(), 'dto');
$expected = $this->transformCollectionForComparison($data, 'array');
$this->assertEquals($expected, $actual);
}
/**
* Helper to transform collection for comparison in tests.
*
* @param array $collection
* @param string $mode 'dto' or 'array'
* @return array
*/
private function transformCollectionForComparison(array $collection, string $mode): array
{
return collect($collection)->map(function($item) use ($mode) {
if ($mode === 'dto' && isset($item['statePartyCodes']) && is_array($item['statePartyCodes'])) {
$item['state_parties'] = collect($item['statePartyCodes'])->map(function($code) {
return Str::upper($code);
})->toArray();
}
if ($mode === 'array' && isset($item['state_parties']) && is_array($item['state_parties'])) {

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +37
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=0;');
WorldHeritage::truncate();
Country::truncate();
DB::table('site_state_parties')->truncate();
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=1;');
Copy link

Copilot AI Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Database connection is hardcoded to 'mysql'. Consider using the default connection or making it configurable to support different database types in testing environments.

Suggested change
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=0;');
WorldHeritage::truncate();
Country::truncate();
DB::table('site_state_parties')->truncate();
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=1;');
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
WorldHeritage::truncate();
Country::truncate();
DB::table('site_state_parties')->truncate();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');

Copilot uses AI. Check for mistakes.
Comment on lines 37 to 41
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=0;');
WorldHeritage::truncate();
Country::truncate();
DB::table('site_state_parties')->truncate();
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=1;');
Copy link

Copilot AI Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Database connection is hardcoded to 'mysql'. Consider using the default connection or making it configurable to support different database types in testing environments.

Suggested change
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=0;');
WorldHeritage::truncate();
Country::truncate();
DB::table('site_state_parties')->truncate();
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=1;');
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
WorldHeritage::truncate();
Country::truncate();
DB::table('site_state_parties')->truncate();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');

Copilot uses AI. Check for mistakes.
@zigzagdev zigzagdev merged commit 415a146 into feature/central-asia Aug 25, 2025
1 check passed
@zigzagdev zigzagdev deleted the feature/central-asia-application branch August 25, 2025 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Application Layer

2 participants