Skip to content

Commit

Permalink
Qual: Add error message if using wrong parameter into upgrade.php script
Browse files Browse the repository at this point in the history
First try to test migration into travis.
  • Loading branch information
eldy committed Jan 15, 2014
1 parent aa69927 commit b3229a4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 41 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Expand Up @@ -56,7 +56,7 @@ before_script:
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE DATABASE myapp_test;' -U postgres; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'DROP DATABASE IF EXISTS myapp_test;'; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE IF NOT EXISTS myapp_test;'; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -D myapp_test < $(pwd)/dev/initdata/mysqldump_dolibarr_3.5.0.sql; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -D myapp_test < $(pwd)/dev/initdata/mysqldump_dolibarr_3.4.0.sql; fi"
- echo Create config file htdocs/conf/conf.php
- echo '<?php ' > htdocs/conf/conf.php
- sh -c "if [ '$DB' = 'pgsql' ]; then echo '$'dolibarr_main_db_type=\'pgsql\'';' >> htdocs/conf/conf.php; fi"
Expand Down Expand Up @@ -84,13 +84,14 @@ before_script:


script:
- cd htdocs/install; php upgrade.php 3.4.0 3.5.0
# - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml --coverage-text test/phpunit/AllTests.php
# - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml --coverage-text test/phpunit/BuildDocTest.php
# - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/WebservicesOtherTest.php
# - phpcs --warning-severity=0 -s --report-checkstyle --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ htdocs/core/class/dolgraph.class.php
- phpcs --warning-severity=0 -s --report-checkstyle --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ .
# - phpcs --warning-severity=0 -s --report-checkstyle --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ .
# - phpcs --warning-severity=0 -s --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ .
- phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/AllTests.php
# - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/AllTests.php

after_script:
# - echo Output dolibarr log file; cat $(pwd)/htdocs/documents/dolibarr.log
Expand Down
83 changes: 45 additions & 38 deletions htdocs/install/upgrade.php
Expand Up @@ -365,47 +365,54 @@
}
}

// Loop on each migrate files
foreach($filelist as $file)
if (count($filelist) == 0)
{
print '<tr><td colspan="2"><hr></td></tr>';
print '<tr><td class="nowrap">'.$langs->trans("ChoosedMigrateScript").'</td><td align="right">'.$file.'</td></tr>'."\n";

// Run sql script
$ok=run_sql($dir.$file, 0, '', 1);

// Scan if there is migration scripts for modules htdocs/module/sql or htdocs/custom/module/sql
$modulesfile = array();
foreach ($conf->file->dol_document_root as $type => $dirroot)
{
$handlemodule=@opendir($dirroot); // $dirroot may be '..'
if (is_resource($handlemodule))
{
while (($filemodule = readdir($handlemodule))!==false)
{
if (! preg_match('/\./',$filemodule) && is_dir($dirroot.'/'.$filemodule.'/sql')) // We exclude filemodule that contains . (are not directories) and are not directories.
{
//print "Scan for ".$dirroot . '/' . $filemodule . '/sql/'.$file;
if (is_file($dirroot . '/' . $filemodule . '/sql/'.$file))
{
$modulesfile[$dirroot . '/' . $filemodule . '/sql/'.$file] = '/' . $filemodule . '/sql/'.$file;
}
}
}
closedir($handlemodule);
}
}

foreach ($modulesfile as $modulefilelong => $modulefileshort)
{
print '<tr><td colspan="2"><hr></td></tr>';
print '<tr><td class="nowrap">'.$langs->trans("ChoosedMigrateScript").' (external modules)</td><td align="right">'.$modulefileshort.'</td></tr>'."\n";
print '<div class="error">'.$langs->trans("ErrorNoMigrationFilesFoundForParameters").'</div>';
}
else
{
// Loop on each migrate files
foreach($filelist as $file)
{
print '<tr><td colspan="2"><hr></td></tr>';
print '<tr><td class="nowrap">'.$langs->trans("ChoosedMigrateScript").'</td><td align="right">'.$file.'</td></tr>'."\n";

// Run sql script
$okmodule=run_sql($modulefilelong, 0, '', 1); // Note: Result of migration of external module should not decide if we continue migration of Dolibarr or not.
}

}
$ok=run_sql($dir.$file, 0, '', 1);

// Scan if there is migration scripts for modules htdocs/module/sql or htdocs/custom/module/sql
$modulesfile = array();
foreach ($conf->file->dol_document_root as $type => $dirroot)
{
$handlemodule=@opendir($dirroot); // $dirroot may be '..'
if (is_resource($handlemodule))
{
while (($filemodule = readdir($handlemodule))!==false)
{
if (! preg_match('/\./',$filemodule) && is_dir($dirroot.'/'.$filemodule.'/sql')) // We exclude filemodule that contains . (are not directories) and are not directories.
{
//print "Scan for ".$dirroot . '/' . $filemodule . '/sql/'.$file;
if (is_file($dirroot . '/' . $filemodule . '/sql/'.$file))
{
$modulesfile[$dirroot . '/' . $filemodule . '/sql/'.$file] = '/' . $filemodule . '/sql/'.$file;
}
}
}
closedir($handlemodule);
}
}

foreach ($modulesfile as $modulefilelong => $modulefileshort)
{
print '<tr><td colspan="2"><hr></td></tr>';
print '<tr><td class="nowrap">'.$langs->trans("ChoosedMigrateScript").' (external modules)</td><td align="right">'.$modulefileshort.'</td></tr>'."\n";

// Run sql script
$okmodule=run_sql($modulefilelong, 0, '', 1); // Note: Result of migration of external module should not decide if we continue migration of Dolibarr or not.
}

}
}
}

print '</table>';
Expand Down

0 comments on commit b3229a4

Please sign in to comment.