-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
phpunit config #1
Comments
example phpunit.xml.dist from another project: <?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="Test/bootstrap.php"
colors="true"
cacheResult="false"
executionOrder="depends,defects"
forceCoversAnnotation="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory>Test/Case</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="CakeFixtureInjector" file="Vendor/kba-team/cakephp/lib/Cake/TestSuite/Fixture/CakeFixtureInjector.php"/>
</listeners>
</phpunit> example bootstrap.php <?php
/**
* Web Access Frontend for TestSuite
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html
* @package app.webroot
* @since CakePHP(tm) v 1.2.0.4433
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
set_time_limit(0);
ini_set('display_errors', 1);
//ini_set('memory_limit', "2048M"); //2GB for Psalm.
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
if (!defined('ROOT')) {
define('ROOT', dirname(dirname(dirname(__FILE__))));
}
if (!defined('APP_DIR')) {
define('APP_DIR', basename(dirname(dirname(__FILE__))));
}
if (!defined('APP')) {
define('APP', ROOT . DS . APP_DIR . DS);
}
if (!defined('WEBROOT_DIR')) {
//define('WEBROOT_DIR', basename(dirname(__FILE__)));
define('WEBROOT_DIR', 'webroot');
}
if (!defined('WWW_ROOT')) {
//define('WWW_ROOT', dirname(__FILE__).DS);
define('WWW_ROOT', APP . WEBROOT_DIR . DS);
}
/**
* try to get vendor directory
*/
$loaderStack = \Composer\Autoload\ClassLoader::getRegisteredLoaders();
$composerDirs = array_keys($loaderStack);
if (1 == count($composerDirs)) {
$vendorDir = array_pop($composerDirs);
} else {
throw new Exception(sprintf("Vendor directory could not be detected: %s", implode(', ', $composerDirs)));
}
/**
* try to get cakephp/cakephp package
*/
$cakephpDir = \Composer\InstalledVersions::getInstallPath("cakephp/cakephp");
// More complex case, cakephp/cakephp is replaced by another package
if (null === $cakephpDir) {
$composerInstalledJson = $vendorDir . DS . 'composer/installed.json';
$composerInstalledJsonEncoded = file_get_contents($composerInstalledJson);
if (!is_string($composerInstalledJsonEncoded)) {
throw new Exception('Could not read composer/installed.json');
}
try {
/** @var StdClass $composerInstalled */
$composerInstalled = json_decode($composerInstalledJsonEncoded, false, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
throw new Exception('Could not read composer/installed.json');
}
foreach ($composerInstalled->packages as $packageInfo) {
if (isset($packageInfo->replace->{'cakephp/cakephp'})) {
$cakephpDir = \Composer\InstalledVersions::getInstallPath($packageInfo->name);
break;
}
}
}
define('CAKE_CORE_INCLUDE_PATH', $cakephpDir . DS . 'lib');
$cakeBootstrapFile = CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php';
$failed = false;
if (file_exists($cakeBootstrapFile)) {
if (!include($cakeBootstrapFile)) {
$failed = true;
}
} else {
$failed = true;
}
if (!empty($failed)) {
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH.", E_USER_ERROR);
}
if (Configure::read('debug') < 1) {
die(__d('cake_dev', 'Debug setting does not allow access to this url.'));
}
if (!defined('BEHAT_TESTING') || !BEHAT_TESTING) {
/**
* has been handled as listener in phpunit.xml
*/
//App::uses('CakeTestSuiteDispatcher', 'TestSuite');
//App::load('CakeTestSuiteDispatcher');
//App::uses("ClassRegistry", 'Utility');
//App::uses("Security", "Utility");
//App::uses("CakeRequest", 'Network');
//App::uses("SessionComponent", "Controller/Component");
//App::uses("Controller", "Controller");
//App::uses("AppController", "Controller");
App::uses('CakeTestCase', 'TestSuite');
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: