diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 78be52c8aba3570de512c08359d12d6621810bc7..6e4287f57efecf3b11d1f02fe400289219d12679 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ variables: BOKEH_HTML_VALIDATOR_URL: "http://sthysel__nuhtml:8888" test:php74_bokeh: - image: bokeh_php74_with_chrome + image: registry.afi-sa.net/afi/bokeh-docker/bokeh_php74_with_chrome:stable services: - localhost:5000/bokeh_mariadb_10.3 - sthysel/nuhtml @@ -20,21 +20,21 @@ test:php74_bokeh: test:php74_other: - image: bokeh_php74_with_chrome + image: registry.afi-sa.net/afi/bokeh-docker/bokeh_php74_with_chrome:stable 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_other.sh $MYSQL_DATABASE root $MYSQL_ROOT_PASSWORD $MYSQL_HOST + - bash build_other_74.sh $MYSQL_DATABASE root $MYSQL_ROOT_PASSWORD $MYSQL_HOST except: - tags tags: - - bladerunner + - free test:php74_scenario: - image: bokeh_php74_with_chrome + image: registry.afi-sa.net/afi/bokeh-docker/bokeh_php74_with_chrome:stable services: - localhost:5000/bokeh_mariadb_10.3 - sthysel/nuhtml @@ -44,11 +44,11 @@ test:php74_scenario: except: - tags tags: - - bladerunner + - free test:php81_bokeh: - image: bokeh_php81 + image: registry.afi-sa.net/afi/bokeh-docker/bokeh_php81:stable services: - localhost:5000/bokeh_mariadb_10.3 - sthysel/nuhtml @@ -62,7 +62,7 @@ test:php81_bokeh: test:php81_other: - image: bokeh_php81 + image: registry.afi-sa.net/afi/bokeh-docker/bokeh_php81:stable services: - localhost:5000/bokeh_mariadb_10.3 - sthysel/nuhtml @@ -72,11 +72,11 @@ test:php81_other: except: - tags tags: - - bladerunner + - free test:php81_scenario: - image: bokeh_php81 + image: registry.afi-sa.net/afi/bokeh-docker/bokeh_php81:stable services: - localhost:5000/bokeh_mariadb_10.3 - sthysel/nuhtml @@ -86,4 +86,4 @@ test:php81_scenario: except: - tags tags: - - bladerunner \ No newline at end of file + - free diff --git a/build_bokeh.sh b/build_bokeh.sh index f1333658a60f588214c95d67ad09f4d9e98044bd..6d04d6848e4fe45e63d3deee6ce709d08c721786 100644 --- a/build_bokeh.sh +++ b/build_bokeh.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/env bash DBNAME=$1 DBUSER=$2 DBPASS=$3 @@ -8,5 +8,5 @@ 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.xml --list-suites $EARLY_DESC \ - && phpunit -c tests/phpunit.xml --exclude-group no-ci $EARLY_DESC +phpunit -c tests/phpunit_bokeh.xml --list-suites $EARLY_DESC \ + && phpunit -c tests/phpunit_bokeh.xml --exclude-group no-ci $EARLY_DESC diff --git a/build_bokeh_config.sh b/build_bokeh_config.sh index 56ac77317fbdb09ccb36c2f4ea0d94542f5f9ab2..49640b2b7731c78ec014408bdfaccb48934cb648 100644 --- a/build_bokeh_config.sh +++ b/build_bokeh_config.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/env bash DBNAME=$1 DBUSER=$2 DBPASS=$3 diff --git a/build_other.sh b/build_other.sh index 8ec7a8ee952a38f246fa03ed18949966f7ddf16a..81acc380a1643c6c5ed6ae0f6cee9693c4c111ce 100644 --- a/build_other.sh +++ b/build_other.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/env bash DBNAME=$1 DBUSER=$2 DBPASS=$3 diff --git a/build_other_74.sh b/build_other_74.sh new file mode 100644 index 0000000000000000000000000000000000000000..38ba46a7ddee2f08e120fd36de231640640390ee --- /dev/null +++ b/build_other_74.sh @@ -0,0 +1,20 @@ +#!/bin/env 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_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 \ + && 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 index 3dd14518d139e55ea6223340000551ff3280ad7c..ba5c79d0b21c28c0c3cc4e15f94eefe530b6ee71 100644 --- a/build_scenario.sh +++ b/build_scenario.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/env bash DBNAME=$1 DBUSER=$2 DBPASS=$3 diff --git a/docker/php-fpm/Dockerfile b/docker/php-fpm/Dockerfile index 4fe2c25913f1001717b07f35429f0609bfe0aa01..48648911271a9a46976ba6080a81678516aefe18 100644 --- a/docker/php-fpm/Dockerfile +++ b/docker/php-fpm/Dockerfile @@ -93,20 +93,21 @@ COPY phpunit /usr/local/bin/phpunit RUN chmod +x /usr/local/bin/phpunit RUN cd /usr/local/share \ - && wget -O chrome-linux.zip https://download-chromium.appspot.com/dl/Linux_x64?type=snapshots \ + && wget -O chrome-linux.zip https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/1199984/chrome-linux.zip \ && unzip chrome-linux.zip \ - && ln -s /usr/local/share/chrome-linux/chrome /usr/local/bin/chromium \ - && apt-get install -yqq libnss3 \ - libatk1.0-0 \ - libatk-bridge2.0-0 \ - libdrm2 \ - libxkbcommon0 \ - libxcomposite1 \ - libxdamage1 \ - libxrandr2 \ - libgbm1 \ - libasound2 \ - libxshmfence1 + && ln -s /usr/local/share/chrome-linux/chrome /usr/local/bin/chromium + +RUN apt-get install -yqq libnss3 \ + libatk1.0-0 \ + libatk-bridge2.0-0 \ + libdrm2 \ + libxkbcommon0 \ + libxcomposite1 \ + libxdamage1 \ + libxrandr2 \ + libgbm1 \ + libasound2 \ + libxshmfence1 EXPOSE 9000 diff --git a/includes.php b/includes.php index 484d64317547febfca1e8908b196c92025721bfb..aa034d231f4afb8b4f4e21d7a9ede6fe1bf475d8 100644 --- a/includes.php +++ b/includes.php @@ -18,16 +18,15 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + $base_path = realpath(dirname(__FILE__)); set_include_path($base_path . PATH_SEPARATOR . $base_path . '/library' . PATH_SEPARATOR . $base_path . '/library/storm/src' . PATH_SEPARATOR . $base_path . '/library/storm/zf/library' . PATH_SEPARATOR . $base_path . '/library/digital_resources' . PATH_SEPARATOR . - $base_path . '/library/templates' . PATH_SEPARATOR . - get_include_path()); + $base_path . '/library/templates' . PATH_SEPARATOR . get_include_path()); include_once "local.php"; include_once "library/fonctions/fonctions.php"; require_once "library/startup.php"; -?> diff --git a/library/Polyfill80.php b/library/Polyfill80.php new file mode 100644 index 0000000000000000000000000000000000000000..5af26d1ae38f4dd7538395eb36dade5e9f9dd7cf --- /dev/null +++ b/library/Polyfill80.php @@ -0,0 +1,38 @@ +<?php +/** + * Copyright (c) 2012-2023, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH 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 AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +if (version_compare(PHP_VERSION, '8.0.0') >= 0) + return; + +if ( ! function_exists('str_contains')) { + function str_contains(?string $haystack, ?string $needle) : bool { + $needle ??= ''; + $haystack ??= ''; + + return '' === $needle || false !== strpos($haystack, $needle); + } +} + +if ( ! function_exists('str_starts_with')) { + function str_starts_with(?string $haystack, ?string $needle) : bool { + return 0 === strncmp($haystack, $needle, strlen($needle)); + } +} diff --git a/library/startup.php b/library/startup.php index 899b2e5e9be5812d3cdfbf6cadf7dd10b0aae147..d85681c22b4ab0682aefbda5ad3ab8fab767f8ce 100644 --- a/library/startup.php +++ b/library/startup.php @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +require_once "Polyfill80.php"; + if (!function_exists('xdebug_break')) { function xdebug_break(){}; } @@ -240,7 +242,6 @@ class Bokeh_Engine { $this->setCacheSeed($seed); Storm_Cache::setSeed($this->getCacheSeed()); - $db_cache = Zend_Cache::factory('Core', $backend, array_merge($frontendOptions, @@ -355,7 +356,7 @@ class Bokeh_Engine { protected function _setupTranslationsIn($translate, $default) { - if (!$languages = Class_AdminVar::getLanguesWithoutDefault()) + if ( ! $languages = Class_AdminVar::getLanguesWithoutDefault()) return $this; foreach ($languages as $language) { @@ -372,7 +373,8 @@ class Bokeh_Engine { function setupDatabase() { // setup database - $sql = Zend_Db::factory($this->_config->sgbd->adapter, $this->_config->sgbd->config->toArray()); + $sql = Zend_Db::factory($this->_config->sgbd->adapter, + $this->_config->sgbd->config->toArray()); $sql->usePrepared(false); Zend_Db_Table::setDefaultAdapter($sql); @@ -413,7 +415,6 @@ class Bokeh_Engine { function setupHTTPClient() { - if ( (isset ($this->_config->proxy->host) ) && ($this->_config->proxy->host != '') ){ //set up HTTP Client to use proxy settings $proxy_config = [ @@ -604,7 +605,6 @@ class Bokeh_Session { function setupOpac() { - return Bokeh_Engine::getInstance() ->powerOn() ->getFrontController(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index b3b550f97cb3a5a73d9214197741def72cba41ec..185b901602c5796de26ac2f5630bec3c354c2243 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -18,6 +18,7 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + chdir(realpath(dirname(__FILE__)).'/../'); error_reporting(E_ALL^E_DEPRECATED); @@ -95,8 +96,7 @@ require_once 'tests/library/Class/WebService/SIGB/TestingService.php'; require_once 'tests/fixtures/RessourcesNumeriquesFixtures.php'; require_once 'tests/fixtures/MockedClasses.php'; require_once 'tests/application/modules/telephone/controllers/TelephoneAbstractControllerTestCase.php'; -require_once 'tests/js/BrowserTest.php'; +if (version_compare(PHP_VERSION, '8.0.0') >= 0) + require_once 'tests/js/BrowserTest.php'; register_shutdown_function(fn() => TestSpeedTrap::printSpeedTrappedTests()); - -?> diff --git a/tests/js/BrowserTest.php b/tests/js/BrowserTest.php index f83139470210b0e162afab65a97442eef4efa33a..9caa3cb4223cd7938e62f86b6b17206436beb0f3 100644 --- a/tests/js/BrowserTest.php +++ b/tests/js/BrowserTest.php @@ -45,7 +45,8 @@ abstract class BrowserTest extends PHPUnit_Framework_TestCase { * @dataProvider pathsForTests **/ public function jsTestShouldSucceed($path) { - $browser = (new BrowserFactory('chromium'))->createBrowser(['noSandbox' => true]); + $browser = (new BrowserFactory('chromium'))->createBrowser(['noSandbox' => true, + 'customFlags' => ['--remote-allow-origins=*']]); try { $page = $browser->createPage(); diff --git a/tests/phpunit.xml b/tests/phpunit.xml index 7d2b4bcba7220c2df2f6079d20b0163e39f06229..2a3703effdae3174b80e12548a7fcf3e94384530 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -13,6 +13,10 @@ <directory>./application/</directory> <directory>./library/</directory> <directory>../library/digital_resources/</directory> + <directory>./db/</directory> + <directory>./eco/</directory> + <directory>./scenarios/</directory> + <directory>../library/storm/tests/Storm/</directory> </testsuite> </testsuites> <filter> diff --git a/tests/phpunit_bokeh.xml b/tests/phpunit_bokeh.xml new file mode 100644 index 0000000000000000000000000000000000000000..7d2b4bcba7220c2df2f6079d20b0163e39f06229 --- /dev/null +++ b/tests/phpunit_bokeh.xml @@ -0,0 +1,39 @@ +<?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 application, library and digital resources"> + <directory>./application/</directory> + <directory>./library/</directory> + <directory>../library/digital_resources/</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> diff --git a/tests_js/lib/chrome-php b/tests_js/lib/chrome-php index 448af70ba2da1a283d451b5856b66b37731a95e5..7cc56762cce4b65b49ad26996ac68097fd0c2c37 160000 --- a/tests_js/lib/chrome-php +++ b/tests_js/lib/chrome-php @@ -1 +1 @@ -Subproject commit 448af70ba2da1a283d451b5856b66b37731a95e5 +Subproject commit 7cc56762cce4b65b49ad26996ac68097fd0c2c37