This PR refactors large functions in GedcomExporterTest.php and ImporterTests.php to improve code readability, understandability, and maintainability. The changes involve breaking down large test methods into smaller, more modular functions that handle specific parts of the functionality.
In GedcomExporterTest.php, the testExportingData function has been refactored into functions that set up the test environment, execute the test, and verify the results. Similarly, in ImporterTests.php, the functions testNoteImport, testObjeImport, and testRepoImport have been broken down into functions that prepare the mock data, execute the import, and verify the results.
Summary of Changes
Extracted the setup logic of the testExportingDataCreatesDirectoryIfNeeded and testExportingDataWithMockDatabaseRecords into a private method named setupExportTestEnvironment in GedcomExporterTest.php.
Extracted the verification logic of testExportingDataCreatesDirectoryIfNeeded and testExportingDataWithMockDatabaseRecords into a private method named verifyExportedFileExists in GedcomExporterTest.php.
Replaced the setup and verification code in testExportingDataCreatesDirectoryIfNeeded and testExportingDataWithMockDatabaseRecords with calls to setupExportTestEnvironment and verifyExportedFileExists respectively.
For each of the testNoteImport, testObjeImport, and testRepoImport methods in ImporterTests.php, extracted the mock data preparation into a private method named prepareMockDataFor<Type>Import.
Extracted the verification logic in each of these methods into a private method named verify<Type>ImportResult in ImporterTests.php.
Replaced the mock data preparation and verification code in testNoteImport, testObjeImport, and testRepoImport with calls to the respective prepareMockDataFor<Type>Import and verify<Type>ImportResult methods.
PR Feedback (click)
I created this PR to address this rule:
"Refactor large functions to be more modular."
Description
This PR refactors large functions in
GedcomExporterTest.php
andImporterTests.php
to improve code readability, understandability, and maintainability. The changes involve breaking down large test methods into smaller, more modular functions that handle specific parts of the functionality.In
GedcomExporterTest.php
, thetestExportingData
function has been refactored into functions that set up the test environment, execute the test, and verify the results. Similarly, inImporterTests.php
, the functionstestNoteImport
,testObjeImport
, andtestRepoImport
have been broken down into functions that prepare the mock data, execute the import, and verify the results.Summary of Changes
testExportingDataCreatesDirectoryIfNeeded
andtestExportingDataWithMockDatabaseRecords
into a private method namedsetupExportTestEnvironment
inGedcomExporterTest.php
.testExportingDataCreatesDirectoryIfNeeded
andtestExportingDataWithMockDatabaseRecords
into a private method namedverifyExportedFileExists
inGedcomExporterTest.php
.testExportingDataCreatesDirectoryIfNeeded
andtestExportingDataWithMockDatabaseRecords
with calls tosetupExportTestEnvironment
andverifyExportedFileExists
respectively.testNoteImport
,testObjeImport
, andtestRepoImport
methods inImporterTests.php
, extracted the mock data preparation into a private method namedprepareMockDataFor<Type>Import
.verify<Type>ImportResult
inImporterTests.php
.testNoteImport
,testObjeImport
, andtestRepoImport
with calls to the respectiveprepareMockDataFor<Type>Import
andverify<Type>ImportResult
methods.