diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2b111e41746892ad923df0bad0bd51982e1efdae..78be52c8aba3570de512c08359d12d6621810bc7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,6 +33,20 @@ test:php74_other: - bladerunner +test:php74_scenario: + image: bokeh_php74_with_chrome + services: + - localhost:5000/bokeh_mariadb_10.3 + - sthysel/nuhtml + script: + - bash scripts/ci_data_preparation.sh $MYSQL_DATABASE $MYSQL_HOST $MYSQL_ROOT_PASSWORD + - bash build_scenario.sh $MYSQL_DATABASE root $MYSQL_ROOT_PASSWORD $MYSQL_HOST + except: + - tags + tags: + - bladerunner + + test:php81_bokeh: image: bokeh_php81 services: @@ -59,3 +73,17 @@ test:php81_other: - tags tags: - bladerunner + + +test:php81_scenario: + image: bokeh_php81 + services: + - localhost:5000/bokeh_mariadb_10.3 + - sthysel/nuhtml + script: + - bash scripts/ci_data_preparation.sh $MYSQL_DATABASE $MYSQL_HOST $MYSQL_ROOT_PASSWORD + - bash build_scenario.sh $MYSQL_DATABASE root $MYSQL_ROOT_PASSWORD $MYSQL_HOST + except: + - tags + tags: + - bladerunner \ No newline at end of file diff --git a/build_bokeh.sh b/build_bokeh.sh index 3a23afe9f4a5c6fe0bd698c598a69b8063cca452..f1333658a60f588214c95d67ad09f4d9e98044bd 100644 --- a/build_bokeh.sh +++ b/build_bokeh.sh @@ -4,30 +4,9 @@ DBUSER=$2 DBPASS=$3 DBHOST=$4 -source ./update.sh -cp config.ini.default config.ini -sed -i "s/sgbd.config.host = localhost/sgbd.config.host = $DBHOST/g" config.ini -sed -i "s/sgbd.config.username =/sgbd.config.username = $DBUSER/g" config.ini -sed -i "s/sgbd.config.password =/sgbd.config.password = $DBPASS/g" config.ini -sed -i "s/sgbd.config.dbname =/sgbd.config.dbname = $DBNAME/g" config.ini -touch local.php - -php --version - -php -d display_errors=on -d error_reporting=E_ALL scripts/upgrade_db.php - -cd cosmogramme -cp config.ref.php config.php -sed -i "s/integration_server=localhost/integration_server=$DBHOST/g" config.php -sed -i "s/integration_user=root/integration_user=$DBUSER/g" config.php -sed -i "s/integration_pwd=root/integration_pwd=$DBPASS/g" config.php -sed -i "s/integration_base=opac3/integration_base=$DBNAME/g" config.php -cd .. - -export OPENSSL_CONF=/etc/ssl/ +source ./build_bokeh_config.sh $DBNAME $DBUSER $DBPASS $DBHOST EARLY_DESC=`php -r "echo version_compare(PHP_VERSION, '8.1', '>=') ? '--fail-error-with-desc' : '';"` -phpunit -c tests/phpunit_eco.xml --list-suites && phpunit -c tests/phpunit_eco.xml \ - && phpunit -c tests/phpunit.xml --list-suites $EARLY_DESC \ +phpunit -c tests/phpunit.xml --list-suites $EARLY_DESC \ && phpunit -c tests/phpunit.xml --exclude-group no-ci $EARLY_DESC diff --git a/build_bokeh_config.sh b/build_bokeh_config.sh new file mode 100644 index 0000000000000000000000000000000000000000..56ac77317fbdb09ccb36c2f4ea0d94542f5f9ab2 --- /dev/null +++ b/build_bokeh_config.sh @@ -0,0 +1,31 @@ +#!/bin/bash +DBNAME=$1 +DBUSER=$2 +DBPASS=$3 +DBHOST=$4 + +source ./update.sh +cp config.ini.default config.ini +sed -i "s/sgbd.config.host = localhost/sgbd.config.host = $DBHOST/g" config.ini +sed -i "s/sgbd.config.username =/sgbd.config.username = $DBUSER/g" config.ini +sed -i "s/sgbd.config.password =/sgbd.config.password = $DBPASS/g" config.ini +sed -i "s/sgbd.config.dbname =/sgbd.config.dbname = $DBNAME/g" config.ini +touch local.php + +php --version + +php -d display_errors=on -d error_reporting=E_ALL scripts/upgrade_db.php + +cd cosmogramme +cp config.ref.php config.php +sed -i "s/integration_server=localhost/integration_server=$DBHOST/g" config.php +sed -i "s/integration_user=root/integration_user=$DBUSER/g" config.php +sed -i "s/integration_pwd=root/integration_pwd=$DBPASS/g" config.php +sed -i "s/integration_base=opac3/integration_base=$DBNAME/g" config.php +cd .. + +export OPENSSL_CONF=/etc/ssl/ + +function earlyDesc() { + `php -r "echo version_compare(PHP_VERSION, '8.1', '>=') ? '--fail-error-with-desc' : '';"` +} diff --git a/build_other.sh b/build_other.sh index 2c28e380b6cbe028d4729000d0e132df02fa1213..8ec7a8ee952a38f246fa03ed18949966f7ddf16a 100644 --- a/build_other.sh +++ b/build_other.sh @@ -4,29 +4,19 @@ DBUSER=$2 DBPASS=$3 DBHOST=$4 -source ./update.sh -cp config.ini.default config.ini -sed -i "s/sgbd.config.host = localhost/sgbd.config.host = $DBHOST/g" config.ini -sed -i "s/sgbd.config.username =/sgbd.config.username = $DBUSER/g" config.ini -sed -i "s/sgbd.config.password =/sgbd.config.password = $DBPASS/g" config.ini -sed -i "s/sgbd.config.dbname =/sgbd.config.dbname = $DBNAME/g" config.ini -touch local.php +source ./build_bokeh_config.sh $DBNAME $DBUSER $DBPASS $DBHOST -php --version +EARLY_DESC=`php -r "echo version_compare(PHP_VERSION, '8.1', '>=') ? '--fail-error-with-desc' : '';"` -php -d display_errors=on -d error_reporting=E_ALL scripts/upgrade_db.php - -cd cosmogramme -cp config.ref.php config.php -sed -i "s/integration_server=localhost/integration_server=$DBHOST/g" config.php -sed -i "s/integration_user=root/integration_user=$DBUSER/g" config.php -sed -i "s/integration_pwd=root/integration_pwd=$DBPASS/g" config.php -sed -i "s/integration_base=opac3/integration_base=$DBNAME/g" config.php -cd .. - -export OPENSSL_CONF=/etc/ssl/ - -phpunit -c tests/phpunit_db.xml --list-suites && phpunit -c tests/phpunit_db.xml --exclude-group no-ci \ - && phpunit -c tests/phpunit_js.xml --list-suites && phpunit -c tests/phpunit_js.xml --exclude-group no-ci \ - && cd cosmogramme/tests && phpunit --list-suites && phpunit --exclude-group no-ci \ - && cd ../cosmozend/tests && phpunit --list-suites && phpunit --exclude-group no-ci +phpunit -c tests/phpunit_eco.xml --list-suites $EARLY_DESC \ + && phpunit -c tests/phpunit_eco.xml $EARLY_DESC \ + && phpunit -c tests/phpunit_db.xml --list-suites $EARLY_DESC \ + && phpunit -c tests/phpunit_db.xml --exclude-group no-ci $EARLY_DESC \ + && phpunit -c tests/phpunit_js.xml --list-suites $EARLY_DESC \ + && phpunit -c tests/phpunit_js.xml --exclude-group no-ci $EARLY_DESC \ + && cd cosmogramme/tests \ + && phpunit --list-suites $EARLY_DESC \ + && phpunit --exclude-group no-ci $EARLY_DESC \ + && cd ../cosmozend/tests \ + && phpunit --list-suites $EARLY_DESC \ + && phpunit --exclude-group no-ci $EARLY_DESC diff --git a/build_scenario.sh b/build_scenario.sh new file mode 100644 index 0000000000000000000000000000000000000000..3dd14518d139e55ea6223340000551ff3280ad7c --- /dev/null +++ b/build_scenario.sh @@ -0,0 +1,12 @@ +#!/bin/bash +DBNAME=$1 +DBUSER=$2 +DBPASS=$3 +DBHOST=$4 + +source ./build_bokeh_config.sh $DBNAME $DBUSER $DBPASS $DBHOST + +EARLY_DESC=`php -r "echo version_compare(PHP_VERSION, '8.1', '>=') ? '--fail-error-with-desc' : '';"` + +phpunit -c tests/phpunit_scenario.xml --list-suites $EARLY_DESC \ + && phpunit -c tests/phpunit_scenario.xml --exclude-group no-ci $EARLY_DESC diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php index 24b10bde2a5b0ab18009c566a10620214a2b2c30..f755a0694c1c9bbacbff182a805cc3cfa5b4df8e 100644 --- a/tests/application/modules/AbstractControllerTestCase.php +++ b/tests/application/modules/AbstractControllerTestCase.php @@ -172,6 +172,24 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe } + protected function _printMemory() : void { + $memory_usage = round((memory_get_usage() / (1024*1024)), 0); + $memory_limit = round(((int) ini_get('memory_limit') ), 0); + echo printf("%s / %s\n", + $memory_usage, + $memory_limit); + } + + + protected function _cleanMemory() { + foreach ((new \ReflectionObject($this))->getProperties() as $prop) { + if ($prop->isStatic() || strpos($prop->getDeclaringClass()->getName(), 'PHPUnit') === 0) + continue; + unset($this->{$prop->getName()}); + } + } + + public function tearDown() { new TearDown($this->_storm_default_to_volatile, $this->_registry_sql, diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 8113469f92765e3be59f9c8eacdeface1e752864..b3b550f97cb3a5a73d9214197741def72cba41ec 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -97,7 +97,6 @@ require_once 'tests/fixtures/MockedClasses.php'; require_once 'tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php'; require_once 'tests/js/BrowserTest.php'; -register_shutdown_function(function(){ - TestSpeedTrap::printSpeedTrappedTests(); -}); +register_shutdown_function(fn() => TestSpeedTrap::printSpeedTrappedTests()); + ?> diff --git a/tests/phpunit.xml b/tests/phpunit.xml index bf5876f43081beaf8b09c1198b2046ea6e65c072..7d2b4bcba7220c2df2f6079d20b0163e39f06229 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -6,10 +6,10 @@ stopOnFailure="false" stopOnError="false" failErrorWithDesc="false" + cacheTokens="false" > <testsuites> - <testsuite name="Bokeh scenario, application, library and digital resources"> - <directory>./scenarios/</directory> + <testsuite name="Bokeh application, library and digital resources"> <directory>./application/</directory> <directory>./library/</directory> <directory>../library/digital_resources/</directory> diff --git a/tests/phpunit_scenario.xml b/tests/phpunit_scenario.xml new file mode 100644 index 0000000000000000000000000000000000000000..f910c894d0badd1c219faa464a63cba3440acb1c --- /dev/null +++ b/tests/phpunit_scenario.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phpunit + bootstrap="./bootstrap.php" + colors="false" + backupGlobals="false" + stopOnFailure="false" + stopOnError="false" + failErrorWithDesc="false" + cacheTokens="false" + > + <testsuites> + <testsuite name="Bokeh scenario"> + <directory>./scenarios/</directory> + </testsuite> + </testsuites> + <filter> + <whitelist> + <directory suffix=".php">../application</directory> + <directory suffix=".php">../library/Class</directory> + <directory suffix=".php">../library/Trait</directory> + <directory suffix=".php">../library/ZendAfi</directory> + <directory suffix=".php">../library/fonctions</directory> + <directory suffix=".php">../library/digital_resources</directory> + <directory suffix=".php">../library/templates</directory> + <directory suffix=".php">./js/</directory> + <exclude> + <file>../index.php</file> + <directory>../library/Class/Pdf</directory> + <directory>../library/Thumbs</directory> + <directory>../library/storm/tests/Storm</directory> + </exclude> + </whitelist> + </filter> + <listeners> + <listener file="./TestSpeedTrap.php" class="TestSpeedTrap"/> + </listeners> +</phpunit>