mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-29 10:47:53 -04:00
This commit adds unit tests for the case-sensitive attribute updates and CSV import attribute deletion capability features introduced in PR #4384. Test Coverage: - Attribute Model Tests (tests/Models/AttributeTest.php): - testCaseSensitiveAttributeValueUpdate: Verifies case-insensitive check then case-sensitive update - testDeleteAttributeLinks: Tests deletion of attribute links - testCategoryDropdownCanBeEnabled: Verifies dropdown enablement bug fix - testDropdownAttributeValueSave: Tests DROPDOWN type attributes - testDateAttributeValueSave/Update: Tests DATE type attributes - testDecimalAttributeValueSave: Tests DECIMAL type attributes - testCheckboxAttributeValueSave: Tests CHECKBOX type attributes - testCategoryDropdownWithConstant: Tests CATEGORY_DEFINITION_ID usage - testDeleteAttributeLinksPreservesSalesAndReceivings: Ensures sales/receivings links protected - testDeleteOrphanedValues: Tests orphan value cleanup - testUnicodeCaseComparison: Tests Unicode handling in case comparisons - testGetAttributeValueByAttributeId: Tests new utility method - testAttributeLinkWithNullAttributeId: Tests null attribute_id handling - testCategoryDropdownUpdatesItemCategory: Tests category dropdown behavior - Attribute Helper Tests (tests/Helpers/AttributeHelperTest.php): - Test getAttributeDataType for all attribute types (TEXT, DECIMAL, DATE, DROPDOWN, CHECKBOX) - Test getAttributeDataType returns 'attribute_value' as fallback for invalid types - Test validateAttributeValueType throws InvalidArgumentException for invalid types - Test validateAttributeValueType accepts valid data types - Import File Helper Tests (tests/Helpers/ImportFileHelperTest.php): - Tests _DELETE_ magic word case-insensitive comparison using strcasecmp - Tests that _DELETE_ does not match similar-looking strings (security) - Tests empty string does not match _DELETE_ - Tests null safety considerations for strcasecmp usage Test Configuration: - Updated phpunit.xml to include Models and Controllers test suites - Uses DatabaseTestTrait for database migration between tests - Tests cover positive and negative cases - Tests include edge cases: Unicode, null values, empty strings, similar strings Files Added: - tests/Models/AttributeTest.php (26,541 bytes, 16 test methods) - tests/Helpers/AttributeHelperTest.php (3,331 bytes, 8 test methods) - tests/Helpers/ImportFileHelperTest.php (2,906 bytes, 4 test methods) Total: 28 test methods covering all new features and edge cases Note: Tests currently designed; will run once PHP environment is configured.