- Add validateCSVStockLocations() method to check CSV columns against allowed locations
- Log error when invalid stock location columns are detected
- Tests for valid, invalid, and mixed stock location columns
- Tests for location name case sensitivity
- Tests for CSV parsing and detecting location columns
- Add error message language string for invalid locations
- Add comprehensive test suite for CSV import in ItemsCsvImportTest.php
- Test CSV header generation (locations, attributes, BOM handling)
- Test CSV file parsing (multiple rows, BOM detection)
- Test item import (basic fields, quantities, inventory records)
- Test item updates, taxes, and attributes
- Test edge cases (zero quantities, negative values, precision)
- Add GitHub Actions workflow for unit tests
- Tests verify data ends up correctly in items/item_quantities tables
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.
* Improve code style and PSR-12 compliance
- refactored code formatting to adhere to PSR-12 guidelines
- standardized coding conventions across the codebase
- added missing framework files and reverted markup changes
- reformatted arrays for enhanced readability
- updated language files for consistent styling and clarity
- minor miscellaneous improvements