mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-14 19:08:25 +00:00
build: add CakePHP2 tests bootstrap files
This commit is contained in:
parent
5f504f1cff
commit
72079a54e6
3 changed files with 73 additions and 0 deletions
29
lib/Cake/Test/bootstrap.php
Normal file
29
lib/Cake/Test/bootstrap.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* Bootstrap for phpunit command
|
||||
*/
|
||||
|
||||
if (!defined('DS')) {
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
}
|
||||
require_once __DIR__ . DS . 'bootstrap' . DS . 'cake_dot_php.php';
|
||||
|
||||
/*
|
||||
* loading of lib/Cake/TestSuite/CakeTestSuiteDispatcher.php
|
||||
* In bootstrap.php, it is sufficient if the const(s) are defined outside the class of CakeTestSuiteDispatcher.php.
|
||||
* However, when loading CakeTestSuiteDispatcher.php in the unit test, a double definition of const(s) error occurs,
|
||||
* so load it here.
|
||||
*/
|
||||
App::uses('CakeTestSuiteDispatcher', 'TestSuite');
|
||||
App::load('CakeTestSuiteDispatcher');
|
||||
|
||||
/*
|
||||
* Classes that can be used without declaring App::uses()
|
||||
*/
|
||||
App::uses('ClassRegistry', 'Utility');
|
||||
App::uses('CakeTestCase', 'TestSuite');
|
||||
App::uses('CakeTestSuite', 'TestSuite');
|
||||
App::uses('ControllerTestCase', 'TestSuite');
|
||||
App::uses('CakeTestModel', 'TestSuite/Fixture');
|
||||
|
||||
set_error_handler(new \PHPUnit\Util\ErrorHandler(true, true, true, true));
|
43
lib/Cake/Test/bootstrap/cake_dot_php.php
Normal file
43
lib/Cake/Test/bootstrap/cake_dot_php.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* lib/Cake/Console/cake.php initialize
|
||||
*/
|
||||
|
||||
if (!defined('DS')) {
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php';
|
||||
$found = false;
|
||||
$paths = explode(PATH_SEPARATOR, ini_get('include_path'));
|
||||
|
||||
foreach ($paths as $path) {
|
||||
if (file_exists($path . DS . $dispatcher)) {
|
||||
$found = $path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$rootInstall = dirname(dirname(dirname(dirname(__FILE__)))) . DS . $dispatcher;
|
||||
$composerInstall = dirname(dirname(dirname(__FILE__))) . DS . $dispatcher;
|
||||
|
||||
if (file_exists($composerInstall)) {
|
||||
include $composerInstall;
|
||||
} elseif (file_exists($rootInstall)) {
|
||||
include $rootInstall;
|
||||
} else {
|
||||
trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
|
||||
}
|
||||
unset($rootInstall, $composerInstall);
|
||||
|
||||
} else {
|
||||
include $found . DS . $dispatcher;
|
||||
}
|
||||
|
||||
// In lib/Cake/Console/cake makes app root path.
|
||||
$appPath = dirname(__DIR__, 4) . DS . 'app';
|
||||
|
||||
new ShellDispatcher([$_SERVER['argv'][0], '-working', $appPath]);
|
||||
|
||||
unset($paths, $path, $found, $dispatcher, $appPath);
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
|
||||
bootstrap="lib/Cake/Test/bootstrap.php"
|
||||
backupGlobals="true"
|
||||
colors="true">
|
||||
<php>
|
||||
|
|
Loading…
Reference in a new issue