-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathrun-tests.php
More file actions
executable file
·71 lines (58 loc) · 1.98 KB
/
run-tests.php
File metadata and controls
executable file
·71 lines (58 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env php
<?php
/**
* Test runner script for FluentAuth plugin
*/
if (PHP_SAPI !== 'cli') {
echo "This script must be run from the command line\n";
exit(1);
}
echo "FluentAuth Plugin Test Runner\n";
echo "=============================\n\n";
// Check if composer is installed
if (!file_exists('tests/vendor/autoload.php')) {
echo "Error: Composer dependencies not found.\n";
echo "Please run: composer install --dev\n";
exit(1);
}
// Load composer autoloader
require_once 'tests/vendor/autoload.php';
// Check if PHPUnit is available
if (!class_exists('PHPUnit\TextUI\Command')) {
echo "Error: PHPUnit not found.\n";
echo "Please install PHPUnit via composer:\n";
echo "composer require --dev phpunit/phpunit\n";
exit(1);
}
// Set up environment
define('WP_TESTS_DIR', getenv('WP_TESTS_DIR') ?: __DIR__ . '/tests/vendor/wordpress-tests-lib');
define('WP_CORE_DIR', getenv('WP_CORE_DIR') ?: __DIR__ . '/tests/vendor/wordpress/');
// Check if WordPress test suite is available
if (!file_exists(WP_TESTS_DIR . '/includes/bootstrap.php')) {
echo "Warning: WordPress test suite not found.\n";
echo "Some tests may not work properly without WordPress test environment.\n";
echo "To install WordPress test suite, see: https://make.wordpress.org/core/handbook/testing/automated-testing/running-phpunit-tests/\n\n";
}
// Create test directory if it doesn't exist
if (!file_exists('tests')) {
mkdir('tests', 0755, true);
echo "Created tests directory.\n";
}
// Run the tests
echo "Running test suite...\n\n";
$command = new PHPUnit\TextUI\Command();
try {
$exitCode = $command->run([
'phpunit',
'--configuration', 'phpunit.xml',
'--colors',
'--verbose',
'--bootstrap', 'tests/bootstrap.php',
'tests'
], false);
echo "\nTest suite completed with exit code: $exitCode\n";
exit($exitCode);
} catch (Exception $e) {
echo "Error running tests: " . $e->getMessage() . "\n";
exit(1);
}