Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Update to PHPUnit 4.3 and fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Nov 15, 2014
1 parent 6a8a9d6 commit d4d9233
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ php:
- 5.6

before_install:
- composer self-update
- composer self-update -n

install:
- composer install
- composer install -n --prefer-dist

before_script:
- cp tests/travis/mysql.ini tests/configs/mysql.ini
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ message(STATUS "Setting up database(s) for testing - done")

include(CTest)
option(MIDAS_RUN_STYLE_TESTS "Run PHP style tests?" ON)
option(MIDAS_RUN_TESTS_WITH_COVERAGE "Run tests with coverage?" OFF)

add_subdirectory(tests)
add_subdirectory(core/tests)
Expand Down
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"ext-fileinfo": "*",
"ext-gd": "*",
"ext-json": "*",
"francodacosta/phMagick": "0.4.*@dev",
"intervention/image": "~2.0.12",
"francodacosta/phmagick": "0.4.*@dev",
"intervention/image": "~2.0.13",
"leafo/scssphp": "~0.1.1",
"maennchen/zipstream-php": "~0.2.2",
"michelf/php-markdown": "~1.4.1",
Expand All @@ -27,10 +27,12 @@
},
"require-dev": {
"ext-curl": "*",
"fabpot/php-cs-fixer": "~0.5.7",
"fabpot/php-cs-fixer": "~1.0",
"phpcheckstyle/phpcheckstyle": "V0.14.1",
"phpunit/dbunit": "~1.3.1",
"phpunit/phpunit": "~3.7.38",
"phpunit/dbunit": "1.3.*@dev",
"phpunit/php-code-coverage": "~2.0.11",
"phpunit/phpcov": "~2.0.1",
"phpunit/phpunit": "~4.3.5",
"satooshi/php-coveralls": "~0.6.1",
"sensiolabs/security-checker": "~2.0.0"
},
Expand Down
2 changes: 0 additions & 2 deletions core/configs/application.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ application.description =
application.lang = en
; session lifetime (minute)
session.lifetime = 20
; path to md5sum
md5sum.path =
; default assetstore
defaultassetstore.id =
; default timezone
Expand Down
6 changes: 2 additions & 4 deletions core/controllers/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class UploadController extends AppController
{
public $_components = array('Upload');
public $_forms = array('Upload');
public $_models = array('Assetstore', 'Folder', 'Folderpolicygroup', 'Folderpolicyuser', 'Item', 'License');
public $_models = array('Assetstore', 'Folder', 'Folderpolicygroup', 'Folderpolicyuser', 'Item', 'License', 'Setting');

/** Init controller */
public function init()
Expand All @@ -48,9 +48,7 @@ public function init()
} else {
$assetstoreDao = $assetstores[0];
}
$config = Zend_Registry::get('configGlobal');
$config->defaultassetstore->id = $assetstoreDao->getKey();
Zend_Registry::set('configGlobal', $config);
$this->Setting->setConfig('default_assetstore', $assetstoreDao->getKey());
}
}

Expand Down
7 changes: 5 additions & 2 deletions core/controllers/components/UtilityComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,11 @@ public static function createInitFile($path, $data)
public static function md5file($filename)
{
// If we have md5 sum
if (Zend_Registry::get('configGlobal')->md5sum->path) {
$result = exec(Zend_Registry::get('configGlobal')->md5sum->path.' '.$filename);
$settingModel = MidasLoader::loadModel('Setting');
$md5sumCommand = $settingModel->getValueByName('md5sum_command');

if (!empty($md5sumCommand)) {
$result = exec($md5sumCommand.' '.$filename);
$resultarray = explode(' ', $result);

return $resultarray[0];
Expand Down
7 changes: 2 additions & 5 deletions modules/javauploaddownload/controllers/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class Javauploaddownload_UploadController extends Javauploaddownload_AppController
{
public $_components = array('Httpupload', 'Upload');
public $_models = array('Assetstore', 'Folder', 'Item', 'License');
public $_models = array('Assetstore', 'Folder', 'Item', 'License', 'Setting');

private function _is_https()
{
Expand All @@ -45,10 +45,7 @@ public function init()
} else {
$assetstoreDao = $assetstores[0];
}

$config = Zend_Registry::get('configGlobal');
$config->defaultassetstore->id = $assetstoreDao->getKey();
Zend_Registry::set('configGlobal', $config);
$this->Setting->setConfig('default_assetstore', $assetstoreDao->getKey());
}
}

Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/3.7/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.3/phpunit.xsd"
bootstrap="tests/TestsBootstrap.php"
colors="true">
<testsuites>
Expand Down
16 changes: 13 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
# limitations under the License.
#=============================================================================

if(MIDAS_RUN_TESTS_WITH_COVERAGE)
if(EXISTS ${CMAKE_BINARY_DIR}/cov)
file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/cov)
endif()
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/cov)
endif()

