| [ Index ] |
PHP Cross Reference of YOURLS |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * YOURLS Unit Test. No, I don't know what I'm doing. 4 */ 5 6 // Globalize some YOURLS variables because PHPUnit loads this inside a function 7 // See https://github.com/sebastianbergmann/phpunit/issues/325 8 // This has to be done before including any file 9 global $yourls_user_passwords, $yourls_reserved_URL, // main object & config file 10 $yourls_filters, $yourls_actions, // used by plugin API 11 $yourls_locale, $yourls_l10n, $yourls_locale_formats, // used by L10N API 12 $yourls_allowedentitynames, $yourls_allowedprotocols; // used by KSES 13 14 require_once __DIR__ . '/includes/utils.php'; 15 require_once __DIR__ . '/includes/install.php'; 16 17 // Include relevant config file 18 define('YOURLS_CONFIGFILE', yut_find_config()); 19 echo "Using config file: " . YOURLS_CONFIGFILE . "\n"; 20 require_once YOURLS_CONFIGFILE; 21 22 // Bootstrap YOURLS 23 require_once YOURLS_ABSPATH . '/includes/vendor/autoload.php'; 24 define('YOURLS_TESTDATA_DIR', __DIR__ . '/data'); 25 define('YOURLS_LANG_DIR', YOURLS_TESTDATA_DIR.'/pomo'); 26 define('YOURLS_PLUGINDIR', YOURLS_TESTDATA_DIR.'/plugins'); 27 define('YOURLS_PAGEDIR', YOURLS_TESTDATA_DIR.'/pages'); 28 $config = new \YOURLS\Config\Config(YOURLS_CONFIGFILE); 29 $config->define_core_constants(); 30 31 // Define YOURLS actions upon new instance 32 $init = new \YOURLS\Config\InitDefaults; 33 $init->check_maintenance_mode = false; 34 $init->fix_request_uri = false; 35 $init->redirect_ssl = false; 36 $init->redirect_to_install = false; 37 $init->check_if_upgrade_needed = false; 38 $init->load_plugins = false; // do not attempt to load (no DB yet to store data), but do send the 'plugins_loaded' action (some code depend on it) 39 $init->get_all_options = false; 40 $init->check_new_version = false; 41 new \YOURLS\Config\Init($init); 42 43 // Mark as 'installing' to avoid flood checks 44 yourls_add_filter( 'is_installing', 'yourls_return_true' ); 45 46 // All set -- install 47 yut_install_yourls(); 48 49 // Unmark as 'installing' to allow normal execution of code 50 yourls_remove_filter( 'is_installing', 'yourls_return_true' ); 51 52 // All set -- instantiate the rest 53 yourls_get_all_options(); 54 yourls_load_plugins(); 55 56 // At this point, tests will start 57 58 // Simplify yourls_die() when running unit tests 59 yourls_add_action( 'pre_yourls_die', function($params) { 60 printf("\n\nCalling yourls_die(). %s : %s (%s)\n\n", $params[1], $params[0], $params[2]); 61 echo "Last 10 Backtrace:\n"; 62 $trace = debug_backtrace(); 63 foreach( array_slice($trace, 0, 10) as $t ) { 64 printf("** %s:%d %s() with args\n%s\n", $t['file'], $t['line'], $t['function'], var_export($t['args'], true)); 65 } 66 67 die(1); 68 } ); 69 70 echo "YOURLS installed, starting PHPUnit\n\n"; 71 72 require_once __DIR__ . "/tests/auth/AbstractLoginTestCase.php"; 73 require_once __DIR__ . "/tests/auth/LoginAssertionTrait.php";
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sun Jul 12 05:10:03 2026 | Cross-referenced by PHPXref 0.7.1 |