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

Commit

Permalink
Move customized test files out of library and tweak naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Jun 20, 2014
1 parent 24621fc commit 831c158
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ncss.xml
TestConfig.php
TestsConfig.php
18 changes: 9 additions & 9 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
# limitations under the License.
#=============================================================================

# Create the TestConfig.php file used for testing
# Create the TestsConfig.php file used for testing
option(MIDAS_TEST_COVERAGE "Perform xdebug coverage. Only turn on if you need coverage." OFF)
if(MIDAS_TEST_COVERAGE)
set(MIDAS_TEST_COVERAGE_LITERAL "true")
else()
set(MIDAS_TEST_COVERAGE_LITERAL "false")
endif()
configure_file(${CMAKE_SOURCE_DIR}/tests/TestConfig.php.in ${CMAKE_SOURCE_DIR}/tests/TestConfig.php)
configure_file(${CMAKE_SOURCE_DIR}/tests/TestsConfig.php.in ${CMAKE_SOURCE_DIR}/tests/TestsConfig.php)

# Create the xdebug coverage directory that CTest expects
if(NOT EXISTS ${CMAKE_BINARY_DIR}/xdebugCoverage)
Expand All @@ -46,11 +46,11 @@ endfunction(add_midas_test)
function(add_midas_mysql_test TestName TestFile)
IF(EXISTS ${CMAKE_SOURCE_DIR}/tests/configs/mysql.ini)
add_test(
Mysql${TestName}
${PHP} ${CMAKE_SOURCE_DIR}/tests/library/PHPUnit/mysqlPhpunit.php --bootstrap ${CMAKE_SOURCE_DIR}/tests/bootstrap.php ${CMAKE_CURRENT_SOURCE_DIR}/${TestFile}
MySQL${TestName}
${PHP} ${CMAKE_SOURCE_DIR}/tests/PHPUnitMySQL.php --bootstrap ${CMAKE_SOURCE_DIR}/tests/TestsBootstrap.php ${CMAKE_CURRENT_SOURCE_DIR}/${TestFile}
)
set_tests_properties(
Mysql${TestName} PROPERTIES
MySQL${TestName} PROPERTIES
FAIL_REGULAR_EXPRESSION ".*Failures: [1-9]+.*;.*Exceptions: [1-9]+.*"
RESOURCE_LOCK MIDASDatabase
)
Expand All @@ -60,11 +60,11 @@ endfunction(add_midas_mysql_test)
function(add_midas_pgsql_test TestName TestFile)
IF(EXISTS ${CMAKE_SOURCE_DIR}/tests/configs/pgsql.ini)
add_test(
Pgsql${TestName}
${PHP} ${CMAKE_SOURCE_DIR}/tests/library/PHPUnit/pgsqlPhpunit.php --bootstrap ${CMAKE_SOURCE_DIR}/tests/bootstrap.php ${CMAKE_CURRENT_SOURCE_DIR}/${TestFile}
PgSQL${TestName}
${PHP} ${CMAKE_SOURCE_DIR}/tests/PHPUnitPgSQL.php --bootstrap ${CMAKE_SOURCE_DIR}/tests/TestsBootstrap.php ${CMAKE_CURRENT_SOURCE_DIR}/${TestFile}
)
set_tests_properties(
Pgsql${TestName} PROPERTIES
PgSQL${TestName} PROPERTIES
FAIL_REGULAR_EXPRESSION ".*Failures: [1-9]+.*;.*Exceptions: [1-9]+.*"
RESOURCE_LOCK MIDASDatabase
)
Expand Down Expand Up @@ -99,7 +99,7 @@ if(NOT WIN32)
endif()

add_midas_style_test( StyleKWUtils ${CMAKE_SOURCE_DIR}/library/KWUtils.php )
add_midas_style_test( StyleTestsBootstrap ${CMAKE_SOURCE_DIR}/tests/bootstrap.php )
add_midas_style_test( StyleTestsTestsBootstrap ${CMAKE_SOURCE_DIR}/tests/TestsBootstrap.php )
add_midas_style_test( StyleTestsControllerTestCase ${CMAKE_SOURCE_DIR}/tests/ControllerTestCase.php )
add_midas_style_test( StyleTestsDatabaseSetup ${CMAKE_SOURCE_DIR}/tests/DatabaseSetup.php )
add_midas_style_test( StyleTestsDatabaseTestCase ${CMAKE_SOURCE_DIR}/tests/DatabaseTestCase.php )
Expand Down
4 changes: 2 additions & 2 deletions tests/ControllerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
limitations under the License.
=========================================================================*/

require_once dirname(__FILE__).'/bootstrap.php';
require_once dirname(__FILE__).'/TestConfig.php';
require_once dirname(__FILE__).'/TestsBootstrap.php';
require_once dirname(__FILE__).'/TestsConfig.php';
require_once BASE_PATH.'/core/controllers/components/UtilityComponent.php';

/** main controller test element*/
Expand Down
4 changes: 2 additions & 2 deletions tests/DatabaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
limitations under the License.
=========================================================================*/

require_once dirname(__FILE__).'/bootstrap.php';
require_once dirname(__FILE__).'/TestConfig.php';
require_once dirname(__FILE__).'/TestsBootstrap.php';
require_once dirname(__FILE__).'/TestsConfig.php';
require_once BASE_PATH.'/core/controllers/components/UtilityComponent.php';

/** main models test element */
Expand Down
77 changes: 77 additions & 0 deletions tests/PHPUnitMySQL.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/*=========================================================================
MIDAS Server
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
All rights reserved.
More information http://www.kitware.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/

/* PHPUnit
*
* Copyright (c) 2002-2011, Sebastian Bergmann <[email protected]>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Sebastian Bergmann nor the names of his
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

$base_path = realpath(dirname(__FILE__)) . '/..';
set_include_path(get_include_path() . PATH_SEPARATOR . $base_path . '/tests/library/PHPUnit');

if (!file_exists($base_path . '/tests/configs/mysql.ini')) {
echo 'Failures: 1 Unable to find config';
exit();
}

copy($base_path . '/tests/configs/mysql.ini', $base_path . '/tests/configs/lock.mysql.ini');

require_once 'PHP/CodeCoverage/Filter.php';
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'PHPUNIT');

if (strpos('@php_bin@', '@php_bin') === 0) {
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());
}

require_once 'PHPUnit/Autoload.php';

define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');

PHPUnit_TextUI_Command::main();
77 changes: 77 additions & 0 deletions tests/PHPUnitPgSQL.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/*=========================================================================
MIDAS Server
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
All rights reserved.
More information http://www.kitware.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/

/* PHPUnit
*
* Copyright (c) 2002-2011, Sebastian Bergmann <[email protected]>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Sebastian Bergmann nor the names of his
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

$base_path = realpath(dirname(__FILE__)) . '/..';
set_include_path(get_include_path() . PATH_SEPARATOR . $base_path . '/tests/library/PHPUnit');

if (!file_exists($base_path . '/tests/configs/pgsql.ini')) {
echo 'Failures: 1 Unable to find config';
exit();
}

copy($base_path . '/tests/configs/pgsql.ini', $base_path . '/tests/configs/lock.pgsql.ini');

require_once 'PHP/CodeCoverage/Filter.php';
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'PHPUNIT');

if (strpos('@php_bin@', '@php_bin') === 0) {
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());
}

require_once 'PHPUnit/Autoload.php';

define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');

PHPUnit_TextUI_Command::main();
File renamed without changes.
File renamed without changes.

0 comments on commit 831c158

Please sign in to comment.