Core Components Implemented:
- FilenameParser: V2 naming convention parser with strict validation
- MetadataMerger: Merge master + filename metadata (filename priority)
- BoxFileRetriever: List/download files from Box folders
- DAM Lookup Domains: Complete documentation (182 domains)
Features:
- Parse V2 filenames: OMG_JOB_BRAND_COUNTRY_LANG_TITLE_TYPE_VER_SEC_RATIO_TRACKING
- Strip upload components (Job Number & Tracking ID)
- Extract tracking IDs and load master metadata from PostgreSQL
- Merge metadata with filename always winning
- Identify editable vs locked fields
- Build proper asset representation for DAM upload
Files Added:
- src/FilenameParser.php (tested - 8/8 passing)
- src/MetadataMerger.php
- src/BoxFileRetriever.php
- ECOMMERCE_ALLOWED_FIELDS.md (182 lookup domains)
- DAM_LOOKUPDOMAINS_RAW.json (15MB raw data)
- test_filename_parser.php
- fetch_lookupdomains.php
- UPLOAD_FROM_BOX_STATUS.md (complete documentation)
Next Phase: UI integration - Add "Upload from Box" tab to workflow_v3.php
🤖 Generated with Claude Code
137 lines
4.2 KiB
PHP
137 lines
4.2 KiB
PHP
<?php
|
|
/**
|
|
* Test FilenameParser with various V2 naming convention examples
|
|
*/
|
|
|
|
require_once 'src/FilenameParser.php';
|
|
|
|
echo "=== FilenameParser Test Suite ===\n\n";
|
|
|
|
$parser = new FilenameParser();
|
|
|
|
// Test cases
|
|
$testCases = [
|
|
// Valid filenames
|
|
[
|
|
'filename' => '1234567_RAF_CH_de_TEST_FILE_OLV_001_15S_16x9_a7K9mP.mp4',
|
|
'description' => 'Complete V2 filename with tracking ID',
|
|
'expected_valid' => true
|
|
],
|
|
[
|
|
'filename' => '9876543_KIN_IT_it_CHRISTMAS_TVC_MST_30S_16x9_xYz123.mov',
|
|
'description' => 'Master file (MST) with tracking ID',
|
|
'expected_valid' => true
|
|
],
|
|
[
|
|
'filename' => '555_RAF_DE_de_SAMPLE_ECB_002_6S_4x3.jpg',
|
|
'description' => 'Without tracking ID (optional)',
|
|
'expected_valid' => true
|
|
],
|
|
[
|
|
'filename' => '12345_FERR_US_en_MULTI_WORD_TITLE_OLV_001_15S_16x9_abc123.mp4',
|
|
'description' => 'Multi-word subject title',
|
|
'expected_valid' => true
|
|
],
|
|
|
|
// Invalid filenames
|
|
[
|
|
'filename' => 'RAF_CH_de_TEST_OLV_001_15S_16x9.mp4',
|
|
'description' => 'Missing OMG Job Number',
|
|
'expected_valid' => false
|
|
],
|
|
[
|
|
'filename' => '1234567_R_CH_de_TEST_OLV_001_15S_16x9.mp4',
|
|
'description' => 'Brand code too short',
|
|
'expected_valid' => false
|
|
],
|
|
[
|
|
'filename' => '1234567_RAF_CHE_de_TEST_OLV_001_15S_16x9.mp4',
|
|
'description' => 'Country code wrong length',
|
|
'expected_valid' => false
|
|
],
|
|
[
|
|
'filename' => '1234567_RAF_CH_d_TEST_OLV_001_15S_16x9.mp4',
|
|
'description' => 'Language code too short',
|
|
'expected_valid' => false
|
|
]
|
|
];
|
|
|
|
// Run tests
|
|
$passed = 0;
|
|
$failed = 0;
|
|
|
|
foreach ($testCases as $index => $test) {
|
|
echo "Test " . ($index + 1) . ": {$test['description']}\n";
|
|
echo "Filename: {$test['filename']}\n";
|
|
|
|
$parsed = $parser->parseFilename($test['filename']);
|
|
|
|
if ($parsed) {
|
|
$isValid = $parsed['is_valid'];
|
|
$expectedValid = $test['expected_valid'];
|
|
|
|
if ($isValid === $expectedValid) {
|
|
echo "✓ PASSED\n";
|
|
$passed++;
|
|
|
|
// Show parsed components for valid files
|
|
if ($isValid) {
|
|
echo " Components:\n";
|
|
echo " OMG Job: {$parsed['omg_job_number']}\n";
|
|
echo " Brand: {$parsed['brand_code']}\n";
|
|
echo " Country: {$parsed['country_code']}\n";
|
|
echo " Language: {$parsed['language_code']}\n";
|
|
echo " Subject: {$parsed['subject_title']}\n";
|
|
echo " Asset Type: {$parsed['asset_type']}\n";
|
|
echo " Spot Version: {$parsed['spot_version']}\n";
|
|
echo " Duration: {$parsed['seconds']}S\n";
|
|
echo " Aspect Ratio: {$parsed['aspect_ratio']}\n";
|
|
echo " Tracking ID: " . ($parsed['tracking_id'] ?? 'None') . "\n";
|
|
|
|
// Show clean filename
|
|
$cleanFilename = $parser->stripUploadComponents($test['filename']);
|
|
echo " Clean Filename: $cleanFilename\n";
|
|
} else {
|
|
echo " Validation Errors:\n";
|
|
foreach ($parsed['validation_errors'] as $error) {
|
|
echo " - $error\n";
|
|
}
|
|
}
|
|
|
|
if (!empty($parsed['warnings'])) {
|
|
echo " Warnings:\n";
|
|
foreach ($parsed['warnings'] as $warning) {
|
|
echo " - $warning\n";
|
|
}
|
|
}
|
|
} else {
|
|
echo "✗ FAILED - Expected valid=$expectedValid, got valid=$isValid\n";
|
|
$failed++;
|
|
|
|
if (!empty($parsed['validation_errors'])) {
|
|
echo " Validation Errors:\n";
|
|
foreach ($parsed['validation_errors'] as $error) {
|
|
echo " - $error\n";
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
echo "✗ FAILED - Could not parse filename\n";
|
|
$failed++;
|
|
}
|
|
|
|
echo "\n" . str_repeat('-', 70) . "\n\n";
|
|
}
|
|
|
|
// Summary
|
|
echo "=== TEST SUMMARY ===\n";
|
|
echo "Total: " . count($testCases) . "\n";
|
|
echo "Passed: $passed\n";
|
|
echo "Failed: $failed\n";
|
|
echo "\n";
|
|
|
|
if ($failed === 0) {
|
|
echo "✓ All tests passed!\n";
|
|
} else {
|
|
echo "✗ Some tests failed\n";
|
|
}
|