Test 1: Verify only one edit button in profile view... Found 1 edit button(s) pointing to edit-profile ✅ PASS: 'Edit Phone Number' button has been removed ✅ PASS: 'Edit Profile' button exists ✅ PASS: 'Edit Profile Info' button has been removed ✅ PASS: 'Edit Profile' button found with correct markup Test 2: Verify button navigates to correct route... /edit-profile // Look for the Edit Profile button and verify its href contains the right parts $editProfilePos = strpos($viewFile, '>Edit Profile'); if ($editProfilePos === false) { echo " ❌ FAIL: Edit Profile button not found\n"; exit(1); } // Get the 500 characters before the button to capture the full href $buttonContext = substr($viewFile, max(0, $editProfilePos - 500), 500); // Verify the href contains both /user and edit-profile if (strpos($buttonContext, '/user') === false || strpos($buttonContext, 'edit-profile') === false) { echo " ❌ FAIL: Button does not link to /user/edit-profile\n"; echo " Context: " . substr($buttonContext, -200) . "\n"; exit(1); } // Verify the href attribute exists if (strpos($buttonContext, 'href=') === false) { echo " ❌ FAIL: Button does not have href attribute\n"; exit(1); } echo " ✅ PASS: Button navigates to /user/edit-profile\n"; // Test 3: Verify edit form has all required fields echo "\nTest 3: Verify edit form has all required fields...\n"; $requiredFields = [ 'Email' => 'email', 'Display Name' => 'name', 'First Name' => 'fname', 'Last Name' => 'lname', 'Timezone' => 'timezone', '24-hour Format' => 'format_24h', 'Phone Number' => 'phone' ]; foreach ($requiredFields as $label => $nameAttr) { // Check for label if (strpos($editProfileFile, $label) === false) { echo " ❌ FAIL: Field label '{$label}' not found in edit form\n"; exit(1); } // Check for name attribute if (strpos($editProfileFile, 'name="' . $nameAttr . '"') === false) { echo " ❌ FAIL: Field name '{$nameAttr}' not found in edit form\n"; exit(1); } echo " ✅ PASS: Field '{$label}' (name='{$nameAttr}') found in edit form\n"; } // Test 4: Verify phone number section includes validation status echo "\nTest 4: Verify phone number section has validation status indicators...\n"; if (strpos($editProfileFile, 'phone_validated') === false) { echo " ❌ FAIL: Phone validation status indicator not found\n"; exit(1); } echo " ✅ PASS: Phone validation status indicator found\n"; if (strpos($editProfileFile, 'Phone verified') === false) { echo " ❌ FAIL: 'Phone verified' status not found\n"; exit(1); } echo " ✅ PASS: 'Phone verified' status found\n"; if (strpos($editProfileFile, 'Pending verification') === false) { echo " ❌ FAIL: 'Pending verification' status not found\n"; exit(1); } echo " ✅ PASS: 'Pending verification' status found\n"; // Test 5: Verify phone action buttons exist echo "\nTest 5: Verify phone action buttons exist...\n"; if (strpos($editProfileFile, 'Resend Validation SMS') === false) { echo " ❌ FAIL: 'Resend Validation SMS' button not found\n"; exit(1); } echo " ✅ PASS: 'Resend Validation SMS' button found\n"; if (strpos($editProfileFile, 'Remove Phone Number') === false) { echo " ❌ FAIL: 'Remove Phone Number' button not found\n"; exit(1); } echo " ✅ PASS: 'Remove Phone Number' button found\n"; if (strpos($editProfileFile, 'Change Phone Number') === false) { echo " ❌ FAIL: 'Change Phone Number' button not found\n"; exit(1); } echo " ✅ PASS: 'Change Phone Number' button found\n"; // Test 6: Verify button is properly positioned (after all profile fields) echo "\nTest 6: Verify button positioning...\n"; // Check that Edit Profile button comes after 24-hour Format field $buttonPos = strpos($viewFile, 'Edit Profile'); $format24hPos = strpos($viewFile, '24-hour Format'); if ($buttonPos === false || $format24hPos === false) { echo " ❌ FAIL: Could not determine button positioning\n"; exit(1); } if ($buttonPos < $format24hPos) { echo " ❌ FAIL: Edit Profile button appears before 24-hour Format field\n"; exit(1); } echo " ✅ PASS: Edit Profile button appears after all profile fields\n"; // Test 7: Verify $isOwnProfile condition is still present echo "\nTest 7: Verify edit button is only shown for own profile...\n"; if (strpos($viewFile, 'if ($isOwnProfile):') === false) { echo " ❌ FAIL: \$isOwnProfile condition not found\n"; exit(1); } echo " ✅ PASS: Edit button is conditional on \$isOwnProfile\n"; // Verify the Edit Profile button is inside the isOwnProfile block $buttonPattern = '/if\s*\(\s*\$isOwnProfile\s*\):.*?Edit Profile.*?endif/is'; if (!preg_match($buttonPattern, $viewFile)) { echo " ❌ FAIL: Edit Profile button is not inside isOwnProfile block\n"; exit(1); } echo " ✅ PASS: Edit Profile button is inside isOwnProfile block\n"; echo "\n" . str_repeat("=", 60) . "\n"; echo "All tests passed! ✅\n"; echo str_repeat("=", 60) . "\n"; echo "\nSummary:\n"; echo " - Only one 'Edit Profile' button exists (duplicates removed)\n"; echo " - Button navigates to /user/edit-profile\n"; echo " - Edit form contains all required fields\n"; echo " - Phone number section has validation status indicators\n"; echo " - Phone action buttons (Resend, Change, Remove) are present\n"; echo " - Button is properly positioned after all profile fields\n"; echo " - Edit button is only shown for own profile\n"; exit(0);