Unit Test Generator

Instructions

This tool automatically generates PHPUnit test templates for your functions and classes. Here's how it works:

  1. Select a function or class from the lists below
  2. Click "Generate Test" to create a PHPUnit test template
  3. Customize the generated test to suit your specific test requirements
  4. Copy the code and save it to your tests directory
The generated tests are templates and may need customization for your specific use cases.
Functions (529)
Function Name File Action
copyBrief index1.php
include_db_setup index1.php
include_overview index1.php
include_database index1.php
include_files index1.php
ajax_getTableColumnsAjax ajax_handlers.php
detectLanguage language_detector.php
detectFromContent language_detector.php
getSupportedLanguages language_detector.php
isLanguageSupported language_detector.php
detectTrends language_detector.php
getSupportedLanguage css_analyzer.php
getName css_analyzer.php
getDescription css_analyzer.php
getVersion css_analyzer.php
getExternalToolDependencies css_analyzer.php
checkDependencies css_analyzer.php
analyze css_analyzer.php
detectCssType css_analyzer.php
analyzeBasicMetrics css_analyzer.php
extractSelectors css_analyzer.php
calculateSelectorSpecificity css_analyzer.php
calculateSelectorNesting css_analyzer.php
extractProperties css_analyzer.php
extractColors css_analyzer.php
findSimilarColors css_analyzer.php
areColorsSimilar css_analyzer.php
checkBrowserPrefixes css_analyzer.php
analyzePerformance css_analyzer.php
analyzeBestPractices css_analyzer.php
checkShorthandProperties css_analyzer.php
analyzeSassSpecific css_analyzer.php
analyzeLessSpecific css_analyzer.php
runExternalTools css_analyzer.php
isToolAvailable css_analyzer.php
runStylelint css_analyzer.php
runSassLint css_analyzer.php
getSupportedLanguage js_analyzer.php
getName js_analyzer.php
getDescription js_analyzer.php
getVersion js_analyzer.php
getExternalToolDependencies js_analyzer.php
checkDependencies js_analyzer.php
analyze js_analyzer.php
analyzeBasicMetrics js_analyzer.php
calculateCyclomaticComplexity js_analyzer.php
calculateFunctionLengths js_analyzer.php
calculateCommentRatio js_analyzer.php
checkNamingConventions js_analyzer.php
names js_analyzer.php
analyzeSecurityIssues js_analyzer.php
analyzeJavaScriptSpecificIssues js_analyzer.php
runExternalTools js_analyzer.php
isToolAvailable js_analyzer.php
runESLint js_analyzer.php
runJSHint js_analyzer.php
initialize base_analyzer.php
initialize base_analyzer.php
getSupportedMetrics base_analyzer.php
isMetricSupported base_analyzer.php
requiresExternalTools base_analyzer.php
getDefaultResultStructure base_analyzer.php
calculateLinesOfCode base_analyzer.php
addIssue base_analyzer.php
addMetric base_analyzer.php
registerAnalyzer base_analyzer.php
getAnalyzer base_analyzer.php
getSupportedLanguages base_analyzer.php
isLanguageSupported base_analyzer.php
discoverAnalyzers base_analyzer.php
getSupportedLanguage anguler_analyzer.php
getName anguler_analyzer.php
getDescription anguler_analyzer.php
getVersion anguler_analyzer.php
getExternalToolDependencies anguler_analyzer.php
checkDependencies anguler_analyzer.php
analyze anguler_analyzer.php
analyzeBasicMetrics anguler_analyzer.php
calculateCyclomaticComplexity anguler_analyzer.php
calculateMethodLengths anguler_analyzer.php
calculateCommentRatio anguler_analyzer.php
checkNamingConventions anguler_analyzer.php
analyzeSecurityIssues anguler_analyzer.php
analyzeAngularSpecificIssues anguler_analyzer.php
checkChangeDetectionIssues anguler_analyzer.php
checkPotentialMemoryLeaks anguler_analyzer.php
checkStandaloneComponents anguler_analyzer.php
checkTemplateBindingIssues anguler_analyzer.php
checkLazyLoading anguler_analyzer.php
checkDependencyInjectionIssues anguler_analyzer.php
runExternalTools anguler_analyzer.php
isToolAvailable anguler_analyzer.php
runESLint anguler_analyzer.php
runTSLint anguler_analyzer.php
getSupportedLanguage php_analyzer.php
getName php_analyzer.php
getDescription php_analyzer.php
getVersion php_analyzer.php
getExternalToolDependencies php_analyzer.php
checkDependencies php_analyzer.php
analyze php_analyzer.php
analyzeBasicMetrics php_analyzer.php
calculateCyclomaticComplexity php_analyzer.php
calculateMethodLengths php_analyzer.php
calculateCommentRatio php_analyzer.php
checkNamingConventions php_analyzer.php
names php_analyzer.php
analyzeSecurityIssues php_analyzer.php
checkSQLInjection php_analyzer.php
checkXSS php_analyzer.php
checkOtherSecurityIssues php_analyzer.php
analyzePHPSpecificIssues php_analyzer.php
checkDeprecatedFunctions php_analyzer.php
checkVersionCompatibility php_analyzer.php
checkErrorSuppression php_analyzer.php
runExternalTools php_analyzer.php
isToolAvailable php_analyzer.php
runPHPCS php_analyzer.php
runPHPStan php_analyzer.php
getSupportedLanguage typescript_analyzer.php
getName typescript_analyzer.php
getDescription typescript_analyzer.php
getVersion typescript_analyzer.php
getExternalToolDependencies typescript_analyzer.php
checkDependencies typescript_analyzer.php
analyze typescript_analyzer.php
analyzeBasicMetrics typescript_analyzer.php
calculateCyclomaticComplexity typescript_analyzer.php
calculateFunctionLengths typescript_analyzer.php
calculateCommentRatio typescript_analyzer.php
checkNamingConventions typescript_analyzer.php
names typescript_analyzer.php
analyzeSecurityIssues typescript_analyzer.php
analyzeTypeScriptSpecificIssues typescript_analyzer.php
checkTypeSafetyIssues typescript_analyzer.php
checkInterfaceIssues typescript_analyzer.php
checkGenericsIssues typescript_analyzer.php
checkNullSafetyIssues typescript_analyzer.php
checkTypeScriptBestPractices typescript_analyzer.php
runExternalTools typescript_analyzer.php
isToolAvailable typescript_analyzer.php
runESLint typescript_analyzer.php
runTypeScriptCompiler typescript_analyzer.php
getSupportedLanguage react_analyzer.php
getName react_analyzer.php
getDescription react_analyzer.php
getVersion react_analyzer.php
getExternalToolDependencies react_analyzer.php
checkDependencies react_analyzer.php
analyze react_analyzer.php
analyzeBasicMetrics react_analyzer.php
calculateCyclomaticComplexity react_analyzer.php
calculateComponentLengths react_analyzer.php
calculateCommentRatio react_analyzer.php
checkNamingConventions react_analyzer.php
names react_analyzer.php
analyzeSecurityIssues react_analyzer.php
analyzeReactSpecificIssues react_analyzer.php
checkHooksRules react_analyzer.php
checkComponentStructure react_analyzer.php
checkPerformanceIssues react_analyzer.php
runExternalTools react_analyzer.php
isToolAvailable react_analyzer.php
runESLint react_analyzer.php
loadAnalyzers analyzer_loader.php
getLoadedAnalyzers analyzer_loader.php
getSupportedLanguages analyzer_loader.php
analyzeCode analyzer_loader.php
performGenericAnalysis analyzer_loader.php
getSupportedLanguage html_analyzer.php
getName html_analyzer.php
getDescription html_analyzer.php
getVersion html_analyzer.php
getExternalToolDependencies html_analyzer.php
checkDependencies html_analyzer.php
analyze html_analyzer.php
checkBasicStructure html_analyzer.php
checkHtmlNesting html_analyzer.php
checkDeprecatedElements html_analyzer.php
checkAccessibility html_analyzer.php
checkHeadingOrder html_analyzer.php
checkColorContrast html_analyzer.php
checkBestPractices html_analyzer.php
checkSemanticElements html_analyzer.php
checkScriptLoading html_analyzer.php
checkSEO html_analyzer.php
checkTitleLength html_analyzer.php
runExternalTools html_analyzer.php
isToolAvailable html_analyzer.php
runHtmlValidate html_analyzer.php
getSupportedLanguage python_analyzer.php
getName python_analyzer.php
getDescription python_analyzer.php
getVersion python_analyzer.php
getExternalToolDependencies python_analyzer.php
checkDependencies python_analyzer.php
analyze python_analyzer.php
analyzeBasicMetrics python_analyzer.php
calculateCyclomaticComplexity python_analyzer.php
calculateFunctionLengths python_analyzer.php
if python_analyzer.php
calculateCommentRatio python_analyzer.php
checkNamingConventions python_analyzer.php
names python_analyzer.php
analyzeSecurityIssues python_analyzer.php
checkSQLInjection python_analyzer.php
checkCommandInjection python_analyzer.php
checkUnsafeDeserialization python_analyzer.php
checkInsecureFileOperations python_analyzer.php
analyzePythonSpecificIssues python_analyzer.php
checkGlobalVariables python_analyzer.php
checkMutableDefaultArgs python_analyzer.php
checkBareExcept python_analyzer.php
checkVersionCompatibility python_analyzer.php
runExternalTools python_analyzer.php
isToolAvailable python_analyzer.php
runPylint python_analyzer.php
runMypy python_analyzer.php
getSupportedLanguage csharp_analyzer.php
getName csharp_analyzer.php
getDescription csharp_analyzer.php
getVersion csharp_analyzer.php
getExternalToolDependencies csharp_analyzer.php
checkDependencies csharp_analyzer.php
analyze csharp_analyzer.php
analyzeBasicMetrics csharp_analyzer.php
calculateCyclomaticComplexity csharp_analyzer.php
calculateMethodLengths csharp_analyzer.php
calculateClassSizes csharp_analyzer.php
calculateCommentRatio csharp_analyzer.php
checkNamingConventions csharp_analyzer.php
analyzeSecurityIssues csharp_analyzer.php
checkSQLInjection csharp_analyzer.php
checkXSS csharp_analyzer.php
checkOtherSecurityIssues csharp_analyzer.php
analyzeCSharpSpecificIssues csharp_analyzer.php
checkDisposableUsage csharp_analyzer.php
checkExceptionHandling csharp_analyzer.php
checkLinqPerformance csharp_analyzer.php
checkAsyncAwaitUsage csharp_analyzer.php
checkBoxingUnboxing csharp_analyzer.php
runExternalTools csharp_analyzer.php
isToolAvailable csharp_analyzer.php
runStyleCop csharp_analyzer.php
getTemporaryProjectFile csharp_analyzer.php
include_overview helpers.php
include_database helpers.php
include_db_setup helpers.php
include_user_settings helpers.php
generateAIBrief brief.php
generateAIBrief brief.php
generateEnhancedAIBrief brief.php
getProjectBrief brief.php
isLoggedIn auth.php
processLogin auth.php
processLogout auth.php
include_login_page auth.php
include_db_setup auth.php
getDatabaseTables project-dashboard.php
getTableColumns project-dashboard.php
getRowCount project-dashboard.php
scanDirectory project-dashboard.php
generateAIBrief project-dashboard.php
copyBrief project-dashboard.php
include_overview project-dashboard.php
include_database project-dashboard.php
include_files project-dashboard.php
include_ai_brief project-dashboard.php
include_db_setup project-dashboard.php
include_prompt prompt-generator.php
copyPrompt prompt-generator.php
regeneratePrompt prompt-generator.php
generateBasicBrief prompt-generator.php
generatePrompt prompt-generator.php
extractSectionFromBrief prompt-generator.php
downloadPrompt prompt-generator.php
include_ai_brief enhanced-brief.php
include_metadata_management enhanced-brief.php
getProjectMetadata enhanced-brief.php
saveProjectMetadata enhanced-brief.php
include_code_analyzer code_analyzer.php
copyCode code_analyzer.php
preventDefaults code_analyzer.php
highlight code_analyzer.php
unhighlight code_analyzer.php
codeAnalyzer_generateCorrectedCode code_analyzer.php
codeAnalyzer_generateSuggestion code_analyzer.php
codeAnalyzer_downloadCorrectedCode code_analyzer.php
codeAnalyzer_processProjectUpload code_analyzer.php
codeAnalyzer_scanDirectoryRecursively code_analyzer.php
codeAnalyzer_deleteDirectory code_analyzer.php
codeAnalyzer_getLangIcon code_analyzer.php
codeAnalyzer_getSeverityColor code_analyzer.php
codeAnalyzer_getStatusColor code_analyzer.php
codeAnalyzer_getPrismLanguage code_analyzer.php
codeAnalyzer_formatBytes code_analyzer.php
codeAnalyzer_isAssociative code_analyzer.php
codeAnalyzer_performCodeAnalysis code_analyzer.php
include_module_summary module-summary.php
include_version_control_integration version-control-integration.php
analyzeGitRepository version-control-integration.php
analyzeSvnRepository version-control-integration.php
isCommandAvailable version-control-integration.php
renderVersionControlPage version-control-integration.php
include_dependency_analysis dependency-analysis.php
findFileIncludes dependency-analysis.php
findMethodCalls dependency-analysis.php
findFunctionCalls dependency-analysis.php
findClassInstantiations dependency-analysis.php
extractClasses dependency-analysis.php
extractFunctions dependency-analysis.php
resolveIncludePath dependency-analysis.php
findCircularDependencies dependency-analysis.php
findCircularPath dependency-analysis.php
findMostDependent dependency-analysis.php
findMostDependencies dependency-analysis.php
scanDirectoryForFiles dependency-analysis.php
renderDependencyAnalysisPage dependency-analysis.php
createNetwork dependency-analysis.php
showFileDependencies dependency-analysis.php
showClassDependencies dependency-analysis.php
showNodeDetails dependency-analysis.php
include_security_analysis security.php
getPhpFiles security.php
hasPotentialSqlInjection security.php
hasPotentialXSS security.php
runSecurityScan security.php
getSecurityAnalysisSummary security.php
formatFileSize file-analysis.php
file_analysis_check_dependencies file-analysis.php
include_file_analysis file-analysis.php
scanProjectFiles file-analysis.php
processDirectory file-analysis.php
displayDirectoryTree file-analysis.php
getFileTypeIcon file-analysis.php
getFileAnalysisSummary file-analysis.php
include_module_summary module-summary.php
include_version_control_integration version-control-integration.php
analyzeGitRepository version-control-integration.php
analyzeSvnRepository version-control-integration.php
isCommandAvailable version-control-integration.php
renderVersionControlPage version-control-integration.php
include_dependency_analysis dependency-analysis.php
findFileIncludes dependency-analysis.php
findMethodCalls dependency-analysis.php
findFunctionCalls dependency-analysis.php
findClassInstantiations dependency-analysis.php
extractClasses dependency-analysis.php
extractFunctions dependency-analysis.php
resolveIncludePath dependency-analysis.php
findCircularDependencies dependency-analysis.php
findCircularPath dependency-analysis.php
findMostDependent dependency-analysis.php
findMostDependencies dependency-analysis.php
scanDirectoryForFiles dependency-analysis.php
renderDependencyAnalysisPage dependency-analysis.php
createNetwork dependency-analysis.php
showFileDependencies dependency-analysis.php
showClassDependencies dependency-analysis.php
showNodeDetails dependency-analysis.php
include_unit_test_generator unit-test-generator.php
extractFunctions unit-test-generator.php
extractClasses unit-test-generator.php
generateFunctionTest unit-test-generator.php
generateClassTest unit-test-generator.php
setUp unit-test-generator.php
tearDown unit-test-generator.php
generateSampleValue unit-test-generator.php
renderUnitTestGeneratorPage unit-test-generator.php
copyToClipboard unit-test-generator.php
downloadTest unit-test-generator.php
scanDirectoryForFiles unit-test-generator.php
include_error_log_analysis error-log-analysis.php
parseLogLine error-log-analysis.php
parseDatabaseErrorRecord error-log-analysis.php
renderErrorLogAnalysisPage error-log-analysis.php
include_code_quality_analysis code-quality-analysis.php
foreach code-quality-analysis.php
extractFunctions code-quality-analysis.php
calculateComplexity code-quality-analysis.php
checkCodeStyle code-quality-analysis.php
findUnusedCode code-quality-analysis.php
findDuplicatedCode code-quality-analysis.php
renderCodeQualityAnalysisPage code-quality-analysis.php
scanDirectoryForFiles code-quality-analysis.php
get_table_columns_ajax code-quality-analysis.php
include_db_trends db-trends.php
takeDbSnapshot db-trends.php
getDbSnapshots db-trends.php
include_unit_test_generator unit-test-generator.php
extractFunctions unit-test-generator.php
extractClasses unit-test-generator.php
generateFunctionTest unit-test-generator.php
generateClassTest unit-test-generator.php
setUp unit-test-generator.php
tearDown unit-test-generator.php
generateSampleValue unit-test-generator.php
renderUnitTestGeneratorPage unit-test-generator.php
copyToClipboard unit-test-generator.php
downloadTest unit-test-generator.php
scanDirectoryForFiles unit-test-generator.php
include_data_health data-health.php
analyzeDataHealth data-health.php
getDataHealthSummary data-health.php
include_error_log_analysis error-log-analysis.php
process_user_data error-log-analysis.php
database_connect error-log-analysis.php
format_date error-log-analysis.php
format_date error-log-analysis.php
get_user_profile error-log-analysis.php
showErrorDetails error-log-analysis.php
getAlertClass error-log-analysis.php
getSuggestedSolution error-log-analysis.php
process_user_data error-log-analysis.php
format_date error-log-analysis.php
format_date error-log-analysis.php
markErrorAsResolved error-log-analysis.php
updateChart error-log-analysis.php
include_error_logs error-log-analysis.php
include_performance performance.php
analyzePerformance performance.php
getPerformanceAnalysisSummary performance.php
include_ai_code_suggestions ai-code-suggestions.php
display_prompt_generator_tab ai-code-suggestions.php
copyPrompt ai-code-suggestions.php
downloadPrompt ai-code-suggestions.php
addSelectedFiles ai-code-suggestions.php
removeFile ai-code-suggestions.php
removeAllFiles ai-code-suggestions.php
regeneratePrompt ai-code-suggestions.php
regeneratePromptWithFiles ai-code-suggestions.php
generateBasicBrief ai-code-suggestions.php
generatePromptWithFileContext ai-code-suggestions.php
analyzeFileCode ai-code-suggestions.php
extractSectionFromBrief ai-code-suggestions.php
display_code_suggestions_tab ai-code-suggestions.php
generateDemoResponse ai-code-suggestions.php
display_ai_benefits_popup ai-code-suggestions.php
list_php_files ai-code-suggestions.php
getAllMetadata metadata.php
saveAllMetadata metadata.php
updateTableMetadata metadata.php
updateFieldMetadata metadata.php
updateRelationshipMetadata metadata.php
updateCodeMetadata metadata.php
updateWorkflowMetadata metadata.php
updateApiMetadata metadata.php
updateUserRoleMetadata metadata.php
updateDataTypeMetadata metadata.php
deleteMetadataItem metadata.php
getMetadataCounts metadata.php
exportMetadataToJson metadata.php
importMetadataFromJson metadata.php
generateComprehensiveAIBrief metadata.php
include_advanced_metadata metadata.php
copyEnhancedBrief metadata.php
include_code_quality_analysis code-quality-analysis.php
foreach code-quality-analysis.php
extractFunctions code-quality-analysis.php
calculateComplexity code-quality-analysis.php
checkCodeStyle code-quality-analysis.php
findUnusedCode code-quality-analysis.php
findDuplicatedCode code-quality-analysis.php
renderCodeQualityAnalysisPage code-quality-analysis.php
scanDirectoryForFiles code-quality-analysis.php
get_table_columns_ajax code-quality-analysis.php
include_relationships relationships.php
analyzeTableRelationships relationships.php
include_add_relationships add-relationships.php
loadColumns add-relationships.php
addMessage setup-prompt-generator.php
getMessages setup-prompt-generator.php
hasErrors setup-prompt-generator.php
createDirectory setup-prompt-generator.php
writeFile setup-prompt-generator.php
checkPermissions setup-prompt-generator.php
backupFile setup-prompt-generator.php
insertIntoFile setup-prompt-generator.php
contentExists setup-prompt-generator.php
generateProjectPrompt setup-prompt-generator.php
extractProjectInfo setup-prompt-generator.php
extractTechStack setup-prompt-generator.php
extractDatabaseInfo setup-prompt-generator.php
extractFileStructure setup-prompt-generator.php
extractDataFlow setup-prompt-generator.php
buildPrompt setup-prompt-generator.php
displayPromptPage setup-prompt-generator.php
copyPrompt setup-prompt-generator.php
downloadPrompt setup-prompt-generator.php
safe_require_once index2.php
copyBrief index2.php
include_db_setup index2.php
include_user_settings index2.php
include_overview index2.php
include_database index2.php
include_files index2.php
get_table_columns_ajax index2.php
asset setup.php
isAuthenticated setup.php
generateBrief setup.php
renderRelationships setup.php
checkSecurity setup.php
optimizePerformance setup.php
assessDataHealth setup.php
generateEnhancedBrief setup.php
safe_require_once index.php
include_overview index.php
copyBrief index.php
preventDefaults index.php
highlight index.php
unhighlight index.php
handleDrop index.php
include_code_analyzer_fallback index.php
performCodeAnalysis index.php
getLanguageIcon index.php
getSeverityColor index.php
getStatusColor index.php
getPrismLanguage index.php
formatBytes index.php
is_associative index.php
connectToDatabase database.php
db_getDatabaseTables database.php
db_getTableColumns database.php
db_getRowCount database.php
db_getTableRelationships database.php
getDatabaseTables database.php
getTableColumns database.php
getRowCount database.php
getTableRelationships database.php
Classes (13)
Class Name File Methods Action
LanguageDetector language_detector.php 0
CssAnalyzer css_analyzer.php 1
JavascriptAnalyzer js_analyzer.php 1
AbstractAnalyzer base_analyzer.php 1
AnalyzerFactory base_analyzer.php 0
AngularAnalyzer anguler_analyzer.php 1
PhpAnalyzer php_analyzer.php 1
TypescriptAnalyzer typescript_analyzer.php 1
ReactAnalyzer react_analyzer.php 1
HtmlAnalyzer html_analyzer.php 0
PythonAnalyzer python_analyzer.php 1
CsharpAnalyzer csharp_analyzer.php 1
SetupHelper setup-prompt-generator.php 1
Generated Test
Select a function or class from the left to generate a test.
PHPUnit Setup Guide

To run the generated tests, you need to set up PHPUnit in your project:

  1. Install PHPUnit via Composer:
  2. composer require --dev phpunit/phpunit
  3. Create a PHPUnit configuration file (phpunit.xml) in your project root:
  4. <?xml version="1.0" encoding="UTF-8"?>
    <phpunit bootstrap="vendor/autoload.php"
             colors="true"
             verbose="true">
        <testsuites>
            <testsuite name="Project Test Suite">
                <directory>tests/</directory>
            </testsuite>
        </testsuites>
        <filter>
            <whitelist>
                <directory suffix=".php">src/</directory>
                <exclude>
                    <directory>vendor/</directory>
                </exclude>
            </whitelist>
        </filter>
    </phpunit>
  5. Create a tests directory if it doesn't exist:
  6. mkdir -p tests
  7. Save generated tests to the tests directory
  8. Run tests using:
  9. ./vendor/bin/phpunit