[ 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 require_once YOURLS_CONFIGFILE; 20 21 // Bootstrap YOURLS 22 require_once YOURLS_ABSPATH . '/includes/vendor/autoload.php'; 23 define('YOURLS_TESTDATA_DIR', __DIR__ . '/data'); 24 define('YOURLS_LANG_DIR', YOURLS_TESTDATA_DIR.'/pomo'); 25 define('YOURLS_PLUGINDIR', YOURLS_TESTDATA_DIR.'/plugins'); 26 define('YOURLS_PAGEDIR', YOURLS_TESTDATA_DIR.'/pages'); 27 $config = new \YOURLS\Config\Config(YOURLS_CONFIGFILE); 28 $config->define_core_constants(); 29 30 // Define YOURLS actions upon new instance 31 $init = new \YOURLS\Config\InitDefaults; 32 $init->check_maintenance_mode = false; 33 $init->fix_request_uri = false; 34 $init->redirect_ssl = false; 35 $init->redirect_to_install = false; 36 $init->check_if_upgrade_needed = false; 37 $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) 38 $init->get_all_options = false; 39 $init->check_new_version = false; 40 new \YOURLS\Config\Init($init); 41 42 // All set -- install 43 yut_install_yourls(); 44 45 // All set -- instantiate the rest 46 yourls_get_all_options(); 47 yourls_load_plugins(); 48 49 // At this point, tests will start 50 51 // Simplify yourls_die() when running unit tests 52 yourls_add_action( 'pre_yourls_die', function($params) { 53 printf("\n\nCalling yourls_die(). %s : %s (%s)\n\n", $params[1], $params[0], $params[2]); 54 echo "Last 10 Backtrace:\n"; 55 $trace = debug_backtrace(); 56 foreach( array_slice($trace, 0, 10) as $t ) { 57 printf("** %s:%d %s() with args\n%s\n", $t['file'], $t['line'], $t['function'], var_export($t['args'], true)); 58 } 59 60 die(1); 61 } ); 62 63 echo "YOURLS installed, starting PHPUnit\n\n"; 64 65 require_once __DIR__ . "/tests/auth/AbstractLoginTestCase.php"; 66 require_once __DIR__ . "/tests/auth/LoginAssertionTrait.php";
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Mar 28 05:10:25 2025 | Cross-referenced by PHPXref 0.7.1 |