diff --git a/.gitignore b/.gitignore index 3c668233..40be9b0b 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,7 @@ bureau/locales/it_IT/LC_MESSAGES/messages.po~ bureau/locales/nl_NL/LC_MESSAGES/messages.po~ bureau/locales/pt_BR/LC_MESSAGES/messages.po~ .tx/alternc.alternc +# Added for running tests; currently not used otherwise +composer.lock +composer.json +vendor/ diff --git a/.travis.yml b/.travis.yml index 40af921b..882336ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,16 @@ language: php services: - mysql php: + - 7.1 - 7.0 - 5.6 - 5.5 - - 5.4 - - 5.3 -script: ../vendor/bin/phpunit --coverage-clover=coverage.clover +script: + - grep --exclude-dir=../.git/ --exclude-dir=../vendor/ -l -r -e '#!/bin/[bash|sh]' ../ | uniq | xargs shellcheck + - ../vendor/bin/phpcs --ignore=../vendor/ ../ + - ../vendor/bin/phpunit --coverage-clover=coverage.clover before_script: - - composer require phpunit/dbunit + - composer require 'phpunit/dbunit=<3.0.2' squizlabs/php_codesniffer - mysql -e 'create database alternc_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;' - cd phpunit after_script: diff --git a/bureau/class/m_action.php b/bureau/class/m_action.php index 0c0aca29..27351686 100644 --- a/bureau/class/m_action.php +++ b/bureau/class/m_action.php @@ -241,7 +241,7 @@ class m_action { * @global m_messages $msg * @global m_mysql $db * @param type $all - * @return boolean + * @return boolean|int The number of rows purged; False is there was an error */ function purge($all = null) { global $msg, $db; diff --git a/bureau/class/m_hooks.php b/bureau/class/m_hooks.php index 1093b077..0e10746a 100644 --- a/bureau/class/m_hooks.php +++ b/bureau/class/m_hooks.php @@ -53,6 +53,11 @@ class m_hooks { // existe on l'execute et on rajoute ce qu'elle a retourné dans // un tableau $val = array(); + if (!$classes) { + // Leaving early if classes isn't set prevents PHP warnings. + // Happens frequently when running PHPUnit tests. + return $val; + } foreach ($classes as $c) { global $$c; if (method_exists($$c, $hname)) { diff --git a/phpunit/lib/AlterncTest.php b/phpunit/lib/AlterncTest.php index d31eb8d3..b9eb7c41 100644 --- a/phpunit/lib/AlterncTest.php +++ b/phpunit/lib/AlterncTest.php @@ -5,6 +5,8 @@ */ use PHPUnit\Framework\TestCase; use PHPUnit\DbUnit\TestCaseTrait; +use PHPUnit\DbUnit\DataSet\YamlDataSet; +use PHPUnit\DbUnit\DataSet\CompositeDataSet; abstract class AlterncTest extends TestCase { @@ -40,10 +42,10 @@ abstract class AlterncTest extends TestCase if( !is_file($file) ){ throw new \Exception("missing $file"); } - $dataSet = new PHPUnit_Extensions_Database_DataSet_YamlDataSet($file); + $dataSet = new YamlDataSet($file); $datasetList[] = $dataSet; } - $compositeDataSet = new PHPUnit_Extensions_Database_DataSet_CompositeDataSet($datasetList); + $compositeDataSet = new CompositeDataSet($datasetList); return $dataSet; } diff --git a/phpunit/tests/bureau/class/m_actionTest.php b/phpunit/tests/bureau/class/m_actionTest.php index 72767e14..d429cb86 100644 --- a/phpunit/tests/bureau/class/m_actionTest.php +++ b/phpunit/tests/bureau/class/m_actionTest.php @@ -174,7 +174,7 @@ class m_actionTest extends AlterncTest { */ public function testPurge() { $result = $this->object->purge(); - $this->assertEquals(0, $result); + $this->assertEquals(1, $result); $expectedTable = $this->loadDataSet("actions-empty.yml")->getTable("actions"); $currentTable = $this->getConnection()->createQueryTable('actions', 'SELECT * FROM actions'); $this->assertTablesEqual($expectedTable, $currentTable); diff --git a/phpunit/tests/bureau/class/m_mailTest.php b/phpunit/tests/bureau/class/m_mailTest.php index c1bf6a03..d34b7c76 100644 --- a/phpunit/tests/bureau/class/m_mailTest.php +++ b/phpunit/tests/bureau/class/m_mailTest.php @@ -320,6 +320,9 @@ class m_mailTest extends AlterncTest public function testCreate_alias() { // Test #1580 + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); } /**