dolibarr/test/phpunit/AllTests.php

256 lines
9.9 KiB
PHP
Raw Normal View History

2010-04-25 16:19:58 +02:00
<?php
2015-01-06 17:54:36 +01:00
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011-2012 Regis Houssin <regis.houssin@capnetworks.com>
2010-04-27 01:52:51 +02:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
2010-04-27 01:52:51 +02:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2011-12-17 21:58:44 +01:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
2010-04-27 01:52:51 +02:00
*/
/**
2011-02-13 11:25:13 +01:00
* \file test/phpunit/AllTest.php
2015-01-06 17:54:36 +01:00
* \ingroup test
2010-04-27 01:52:51 +02:00
* \brief This file is a test suite to run all unit tests
2015-01-06 17:54:36 +01:00
* \remarks To run this script as CLI: phpunit filename.php
2010-04-27 01:52:51 +02:00
*/
2010-04-27 11:05:42 +02:00
print "PHP Version: ".phpversion()."\n";
print "Memory: ". ini_get('memory_limit')."\n";
2010-04-27 01:20:14 +02:00
global $conf,$user,$langs,$db;
2015-01-06 17:54:36 +01:00
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
//require_once 'PHPUnit/Autoload.php';
2010-08-16 01:19:46 +02:00
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
2015-12-18 21:56:00 +01:00
print 'DOL_MAIN_URL_ROOT='.DOL_MAIN_URL_ROOT."\n"; // constant will be used by other tests
2015-04-19 04:43:28 +02:00
if ($langs->defaultlang != 'en_US')
{
print "Error: Default language for company to run tests must be set to en_US or auto. Current is ".$langs->defaultlang."\n";
Better Travis CI NEW: Cleaned up routines for better readability of both declaration and results. PHP versions now really covered. The old code forced install of PHP and didn't use Travis provided versions. This resulted in the process not being executed with the declared PHP version. Dropped MySQL in favor of MariaDB. This is now the FLOSS community standard. This should help avoid problems with buggy MySQL releases. Fast finish enabled to show results faster. Optimized tools installation with composer. The right version of the tool is installed for the PHP version under test. New PHP linter to check for syntax errors. Parallelized for better speed. Apache + PHP FPM for testing webservices. The previous mod_php configuration was not supported on Travis. New global DEBUG environment variable to show verbose output with configuration files content. IRC notification on #dolibarr@freenode for community awareness. FIXES: Bug in scripts preventing execution with environmentalized PHP. Wrong detection of MAIN_URL_ROOT under specific circumstances. $_SERVER["DOCUMENT_ROOT"] empty and $_SERVER["SCRIPT_NAME"] populated. Relative ignore directive in coding style ruleset to avoid bypassing test. Unit test errors without an exit status. This prevented the CI from properly detecting and reporting the error. TODOS: PostgreSQL support. This one is tricky since we only have a MySQL dump and the syntax is not directly compatible. SQLite support. Disabled in core at the moment. Nginx + PHP FPM support. Test webservices on the second most popular webserver. Run dev/* checks. We have a nice collection of scripts we could leverage. Check Javascript. Check CSS. Check SQL.
2015-12-11 05:08:32 +01:00
exit(1);
}
if (empty($conf->adherent->enabled))
{
Better Travis CI NEW: Cleaned up routines for better readability of both declaration and results. PHP versions now really covered. The old code forced install of PHP and didn't use Travis provided versions. This resulted in the process not being executed with the declared PHP version. Dropped MySQL in favor of MariaDB. This is now the FLOSS community standard. This should help avoid problems with buggy MySQL releases. Fast finish enabled to show results faster. Optimized tools installation with composer. The right version of the tool is installed for the PHP version under test. New PHP linter to check for syntax errors. Parallelized for better speed. Apache + PHP FPM for testing webservices. The previous mod_php configuration was not supported on Travis. New global DEBUG environment variable to show verbose output with configuration files content. IRC notification on #dolibarr@freenode for community awareness. FIXES: Bug in scripts preventing execution with environmentalized PHP. Wrong detection of MAIN_URL_ROOT under specific circumstances. $_SERVER["DOCUMENT_ROOT"] empty and $_SERVER["SCRIPT_NAME"] populated. Relative ignore directive in coding style ruleset to avoid bypassing test. Unit test errors without an exit status. This prevented the CI from properly detecting and reporting the error. TODOS: PostgreSQL support. This one is tricky since we only have a MySQL dump and the syntax is not directly compatible. SQLite support. Disabled in core at the moment. Nginx + PHP FPM support. Test webservices on the second most popular webserver. Run dev/* checks. We have a nice collection of scripts we could leverage. Check Javascript. Check CSS. Check SQL.
2015-12-11 05:08:32 +01:00
print "Error: Module member must be enabled to have significant results.\n";
exit(1);
}
if (! empty($conf->ldap->enabled))
{
print "Error: LDAP module should not be enabled.\n";
Better Travis CI NEW: Cleaned up routines for better readability of both declaration and results. PHP versions now really covered. The old code forced install of PHP and didn't use Travis provided versions. This resulted in the process not being executed with the declared PHP version. Dropped MySQL in favor of MariaDB. This is now the FLOSS community standard. This should help avoid problems with buggy MySQL releases. Fast finish enabled to show results faster. Optimized tools installation with composer. The right version of the tool is installed for the PHP version under test. New PHP linter to check for syntax errors. Parallelized for better speed. Apache + PHP FPM for testing webservices. The previous mod_php configuration was not supported on Travis. New global DEBUG environment variable to show verbose output with configuration files content. IRC notification on #dolibarr@freenode for community awareness. FIXES: Bug in scripts preventing execution with environmentalized PHP. Wrong detection of MAIN_URL_ROOT under specific circumstances. $_SERVER["DOCUMENT_ROOT"] empty and $_SERVER["SCRIPT_NAME"] populated. Relative ignore directive in coding style ruleset to avoid bypassing test. Unit test errors without an exit status. This prevented the CI from properly detecting and reporting the error. TODOS: PostgreSQL support. This one is tricky since we only have a MySQL dump and the syntax is not directly compatible. SQLite support. Disabled in core at the moment. Nginx + PHP FPM support. Test webservices on the second most popular webserver. Run dev/* checks. We have a nice collection of scripts we could leverage. Check Javascript. Check CSS. Check SQL.
2015-12-11 05:08:32 +01:00
exit(1);
}
if (! empty($conf->google->enabled))
{
2015-01-06 17:54:36 +01:00
print "Warning: Google module should not be enabled.\n";
}
if (empty($user->id))
{
2015-01-06 17:54:36 +01:00
print "Load permissions for admin user nb 1\n";
$user->fetch(1);
$user->getrights();
2010-04-27 01:52:51 +02:00
}
2010-07-15 01:10:56 +02:00
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
2010-04-25 16:19:58 +02:00
2010-04-27 01:20:14 +02:00
/**
* Class for the All test suite
*/
2011-02-13 11:25:13 +01:00
class AllTests
2010-04-27 01:20:14 +02:00
{
2011-10-05 14:29:16 +02:00
/**
* Function suite to make all PHPUnit tests
*
* @return void
*/
2015-01-06 17:54:36 +01:00
public static function suite()
2010-04-25 16:19:58 +02:00
{
2015-01-06 17:54:36 +01:00
$suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework');
2010-04-25 16:19:58 +02:00
//require_once dirname(__FILE__).'/CoreTest.php';
//$suite->addTestSuite('CoreTest');
2015-01-06 17:54:36 +01:00
require_once dirname(__FILE__).'/AdminLibTest.php';
$suite->addTestSuite('AdminLibTest');
require_once dirname(__FILE__).'/CompanyLibTest.php';
$suite->addTestSuite('CompanyLibTest');
2015-01-06 17:54:36 +01:00
require_once dirname(__FILE__).'/DateLibTest.php';
$suite->addTestSuite('DateLibTest');
require_once dirname(__FILE__).'/UtilsTest.php';
$suite->addTestSuite('UtilsTest');
2015-01-06 17:54:36 +01:00
//require_once dirname(__FILE__).'/DateLibTzFranceTest.php';
//$suite->addTestSuite('DateLibTzFranceTest');
require_once dirname(__FILE__).'/MarginsLibTest.php';
$suite->addTestSuite('MarginsLibTest');
require_once dirname(__FILE__).'/FilesLibTest.php';
$suite->addTestSuite('FilesLibTest');
require_once dirname(__FILE__).'/GetUrlLibTest.php';
$suite->addTestSuite('GetUrlLibTest');
2015-01-06 17:54:36 +01:00
require_once dirname(__FILE__).'/JsonLibTest.php';
$suite->addTestSuite('JsonLibTest');
require_once dirname(__FILE__).'/ImagesLibTest.php';
$suite->addTestSuite('ImagesLibTest');
require_once dirname(__FILE__).'/FunctionsLibTest.php';
$suite->addTestSuite('FunctionsLibTest');
require_once dirname(__FILE__).'/Functions2LibTest.php';
$suite->addTestSuite('Functions2LibTest');
require_once dirname(__FILE__).'/XCalLibTest.php';
$suite->addTestSuite('XCalLibTest');
// Rules into source files content
2015-01-06 17:54:36 +01:00
require_once dirname(__FILE__).'/LangTest.php';
$suite->addTestSuite('LangTest');
require_once dirname(__FILE__).'/CodingSqlTest.php';
$suite->addTestSuite('CodingSqlTest');
require_once dirname(__FILE__).'/CodingPhpTest.php';
2017-05-12 20:01:45 +02:00
$suite->addTestSuite('CodingPhpTest');
2010-11-22 10:29:29 +01:00
require_once dirname(__FILE__).'/SecurityTest.php';
$suite->addTestSuite('SecurityTest');
2017-10-22 13:05:47 +02:00
require_once dirname(__FILE__).'/UserTest.php';
$suite->addTestSuite('UserTest');
require_once dirname(__FILE__).'/UserGroupTest.php';
$suite->addTestSuite('UserGroupTest');
require_once dirname(__FILE__).'/NumberingModulesTest.php';
$suite->addTestSuite('NumberingModulesTest');
require_once dirname(__FILE__).'/PgsqlTest.php';
$suite->addTestSuite('PgsqlTest');
2015-01-06 17:54:36 +01:00
require_once dirname(__FILE__).'/PdfDocTest.php';
$suite->addTestSuite('PdfDocTest');
2010-05-08 20:38:17 +02:00
require_once dirname(__FILE__).'/BuildDocTest.php';
$suite->addTestSuite('BuildDocTest');
2011-05-01 11:38:38 +02:00
require_once dirname(__FILE__).'/CMailFileTest.php';
$suite->addTestSuite('CMailFileTest');
2010-05-06 21:18:48 +02:00
require_once dirname(__FILE__).'/CommonObjectTest.php';
2010-05-06 00:41:54 +02:00
$suite->addTestSuite('CommonObjectTest');
2010-05-05 20:08:42 +02:00
2018-06-07 13:07:15 +02:00
require_once dirname(__FILE__).'/ActionCommTest.php';
2018-06-13 19:57:25 +02:00
$suite->addTestSuite('ActionCommTest');
2010-10-13 21:01:22 +02:00
require_once dirname(__FILE__).'/SocieteTest.php';
$suite->addTestSuite('SocieteTest');
2011-12-30 14:18:19 +01:00
require_once dirname(__FILE__).'/ContactTest.php';
$suite->addTestSuite('ContactTest');
2010-05-05 20:08:42 +02:00
require_once dirname(__FILE__).'/AdherentTest.php';
2010-04-27 13:21:34 +02:00
$suite->addTestSuite('AdherentTest');
2010-10-13 21:01:22 +02:00
2011-10-01 01:40:15 +02:00
require_once dirname(__FILE__).'/ProductTest.php';
$suite->addTestSuite('ProductTest');
2012-01-11 13:07:02 +01:00
require_once dirname(__FILE__).'/PricesTest.php';
$suite->addTestSuite('PricesTest');
require_once dirname(__FILE__).'/DiscountTest.php';
$suite->addTestSuite('DiscountTest');
require_once dirname(__FILE__).'/ContratTest.php';
$suite->addTestSuite('ContratTest');
2014-09-24 01:36:12 +02:00
require_once dirname(__FILE__).'/FichinterTest.php';
$suite->addTestSuite('FichinterTest');
require_once dirname(__FILE__).'/TicketTest.php';
$suite->addTestSuite('TicketTest');
require_once dirname(__FILE__).'/PropalTest.php';
$suite->addTestSuite('PropalTest');
2017-10-22 13:05:47 +02:00
require_once dirname(__FILE__).'/SupplierProposalTest.php';
$suite->addTestSuite('SupplierProposalTest');
2010-10-13 21:01:22 +02:00
require_once dirname(__FILE__).'/CommandeTest.php';
2010-04-27 13:21:34 +02:00
$suite->addTestSuite('CommandeTest');
2012-12-03 11:24:30 +01:00
require_once dirname(__FILE__).'/CommandeFournisseurTest.php';
$suite->addTestSuite('CommandeFournisseurTest');
2012-12-03 11:24:30 +01:00
2010-04-27 13:21:34 +02:00
require_once dirname(__FILE__).'/FactureTest.php';
$suite->addTestSuite('FactureTest');
require_once dirname(__FILE__).'/FactureRecTest.php';
$suite->addTestSuite('FactureRecTest');
require_once dirname(__FILE__).'/FactureTestRounding.php';
$suite->addTestSuite('FactureTestRounding');
2010-10-03 20:53:40 +02:00
require_once dirname(__FILE__).'/FactureFournisseurTest.php';
$suite->addTestSuite('FactureFournisseurTest');
2012-07-02 19:30:37 +02:00
require_once dirname(__FILE__).'/BankAccountTest.php';
2012-06-20 22:19:03 +02:00
$suite->addTestSuite('BankAccountTest');
2015-01-06 17:54:36 +01:00
require_once dirname(__FILE__).'/CompanyBankAccountTest.php';
2010-06-06 20:47:34 +02:00
$suite->addTestSuite('CompanyBankAccountTest');
require_once dirname(__FILE__).'/BonPrelevementTest.php';
$suite->addTestSuite('BonPrelevementTest');
require_once dirname(__FILE__).'/ChargeSocialesTest.php';
$suite->addTestSuite('ChargeSocialesTest');
require_once dirname(__FILE__).'/HolidayTest.php';
$suite->addTestSuite('HolidayTest');
2017-04-14 16:50:30 +02:00
require_once dirname(__FILE__).'/ExpenseReportTest.php';
$suite->addTestSuite('ExpenseReportTest');
2018-09-20 23:41:04 +02:00
require_once dirname(__FILE__).'/LoanTest.php';
$suite->addTestSuite('LoanTest');
2014-03-17 15:01:47 +01:00
require_once dirname(__FILE__).'/EntrepotTest.php';
$suite->addTestSuite('EntrepotTest');
require_once dirname(__FILE__).'/MouvementStockTest.php';
$suite->addTestSuite('MouvementStockTest');
2010-05-08 20:38:17 +02:00
2010-10-23 19:36:02 +02:00
require_once dirname(__FILE__).'/CategorieTest.php';
$suite->addTestSuite('CategorieTest');
2018-05-18 11:17:33 +02:00
require_once dirname(__FILE__).'/AccountingAccountTest.php';
$suite->addTestSuite('AccountingAccountTest');
require_once dirname(__FILE__).'/RestAPIUserTest.php';
$suite->addTestSuite('RestAPIUserTest');
2017-11-17 17:15:23 +01:00
// Test only with php7.2 or less
2017-11-17 18:32:37 +01:00
//if ((float) phpversion() < 7.3)
//{
2017-11-17 17:11:35 +01:00
require_once dirname(__FILE__).'/WebservicesProductsTest.php';
$suite->addTestSuite('WebservicesProductsTest');
require_once dirname(__FILE__).'/WebservicesInvoicesTest.php';
$suite->addTestSuite('WebservicesInvoicesTest');
require_once dirname(__FILE__).'/WebservicesOrdersTest.php';
$suite->addTestSuite('WebservicesOrdersTest');
require_once dirname(__FILE__).'/WebservicesOtherTest.php';
$suite->addTestSuite('WebservicesOtherTest');
require_once dirname(__FILE__).'/WebservicesThirdpartyTest.php';
$suite->addTestSuite('WebservicesThirdpartyTest');
require_once dirname(__FILE__).'/WebservicesUserTest.php';
$suite->addTestSuite('WebservicesUserTest');
2017-11-17 18:32:37 +01:00
//}
2011-09-10 14:28:00 +02:00
require_once dirname(__FILE__).'/ExportTest.php';
$suite->addTestSuite('ExportTest');
require_once dirname(__FILE__).'/ImportTest.php';
$suite->addTestSuite('ImportTest');
require_once dirname(__FILE__).'/ScriptsTest.php';
$suite->addTestSuite('ScriptsTest');
require_once dirname(__FILE__).'/FormAdminTest.php';
$suite->addTestSuite('FormAdminTest');
2011-05-01 11:38:38 +02:00
require_once dirname(__FILE__).'/ModulesTest.php'; // At end because it's the longer
2010-10-13 21:01:22 +02:00
$suite->addTestSuite('ModulesTest');
// GUI
require_once dirname(__FILE__).'/FormAdminTest.php';
2015-01-06 17:54:36 +01:00
$suite->addTestSuite('FormAdminTest');
2010-04-27 01:20:14 +02:00
return $suite;
2010-04-25 16:19:58 +02:00
}
}
2010-04-27 01:20:14 +02:00