2015-06-25 17:00:29 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Global setup for unit tests
|
|
|
|
*/
|
2016-01-06 15:44:40 -05:00
|
|
|
|
|
|
|
use Aviat\AnimeClient\AnimeClient;
|
|
|
|
|
2015-06-25 17:00:29 -04:00
|
|
|
// -----------------------------------------------------------------------------
|
2016-01-06 15:44:40 -05:00
|
|
|
// Global functions
|
2015-06-25 17:00:29 -04:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2015-09-14 10:54:50 -04:00
|
|
|
/**
|
|
|
|
* Joins paths together. Variadic to take an
|
|
|
|
* arbitrary number of arguments
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function _dir()
|
|
|
|
{
|
|
|
|
return implode(DIRECTORY_SEPARATOR, func_get_args());
|
|
|
|
}
|
|
|
|
|
2016-01-06 15:44:40 -05:00
|
|
|
/**
|
|
|
|
* Decode a json file into a php data structure
|
|
|
|
*
|
|
|
|
* @param string $file
|
|
|
|
* @param bool $as_array
|
|
|
|
* @return array|object
|
|
|
|
*/
|
|
|
|
function json_file_decode($file, $as_array=TRUE)
|
|
|
|
{
|
|
|
|
return AnimeClient::json_file_decode($file, $as_array);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Autoloading
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
require _dir(__DIR__, 'AnimeClient_TestCase.php');
|
|
|
|
|
2015-09-17 23:11:18 -04:00
|
|
|
// Define base path constants
|
2016-01-06 15:44:40 -05:00
|
|
|
require _dir(__DIR__, '../vendor/autoload.php');
|
2015-09-14 10:54:50 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set up autoloaders
|
|
|
|
*
|
|
|
|
* @codeCoverageIgnore
|
|
|
|
* @return void
|
|
|
|
*/
|
2015-09-17 23:11:18 -04:00
|
|
|
spl_autoload_register(function ($class) {
|
|
|
|
$class_parts = explode('\\', $class);
|
2016-01-06 15:44:40 -05:00
|
|
|
$ns_path = AnimeClient_TestCase::SRC_DIR . '/' . implode('/', $class_parts) . ".php";
|
2015-06-25 17:00:29 -04:00
|
|
|
|
2015-09-17 23:11:18 -04:00
|
|
|
if (file_exists($ns_path))
|
|
|
|
{
|
|
|
|
require_once($ns_path);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
2016-01-06 15:44:40 -05:00
|
|
|
|
2015-10-09 14:34:55 -04:00
|
|
|
// -----------------------------------------------------------------------------
|
2015-10-19 12:50:46 -04:00
|
|
|
// Ini Settings
|
2015-10-09 14:34:55 -04:00
|
|
|
// -----------------------------------------------------------------------------
|
2015-10-19 12:50:46 -04:00
|
|
|
ini_set('session.use_cookies', 0);
|
|
|
|
ini_set("session.use_only_cookies",0);
|
|
|
|
ini_set("session.use_trans_sid",1);
|
|
|
|
// Start session here to supress error about headers not sent
|
2016-01-06 15:44:40 -05:00
|
|
|
session_start();
|
2015-10-09 14:34:55 -04:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2015-10-19 12:50:46 -04:00
|
|
|
// Load base test case and mocks
|
2015-10-09 14:34:55 -04:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2015-10-19 12:50:46 -04:00
|
|
|
// Pre-define some superglobals
|
|
|
|
$_SESSION = [];
|
|
|
|
$_COOKIE = [];
|
2015-10-09 14:34:55 -04:00
|
|
|
|
2015-10-19 12:50:46 -04:00
|
|
|
// Request base test case and mocks
|
|
|
|
require _dir(__DIR__, 'TestSessionHandler.php');
|
|
|
|
require _dir(__DIR__, 'mocks.php');
|
2015-10-09 14:34:55 -04:00
|
|
|
|
|
|
|
// End of bootstrap.php
|