macro(to_titlecase Arg Result)
string(SUBSTRING ${Arg} 0 1 ArgHead)
string(TOUPPER ${ArgHead} ArgHead)
Expand All @@ -32,9 +39,10 @@ endfunction()

function(add_midas_mysql_test TestName TestFile)
if(EXISTS ${CMAKE_SOURCE_DIR}/tests/configs/mysql.ini)
set(TestParams --debug --bootstrap ${CMAKE_SOURCE_DIR}/tests/TestsBootstrap.php)
add_test(
MySQL${TestName}
${PHP} ${CMAKE_SOURCE_DIR}/tests/PHPUnitMySQL.php --debug --bootstrap ${CMAKE_SOURCE_DIR}/tests/TestsBootstrap.php ${CMAKE_CURRENT_SOURCE_DIR}/${TestFile}
${PHP} ${CMAKE_SOURCE_DIR}/tests/PHPUnitMySQL.php ${TestParams} ${CMAKE_CURRENT_SOURCE_DIR}/${TestFile}
)
set_tests_properties(
MySQL${TestName} PROPERTIES
Expand All @@ -46,9 +54,10 @@ endfunction()

function(add_midas_pgsql_test TestName TestFile)
if(EXISTS ${CMAKE_SOURCE_DIR}/tests/configs/pgsql.ini)
set(TestParams --debug --bootstrap ${CMAKE_SOURCE_DIR}/tests/TestsBootstrap.php)
add_test(
PgSQL${TestName}
${PHP} ${CMAKE_SOURCE_DIR}/tests/PHPUnitPgSQL.php --debug --bootstrap ${CMAKE_SOURCE_DIR}/tests/TestsBootstrap.php ${CMAKE_CURRENT_SOURCE_DIR}/${TestFile}
${PHP} ${CMAKE_SOURCE_DIR}/tests/PHPUnitPgSQL.php ${TestParams} ${CMAKE_CURRENT_SOURCE_DIR}/${TestFile}
)
set_tests_properties(
PgSQL${TestName} PROPERTIES
Expand All @@ -60,9 +69,10 @@ endfunction()

function(add_midas_sqlite_test TestName TestFile)
if(EXISTS ${CMAKE_SOURCE_DIR}/tests/configs/sqlite.ini)
set(TestParams --debug --bootstrap ${CMAKE_SOURCE_DIR}/tests/TestsBootstrap.php)
add_test(
SQLite${TestName}
${PHP} ${CMAKE_SOURCE_DIR}/tests/PHPUnitSQLite.php --debug --bootstrap ${CMAKE_SOURCE_DIR}/tests/TestsBootstrap.php ${CMAKE_CURRENT_SOURCE_DIR}/${TestFile}
${PHP} ${CMAKE_SOURCE_DIR}/tests/PHPUnitSQLite.php ${TestParams} ${CMAKE_CURRENT_SOURCE_DIR}/${TestFile}
)
set_tests_properties(
SQLite${TestName} PROPERTIES
Expand Down

0 comments on commit d4d9233

Please sign in to comment.