"All new business logic should have corresponding unit tests."
Description
This PR introduces unit tests for the DataOptimizer and Sour classes. These tests ensure the correctness of the recently introduced business logic in these classes.
For the DataOptimizer class, tests have been added for the trimString, normalizeIdentifier, and concatenateWithSeparator methods. These tests cover various inputs, including edge cases like empty strings, strings with only whitespace, and strings with special characters.
For the Sour class, tests have been added for the convert method. This method contains complex logic, so the tests cover different scenarios and edge cases. The tests ensure that the method can handle a wide range of inputs, including cases where certain properties are present, absent, or have unusual values.
Summary of Changes
Created a new test file tests/Utils/DataOptimizerTest.php for the DataOptimizer class.
Added tests for trimString, normalizeIdentifier, and concatenateWithSeparator methods in DataOptimizerTest.php.
Modified tests/WriterTest.php to include tests for the Sour class's convert method.
Created several mock Sour objects with different combinations of properties for testing.
Added assertions to check the expected GEDCOM output string for each mock Sour object.
PR Feedback (click)
I created this PR to address this rule:
"All new business logic should have corresponding unit tests."
Description
This PR introduces unit tests for the
DataOptimizer
andSour
classes. These tests ensure the correctness of the recently introduced business logic in these classes.For the
DataOptimizer
class, tests have been added for thetrimString
,normalizeIdentifier
, andconcatenateWithSeparator
methods. These tests cover various inputs, including edge cases like empty strings, strings with only whitespace, and strings with special characters.For the
Sour
class, tests have been added for theconvert
method. This method contains complex logic, so the tests cover different scenarios and edge cases. The tests ensure that the method can handle a wide range of inputs, including cases where certain properties are present, absent, or have unusual values.Summary of Changes
tests/Utils/DataOptimizerTest.php
for theDataOptimizer
class.trimString
,normalizeIdentifier
, andconcatenateWithSeparator
methods inDataOptimizerTest.php
.tests/WriterTest.php
to include tests for theSour
class'sconvert
method.Sour
objects with different combinations of properties for testing.Sour
object.