build: add CakePHP2 tests bootstrap files

This commit is contained in:
Koji Tanaka 2022-12-28 15:25:04 +09:00 committed by Kamil Wylegala
parent 5f504f1cff
commit 72079a54e6
3 changed files with 73 additions and 0 deletions

View 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));

View 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);

View file

@ -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>