Skip to content

Fix Presentation Layer Tests#99

Merged
zigzagdev merged 1 commit into
feature/west-asia-midlle-eastfrom
feature/west-asia-middle-east-presentation
Sep 5, 2025
Merged

Fix Presentation Layer Tests#99
zigzagdev merged 1 commit into
feature/west-asia-midlle-eastfrom
feature/west-asia-middle-east-presentation

Conversation

@zigzagdev

Copy link
Copy Markdown
Owner

what i have done

  • fix controller tests

Copilot AI left a comment

Copy link
Copy Markdown

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 fixes presentation layer tests for the WorldHeritageController by updating test data structures and adding database management functionality. The main purpose is to align the test data with changes to the WorldHeritage data model that now includes state party information and removes UNESCO ID references.

  • Updated test data from Japanese heritage sites to European/Asian transnational sites with state party metadata
  • Added database seeding and cleanup functionality with proper foreign key constraint handling
  • Removed UNESCO ID field references and added state party fields to match updated data model

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
WorldHeritageController_getByIdsTest.php Updated test data structure, added database refresh logic, and modified assertions to match new data model
WorldHeritageController_getByIdTest.php Updated test data, added database cleanup methods, and updated mock DTO to handle new state party fields

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


private function refresh(): void
{
if (env('APP_ENV') === 'testing') {

Copilot AI Sep 5, 2025

Copy link

Choose a reason for hiding this comment

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

Using env() directly in application code is discouraged. Use config('app.env') instead, as env() should only be used in configuration files.

Suggested change
if (env('APP_ENV') === 'testing') {
if (config('app.env') === 'testing') {

Copilot uses AI. Check for mistakes.

private function refresh(): void
{
if (env('APP_ENV') === 'testing') {

Copilot AI Sep 5, 2025

Copy link

Choose a reason for hiding this comment

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

Using env() directly in application code is discouraged. Use config('app.env') instead, as env() should only be used in configuration files.

Suggested change
if (env('APP_ENV') === 'testing') {
if (config('app.env') === 'testing') {

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +48
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;');

Copilot AI Sep 5, 2025

Copy link

Choose a reason for hiding this comment

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

Hard-coding the MySQL connection makes the tests less portable. Consider using the default connection or making it configurable for different database drivers.

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;');
$connection = DB::connection();
$driver = $connection->getDriverName();
if ($driver === 'mysql') {
$connection->statement('SET FOREIGN_KEY_CHECKS=0;');
}
WorldHeritage::truncate();
Country::truncate();
DB::table('site_state_parties')->truncate();
if ($driver === 'mysql') {
$connection->statement('SET FOREIGN_KEY_CHECKS=1;');
}

Copilot uses AI. Check for mistakes.
Comment on lines +38 to +42
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;');

Copilot AI Sep 5, 2025

Copy link

Choose a reason for hiding this comment

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

Hard-coding the MySQL connection makes the tests less portable. Consider using the default connection or making it configurable for different database drivers.

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 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Ok

@zigzagdev zigzagdev linked an issue Sep 5, 2025 that may be closed by this pull request
@zigzagdev zigzagdev merged commit 13dc8c6 into feature/west-asia-midlle-east Sep 5, 2025
1 check passed
@zigzagdev zigzagdev deleted the feature/west-asia-middle-east-presentation branch September 5, 2025 10:24
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 Presentation Layer

2 participants