[fix] integration of PR-290 : Fix unit test errors

This commit is contained in:
Benjamin Sonntag 2018-10-22 17:00:38 +02:00
parent b5b8bc3028
commit e67d628e41
7 changed files with 24 additions and 8 deletions

4
.gitignore vendored
View File

@ -42,3 +42,7 @@ bureau/locales/it_IT/LC_MESSAGES/messages.po~
bureau/locales/nl_NL/LC_MESSAGES/messages.po~ bureau/locales/nl_NL/LC_MESSAGES/messages.po~
bureau/locales/pt_BR/LC_MESSAGES/messages.po~ bureau/locales/pt_BR/LC_MESSAGES/messages.po~
.tx/alternc.alternc .tx/alternc.alternc
# Added for running tests; currently not used otherwise
composer.lock
composer.json
vendor/

View File

@ -2,14 +2,16 @@ language: php
services: services:
- mysql - mysql
php: php:
- 7.1
- 7.0 - 7.0
- 5.6 - 5.6
- 5.5 - 5.5
- 5.4 script:
- 5.3 - grep --exclude-dir=../.git/ --exclude-dir=../vendor/ -l -r -e '#!/bin/[bash|sh]' ../ | uniq | xargs shellcheck
script: ../vendor/bin/phpunit --coverage-clover=coverage.clover - ../vendor/bin/phpcs --ignore=../vendor/ ../
- ../vendor/bin/phpunit --coverage-clover=coverage.clover
before_script: 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;' - mysql -e 'create database alternc_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'
- cd phpunit - cd phpunit
after_script: after_script:

View File

@ -241,7 +241,7 @@ class m_action {
* @global m_messages $msg * @global m_messages $msg
* @global m_mysql $db * @global m_mysql $db
* @param type $all * @param type $all
* @return boolean * @return boolean|int The number of rows purged; False is there was an error
*/ */
function purge($all = null) { function purge($all = null) {
global $msg, $db; global $msg, $db;

View File

@ -53,6 +53,11 @@ class m_hooks {
// existe on l'execute et on rajoute ce qu'elle a retourné dans // existe on l'execute et on rajoute ce qu'elle a retourné dans
// un tableau // un tableau
$val = array(); $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) { foreach ($classes as $c) {
global $$c; global $$c;
if (method_exists($$c, $hname)) { if (method_exists($$c, $hname)) {

View File

@ -5,6 +5,8 @@
*/ */
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit\DbUnit\TestCaseTrait; use PHPUnit\DbUnit\TestCaseTrait;
use PHPUnit\DbUnit\DataSet\YamlDataSet;
use PHPUnit\DbUnit\DataSet\CompositeDataSet;
abstract class AlterncTest extends TestCase abstract class AlterncTest extends TestCase
{ {
@ -40,10 +42,10 @@ abstract class AlterncTest extends TestCase
if( !is_file($file) ){ if( !is_file($file) ){
throw new \Exception("missing $file"); throw new \Exception("missing $file");
} }
$dataSet = new PHPUnit_Extensions_Database_DataSet_YamlDataSet($file); $dataSet = new YamlDataSet($file);
$datasetList[] = $dataSet; $datasetList[] = $dataSet;
} }
$compositeDataSet = new PHPUnit_Extensions_Database_DataSet_CompositeDataSet($datasetList); $compositeDataSet = new CompositeDataSet($datasetList);
return $dataSet; return $dataSet;
} }

View File

@ -174,7 +174,7 @@ class m_actionTest extends AlterncTest {
*/ */
public function testPurge() { public function testPurge() {
$result = $this->object->purge(); $result = $this->object->purge();
$this->assertEquals(0, $result); $this->assertEquals(1, $result);
$expectedTable = $this->loadDataSet("actions-empty.yml")->getTable("actions"); $expectedTable = $this->loadDataSet("actions-empty.yml")->getTable("actions");
$currentTable = $this->getConnection()->createQueryTable('actions', 'SELECT * FROM actions'); $currentTable = $this->getConnection()->createQueryTable('actions', 'SELECT * FROM actions');
$this->assertTablesEqual($expectedTable, $currentTable); $this->assertTablesEqual($expectedTable, $currentTable);

View File

@ -320,6 +320,9 @@ class m_mailTest extends AlterncTest
public function testCreate_alias() public function testCreate_alias()
{ {
// Test #1580 // Test #1580
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
} }
/** /**