[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/pt_BR/LC_MESSAGES/messages.po~
.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:
- 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:

View File

@ -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;

View File

@ -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)) {

View File

@ -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;
}

View File

@ -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);

View File

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