diff --git a/library/Class/Indexation.php b/library/Class/Indexation.php index cf724ec69efe87b7573b2317f53259373fb00e90..4668308c8ca4913bcdf7f2c3aa20424089eae7d9 100644 --- a/library/Class/Indexation.php +++ b/library/Class/Indexation.php @@ -22,25 +22,74 @@ class Class_Indexation { protected static $_instance, - $_alpha_maj_cache = []; - - private $articles; // Articles rejetes - private $inclu; // Mots inclus - private $exclu; // Mots vides - private $pluriel; // Règles des pluriels - private $tableMajFrom, $tableMajTo = []; // Table de transco pour majuscules - private $tableMajUtf8; // Table de transco pour majuscules accentuées utf8 - - private $accents = ['É' => 'E', 'È' => 'E', 'Ë' => 'E', 'Ê' => 'E','Ã' => 'A', 'À' => 'A', 'Ä' => 'A', 'Â' => 'A', - 'Ã…' => 'A', 'Ã' => 'A', 'Æ' => 'E','Ã' => 'I', 'ÃŽ' => 'I', 'ÃŒ' => 'I', 'Ã' => 'I', - 'Ô' => 'O', 'Ö' => 'O', 'Ã’' => 'O', 'Ó' => 'O', 'Õ' => 'O', 'Ø' => 'O', 'Å’' => 'OEU', - 'Ú' => 'U', 'Ù' => 'U', 'Û' => 'U', 'Ãœ' => 'U','Ñ' => 'N', 'Ç' => 'S', '¿' => 'E']; - - private $min2maj = ['é' => 'É', 'è' => 'È', 'ë' => 'Ë', 'ê' => 'Ê','á' => 'Ã', 'â' => 'Â', 'à ' => 'À', 'Ä' => 'A', - 'Â' => 'A', 'Ã¥' => 'Ã…', 'ã' => 'Ã', 'æ' => 'Æ', 'ï' => 'Ã', 'î' => 'ÃŽ', 'ì' => 'ÃŒ', 'Ã' => 'Ã', - 'ô' => 'Ô', 'ö' => 'Ö', 'ò' => 'Ã’', 'ó' => 'Ó','õ' => 'Õ', 'ø' => 'Ø', 'Å“' => 'Å’', - 'ú' => 'Ú', 'ù' => 'Ù', 'û' => 'Û', 'ü' => 'Ãœ','ç' => 'Ç', 'ñ' => 'Ñ', 'ß' => 'S']; - + $_alpha_maj_cache = [], + $_accents = ['É' => 'E', 'È' => 'E', 'Ë' => 'E', 'Ê' => 'E','Ã' => 'A', 'À' => 'A', 'Ä' => 'A', 'Â' => 'A', + 'Ã…' => 'A', 'Ã' => 'A', 'Æ' => 'E','Ã' => 'I', 'ÃŽ' => 'I', 'ÃŒ' => 'I', 'Ã' => 'I', + 'Ô' => 'O', 'Ö' => 'O', 'Ã’' => 'O', 'Ó' => 'O', 'Õ' => 'O', 'Ø' => 'O', 'Å’' => 'OEU', + 'Ú' => 'U', 'Ù' => 'U', 'Û' => 'U', 'Ãœ' => 'U','Ñ' => 'N', 'Ç' => 'S', '¿' => 'E'], + + $_min2maj = ['é' => 'É', 'è' => 'È', 'ë' => 'Ë', 'ê' => 'Ê','á' => 'Ã', 'â' => 'Â', 'à ' => 'À', 'Ä' => 'A', + 'Â' => 'A', 'Ã¥' => 'Ã…', 'ã' => 'Ã', 'æ' => 'Æ', 'ï' => 'Ã', 'î' => 'ÃŽ', 'ì' => 'ÃŒ', 'Ã' => 'Ã', + 'ô' => 'Ô', 'ö' => 'Ö', 'ò' => 'Ã’', 'ó' => 'Ó','õ' => 'Õ', 'ø' => 'Ø', 'Å“' => 'Å’', + 'ú' => 'Ú', 'ù' => 'Ù', 'û' => 'Û', 'ü' => 'Ãœ','ç' => 'Ç', 'ñ' => 'Ñ', 'ß' => 'S'], + + $_articles = ['L\'','LE ','LA ','LES ','UN ','UNE '], + + $_inclu = ['AN','AS','OR','U2','AI','LU','XO','DO','RE','MI','FA','SI','AC','DC','XX','B','C','D','E','F','G','H','I','J','K','M','P','Q','R','S','T','V','W','X','Y','Z','L','YU','UT','LI','OC','PI','ZU','WU','TO','OZ','ZZ','XX', 'PC', 'DS'], + + $_exclu = ['L','LE','LA','LES','UN','UNE','LES','DES','MES','TES','CES'], + + $_pluriel = [ ['AIL','AULX'], + ['AVAL','AVALS'], + ['BAIL','BAUX'], + ['BAL','BALS'], + ['BANAL','BANALS'], + ['BANCAL','BANCALS'], + ['BIJOU','BIJOUX'], + ['BLEU','BLEUS'], + ['CAILLOU','CAILLOUX'], + ['CAL','CALS'], + ['CARNAVAL','CARNAVALS'], + ['CEREMONIAL','CEREMONIALS'], + ['CHACAL','CHACALS'], + ['CHORAL','CHORALS'], + ['CHOU','CHOUX'], + ['CORAIL','CORAUX'], + ['DETAIL','DETAILS'], + ['EMAIL','EMAUX'], + ['EMEU','EMEUS'], + ['ETAL','ETALS'], + ['FATAL','FATALS'], + ['FESTIVAL','FESTIVALS'], + ['GEMMAIL','GEMMAUX'], + ['GENOU','GENOUX'], + ['HIBOU','HIBOUX'], + ['JOUJOU','JOUJOUX'], + ['LANDAU','LANDAUX'], + ['NATAL','NATALS'], + ['OEIL','YEUX'], + ['PAL','PALS'], + ['PNEU','PNEUS'], + ['POU','POUX'], + ['RECITAL','RECITALS'], + ['REGAL','REGALS'], + ['SARRAU','SARRAUS'], + ['SOUPIRAIL','SOUPIRAUX'], + ['TONAL','TONALS'], + ['TRAVAIL','TRAVAUX'], + ['VAL','VALS'], + ['VENTAIL','VENTAUX'], + ['VIRGINAL','VIRGINALS'], + ['VITRAIL','VITRAUX'], + ['*EAU','*EAUX'], + ['*AL','*AUX'], + ['*EU','*EUX'], + ['*AU','*AUX'], + ['PC','PC'], + ['DS','DS']], + + $_tableMajFrom, + $_tableMajTo; public static function getInstance() { if(!static::$_instance) @@ -50,104 +99,18 @@ class Class_Indexation { function __construct() { - // Lire formes rejetées - $this->articles = ['L\'','LE ','LA ','LES ','UN ','UNE ']; - - $this->inclu = ['AN','AS','OR','U2','AI','LU','XO','DO','RE','MI','FA','SI','AC','DC','XX','B','C','D','E','F','G','H','I','J','K','M','P','Q','R','S','T','V','W','X','Y','Z','L','YU','UT','LI','OC','PI','ZU','WU','TO','OZ','ZZ','XX', 'PC', 'DS']; - - $this->exclu = ['L','LE','LA','LES','UN','UNE','LES','DES','MES','TES','CES']; - - // Pluriels - $this->pluriel = [ ['AIL','AULX'], - ['AVAL','AVALS'], - ['BAIL','BAUX'], - ['BAL','BALS'], - ['BANAL','BANALS'], - ['BANCAL','BANCALS'], - ['BIJOU','BIJOUX'], - ['BLEU','BLEUS'], - ['CAILLOU','CAILLOUX'], - ['CAL','CALS'], - ['CARNAVAL','CARNAVALS'], - ['CEREMONIAL','CEREMONIALS'], - ['CHACAL','CHACALS'], - ['CHORAL','CHORALS'], - ['CHOU','CHOUX'], - ['CORAIL','CORAUX'], - ['DETAIL','DETAILS'], - ['EMAIL','EMAUX'], - ['EMEU','EMEUS'], - ['ETAL','ETALS'], - ['FATAL','FATALS'], - ['FESTIVAL','FESTIVALS'], - ['GEMMAIL','GEMMAUX'], - ['GENOU','GENOUX'], - ['HIBOU','HIBOUX'], - ['JOUJOU','JOUJOUX'], - ['LANDAU','LANDAUX'], - ['NATAL','NATALS'], - ['OEIL','YEUX'], - ['PAL','PALS'], - ['PNEU','PNEUS'], - ['POU','POUX'], - ['RECITAL','RECITALS'], - ['REGAL','REGALS'], - ['SARRAU','SARRAUS'], - ['SOUPIRAIL','SOUPIRAUX'], - ['TONAL','TONALS'], - ['TRAVAIL','TRAVAUX'], - ['VAL','VALS'], - ['VENTAIL','VENTAUX'], - ['VIRGINAL','VIRGINALS'], - ['VITRAIL','VITRAUX'], - ['*EAU','*EAUX'], - ['*AL','*AUX'], - ['*EU','*EUX'], - ['*AU','*AUX'], - ['PC','PC'], - ['DS','DS']]; - - // Init table ascii pour majuscules - $this->tableMajTo = str_split(str_repeat( ' ', 42 ) - . '* 0123456789 ' - . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' - . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' - . str_repeat( ' ', 63) - .'AAAAAAACEEEEIIII NOOOOO UUUUY AAAAAAACEEEEIIII NOOOOO UUUUY Y'); - - for($i=0; $i<count($this->tableMajTo); $i++) - $this->tableMajFrom[] = chr($i); - - - $this->tableMajUtf8 = [chr(0xC9) => 'E', - 'È' => 'E', - 'Ë' => 'E', - 'Ê' => 'E', - 'Ã' => 'A', - 'À' => 'A', - 'Ä' => 'A', - 'Â' => 'A', - 'Ã…' => 'A', - 'Ã' => 'A', - 'Æ' => 'E', - 'Ã' => 'I', - 'ÃŽ' => 'I', - 'ÃŒ' => 'I', - 'Ã' => 'I', - 'Ô' => 'O', - 'Ö' => 'O', - 'Ã’' => 'O', - 'Ó' => 'O', - 'Õ' => 'O', - 'Ø' => 'O', - 'Å’' => 'OEU', - 'Ú' => 'U', - 'Ù' => 'U', - 'Û' => 'U', - 'Ãœ' => 'U', - 'Ñ' => 'N', - 'Ç' => 'S', - '¿' => 'E']; + if (isset(static::$_tableMajTo)) + return; + + static::$_tableMajTo = str_split(str_repeat( ' ', 42 ) + . '* 0123456789 ' + . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' + . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' + . str_repeat( ' ', 63) + .'AAAAAAACEEEEIIII NOOOOO UUUUY AAAAAAACEEEEIIII NOOOOO UUUUY Y'); + + for($i=0; $i<count(static::$_tableMajTo); $i++) + static::$_tableMajFrom[] = chr($i); } @@ -155,7 +118,7 @@ class Class_Indexation { public function codeAlphaTitre($titre) { $titre=$this->alphaMaj($titre); - foreach($this->articles as $article) + foreach(static::$_articles as $article) { $lg=strlen($article); if(strLeft($titre, $lg)==$article) {$titre=strMid($titre,$lg,256); break;} @@ -186,8 +149,8 @@ class Class_Indexation { if (isset(static::$_alpha_maj_cache[$chaine])) return static::$_alpha_maj_cache[$chaine]; - return static::$_alpha_maj_cache[$chaine] = trim(str_replace($this->tableMajFrom, - $this->tableMajTo, + return static::$_alpha_maj_cache[$chaine] = trim(str_replace(static::$_tableMajFrom, + static::$_tableMajTo, utf8_decode($chaine))); } @@ -222,14 +185,14 @@ class Class_Indexation { foreach($words as $word) { if(strlen($word) < 3 && intVal($word) == false) { - if(false == in_array($word, $this->inclu)) + if(false == in_array($word, static::$_inclu)) continue; if( 1 == strlen($word)) $word .= '00'; } - if(true == in_array($word, $this->exclu)) + if(true == in_array($word, static::$_exclu)) continue; $new[] = $word; @@ -266,7 +229,7 @@ class Class_Indexation { { if( strToUpper($mot) != $mot ) $mot=$this->alphaMaj($mot); if(!trim($mot)) return false; - foreach($this->pluriel as $regle) + foreach(static::$_pluriel as $regle) { if(strLeft($regle[0],1) != '*') { @@ -296,7 +259,7 @@ class Class_Indexation { // --------------------------------------------------- public function isMotInclu($mot) { - return in_array($mot, $this->inclu); + return in_array($mot, static::$_inclu); } // --------------------------------------------------- @@ -309,8 +272,8 @@ class Class_Indexation { } function phonetixCompute($sIn) { - $sIn = strtr( $sIn, $this->accents); // minuscules accentuées ou composées en majuscules simples - $sIn = strtr( $sIn, $this->min2maj); // majuscules accentuées ou composées en majuscules simples + $sIn = strtr( $sIn, static::$_accents); // minuscules accentuées ou composées en majuscules simples + $sIn = strtr( $sIn, static::$_min2maj); // majuscules accentuées ou composées en majuscules simples $sIn = strtoupper( $sIn ); // on passe tout le reste en majuscules $sIn = preg_replace( '`[^A-Z]`', '', $sIn ); // on garde uniquement les lettres de A à Z diff --git a/library/ZendAfi/Translate.php b/library/ZendAfi/Translate.php index c38a53e75af615ffd63c23fa7da49a3560991fbe..f308e7ce0d76c859904261672ae6256afeb04c85 100644 --- a/library/ZendAfi/Translate.php +++ b/library/ZendAfi/Translate.php @@ -21,18 +21,14 @@ class ZendAfi_Translate extends Zend_Translate { public function _() { - $args = func_get_args(); - $num = func_num_args(); - - if (!$num) + if (!$num = func_num_args()) return ''; - $args[0] = parent::_(Class_TextReplacements::replace($args[0])); - - if($num <= 1) { - return $args[0]; - } + if ($num <= 1) + return parent::_(Class_TextReplacements::replace(func_get_args()[0])); + $args = func_get_args(); + $args[0] = parent::_(Class_TextReplacements::replace($args[0])); return call_user_func_array('sprintf', $args); } diff --git a/scripts/emacs/phafi-mode.el b/scripts/emacs/phafi-mode.el index 4a34da8c36cee1618b8d81aee470071fdbfa0441..5649758caa001e8b7807d27f5dd747f24138e244 100644 --- a/scripts/emacs/phafi-mode.el +++ b/scripts/emacs/phafi-mode.el @@ -205,9 +205,9 @@ (setq phafi-phpunit-command (concat debug-mode - (if phafi-phpunit-profiling (phafi-phpunit-profiling-command) "phpunit") - " -c " - phafi-phpunit-config + "phpunit -c " + (phafi-selected-phpunit-config) + " " command-filter " " filename @@ -226,11 +226,6 @@ ) -(defun phafi-phpunit-profiling-command() - (concat (phafi-mode-dir) "profile-phpunit") - ) - - (defun phafi-run-phpunit(debug-mode) "Run all phpunit tests" (interactive "P" ) @@ -354,6 +349,12 @@ ) +(defun phafi-selected-phpunit-config() + (if phafi-phpunit-profiling + (concat (phafi-root-dir) "tests/phpunit_with_profiling.xml") + phafi-phpunit-config) + ) + (defun phafi-sql-patch(patch) "Force execution of db migration" (interactive (list (read-number "Enter patch number: "))) diff --git a/tests/phpunit-testlistener-xhprof/LICENSE b/tests/phpunit-testlistener-xhprof/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..97048642f8eb297b07fdfcb29b20d073a4168c34 --- /dev/null +++ b/tests/phpunit-testlistener-xhprof/LICENSE @@ -0,0 +1,33 @@ +PHPUnit_TestListener_XHProf + +Copyright (c) 2010-2015, Sebastian Bergmann <sebastian@phpunit.de>. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + * Neither the name of Sebastian Bergmann nor the names of his + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/phpunit-testlistener-xhprof/composer.json b/tests/phpunit-testlistener-xhprof/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..f6b45cb1bce7e05c8c370e58fa172b9d788c097f --- /dev/null +++ b/tests/phpunit-testlistener-xhprof/composer.json @@ -0,0 +1,40 @@ +{ + "name": "phpunit/test-listener-xhprof", + "description": "A TestListener for PHPUnit that uses XHProf for automated profiling of the tested code", + "type": "library", + "keywords": [ + "phpunit", + "xhprof" + ], + "homepage": "https://github.com/phpunit/phpunit-testlistener-xhprof", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de", + "role": "lead" + } + ], + "support": { + "issues": "https://github.com/phpunit/phpunit-testlistener-xhprof/issues" + }, + "require": { + "php": ">=5.3.3", + "phpunit/phpunit": "~4.0" + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + } +} diff --git a/tests/phpunit-testlistener-xhprof/src/XHProfTestListener.php b/tests/phpunit-testlistener-xhprof/src/XHProfTestListener.php new file mode 100755 index 0000000000000000000000000000000000000000..c71fb45918d6f7e2c6cefebf6d6b893706d7a8cf --- /dev/null +++ b/tests/phpunit-testlistener-xhprof/src/XHProfTestListener.php @@ -0,0 +1,226 @@ +<?php +/* + * This file is part of PHPUnit. + * + * (c) Sebastian Bergmann <sebastian@phpunit.de> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PHPUnit\XHProfTestListener; + +/** + * A TestListener that integrates with XHProf. + * + * Here is an example XML configuration for activating this listener: + * + * <code> + * <listeners> + * <listener class="PHPUnit\XHProfTestListener\XHProfTestListener"> + * <arguments> + * <array> + * <element key="xhprofLibFile"> + * <string>/var/www/xhprof_lib/utils/xhprof_lib.php</string> + * </element> + * <element key="xhprofRunsFile"> + * <string>/var/www/xhprof_lib/utils/xhprof_runs.php</string> + * </element> + * <element key="xhprofWeb"> + * <string>http://localhost/xhprof_html/index.php</string> + * </element> + * <element key="appNamespace"> + * <string>Doctrine2</string> + * </element> + * <element key="xhprofFlags"> + * <string>XHPROF_FLAGS_CPU,XHPROF_FLAGS_MEMORY</string> + * </element> + * <element key="xhprofIgnore"> + * <string>call_user_func,call_user_func_array</string> + * </element> + * </array> + * </arguments> + * </listener> + * </listeners> + * </code> + * + * @author Benjamin Eberlei <kontakt@beberlei.de> + * @author Sebastian Bergmann <sebastian@phpunit.de> + * @copyright 2011-2015 Sebastian Bergmann <sebastian@phpunit.de> + * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License + * @link http://www.phpunit.de/ + * @since Class available since Release 1.0.0 + */ +class XHProfTestListener implements \PHPUnit_Framework_TestListener +{ + /** + * @var array + */ + protected $runs = array(); + + /** + * @var array + */ + protected $options = array(); + + /** + * @var integer + */ + protected $suites = 0; + + /** + * Constructor. + * + * @param array $options + */ + public function __construct(array $options = array()) + { + if (!isset($options['appNamespace'])) { + throw new InvalidArgumentException( + 'The "appNamespace" option is not set.' + ); + } + + if (!isset($options['xhprofLibFile']) || + !file_exists($options['xhprofLibFile'])) { + throw new InvalidArgumentException( + 'The "xhprofLibFile" option is not set or the configured file does not exist' + ); + } + + if (!isset($options['xhprofRunsFile']) || + !file_exists($options['xhprofRunsFile'])) { + throw new InvalidArgumentException( + 'The "xhprofRunsFile" option is not set or the configured file does not exist' + ); + } + + require_once $options['xhprofLibFile']; + require_once $options['xhprofRunsFile']; + + $this->options = $options; + } + + /** + * An error occurred. + * + * @param \PHPUnit_Framework_Test $test + * @param \Exception $e + * @param float $time + */ + public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time) + { + } + + /** + * A failure occurred. + * + * @param \PHPUnit_Framework_Test $test + * @param \PHPUnit_Framework_AssertionFailedError $e + * @param float $time + */ + public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time) + { + } + + /** + * Incomplete test. + * + * @param \PHPUnit_Framework_Test $test + * @param \Exception $e + * @param float $time + */ + public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) + { + } + + /** + * Skipped test. + * + * @param \PHPUnit_Framework_Test $test + * @param \Exception $e + * @param float $time + */ + public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) + { + } + + /** + * Risky test. + * + * @param \PHPUnit_Framework_Test $test + * @param \Exception $e + * @param float $time + */ + public function addRiskyTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) + { + } + + /** + * A test started. + * + * @param \PHPUnit_Framework_Test $test + */ + public function startTest(\PHPUnit_Framework_Test $test) + { + if (!isset($this->options['xhprofFlags'])) { + $flags = XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY; + } else { + $flags = 0; + + foreach (explode(',', $this->options['xhprofFlags']) as $flag) { + $flags += constant($flag); + } + } + + xhprof_enable($flags, array( + 'ignored_functions' => explode(',', $this->options['xhprofIgnore']) + )); + } + + /** + * A test ended. + * + * @param \PHPUnit_Framework_Test $test + * @param float $time + */ + public function endTest(\PHPUnit_Framework_Test $test, $time) + { + $data = xhprof_disable(); + $runs = new \XHProfRuns_Default; + $run = $runs->save_run($data, $this->options['appNamespace']); + $test_name = get_class($test) . '::' . $test->getName(); + $this->runs[$test_name] = $this->options['xhprofWeb'] . '?run=' . $run . + '&source=' . $this->options['appNamespace']; + } + + /** + * A test suite started. + * + * @param \PHPUnit_Framework_TestSuite $suite + */ + public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) + { + $this->suites++; + } + + /** + * A test suite ended. + * + * @param \PHPUnit_Framework_TestSuite $suite + */ + public function endTestSuite(\PHPUnit_Framework_TestSuite $suite) + { + $this->suites--; + + if ($this->suites == 0) { + print "\n\nXHProf runs: " . count($this->runs) . "\n"; + + foreach ($this->runs as $test => $run) { + print ' * ' . $test . "\n " . $run . "\n\n"; + } + + print "\n"; + } + } +} diff --git a/tests/phpunit-testlistener-xhprof/src/exceptions/Exception.php b/tests/phpunit-testlistener-xhprof/src/exceptions/Exception.php new file mode 100644 index 0000000000000000000000000000000000000000..db41f6117fcb1ac6a12964a454fb56087db1fd06 --- /dev/null +++ b/tests/phpunit-testlistener-xhprof/src/exceptions/Exception.php @@ -0,0 +1,15 @@ +<?php +/* + * This file is part of PHPUnit. + * + * (c) Sebastian Bergmann <sebastian@phpunit.de> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PHPUnit\XHProfTestListener; + +interface Exception +{ +} diff --git a/tests/phpunit-testlistener-xhprof/src/exceptions/InvalidArgumentException.php b/tests/phpunit-testlistener-xhprof/src/exceptions/InvalidArgumentException.php new file mode 100644 index 0000000000000000000000000000000000000000..f2c57d64df8840bee072d89d4d41c79a40e2a10d --- /dev/null +++ b/tests/phpunit-testlistener-xhprof/src/exceptions/InvalidArgumentException.php @@ -0,0 +1,15 @@ +<?php +/* + * This file is part of PHPUnit. + * + * (c) Sebastian Bergmann <sebastian@phpunit.de> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PHPUnit\XHProfTestListener; + +class InvalidArgumentException extends \InvalidArgumentException implements Exception +{ +} diff --git a/tests/phpunit-testlistener-xhprof/src/load.php b/tests/phpunit-testlistener-xhprof/src/load.php new file mode 100644 index 0000000000000000000000000000000000000000..5fded844ea04bed435e6e79f3a5b2bba0d9e8488 --- /dev/null +++ b/tests/phpunit-testlistener-xhprof/src/load.php @@ -0,0 +1,5 @@ +<?php +require_once('XHProfTestListener.php'); +require_once('exceptions/Exception.php'); +require_once('exceptions/InvalidArgumentException.php'); +?> \ No newline at end of file diff --git a/tests/phpunit_with_profiling.xml b/tests/phpunit_with_profiling.xml new file mode 100644 index 0000000000000000000000000000000000000000..a279b67a2f100bf3d93ccb16c1d177a1bd979cc1 --- /dev/null +++ b/tests/phpunit_with_profiling.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phpunit + bootstrap="./bootstrap.php" + colors="false" + backupGlobals="false" + stopOnFailure="false" + stopOnError="false" + > + <testsuites> + <testsuite name="DBTestSuite"> + <directory>./db/</directory> + </testsuite> + <testsuite name="ScenariosTestSuite"> + <directory>./scenarios/</directory> + </testsuite> + <testsuite name="ApplicationTestSuite"> + <directory>./scenarios/</directory> + <directory>./application/</directory> + <directory>./library/</directory> + <directory>./js/</directory> + <directory>../library/storm/tests/Storm/</directory> + </testsuite> + <testsuite name="DigitalResourcesTestSuite"> + <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">./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"/> + <listener class="PHPUnit\XHProfTestListener\XHProfTestListener" file="phpunit-testlistener-xhprof/src/load.php"> + <arguments> + <array> + <element key="xhprofLibFile"> + <string>xhprof/xhprof_lib/utils/xhprof_lib.php</string> + </element> + <element key="xhprofRunsFile"> + <string>xhprof/xhprof_lib/utils/xhprof_runs.php</string> + </element> + <element key="xhprofWeb"> + <string>xhprof/xhprof_html/index.php</string> + </element> + <element key="xhprofFlags"> + <string>XHPROF_FLAGS_CPU,XHPROF_FLAGS_MEMORY</string> + </element> + <element key="xhprofIgnore"> + <string>call_user_func,call_user_func_array</string> + </element> + <element key="appNamespace"> + <string>Bokeh</string> + </element> + </array> + </arguments> + </listener> + </listeners> +</phpunit>