Files
shopify-ai-backup/test-class-loading.sh

42 lines
1.2 KiB
Bash

#!/bin/bash
# Simple test for class loading validation
echo "Testing class loading validation..."
# Create a simple test file with class loading issues
cat > /tmp/test-class-loading.php << 'EOF'
<?php
// Test file with class loading issues
// Admin hooks without admin class loading
add_action('admin_menu', array('Test_Admin', 'add_menu'));
// Frontend hooks without frontend class loading
add_action('wp_enqueue_scripts', array('Test_Frontend', 'enqueue'));
// Static method calls on potentially unloaded classes
$result = Test_Admin::some_method();
// Class instantiation without proper loading
$admin = new Test_Admin();
EOF
echo "Created test file with class loading issues"
# Test the pattern matching
echo "Testing regex patterns..."
# Test admin class loading detection
if grep -qE "add_action\s*\(\s*['\"]admin_menu" /tmp/test-class-loading.php; then
echo "✓ Admin hook detection working"
fi
if grep -qE "(Admin|admin)" /tmp/test-class-loading.php; then
echo "✓ Admin class reference detection working"
fi
if ! grep -B10 "add_action.*admin_menu" /tmp/test-class-loading.php | grep -qE "(require|include).*Admin"; then
echo "✓ Admin class loading validation working - detected missing load"
fi
echo "Class loading validation test completed"