3 require_once 'PHPUnit/Framework/TestCase.php';
8 * @package DeprecationsTests
9 * @author Roland Mas <lolando@debian.org>
10 * @copyright 2009 Roland Mas
11 * @license http://www.opensource.org/licenses/gpl-license.php GPL License
13 class Deprecations_Tests extends PHPUnit_Framework_TestCase
16 * Check that no code uses db_query() or db_mquery()
18 public function testdb_query()
20 $output = `cd .. ; find gforge tests -name '*.php' -type f | xargs pcregrep -l '\bdb_m?query\b' \
21 | grep -v ^tests/code/deprecations/DeprecationsTest.php \
22 | grep -v ^gforge/db/upgrade-db.php \
23 | grep -v ^gforge/www/include/database-oci8.php \
24 | grep -v ^gforge/common/include/database-pgsql.php \
25 | grep -v ^gforge/common/include/database-mysql.php`;
26 $this->assertEquals('', $output);
30 * Check that no code uses configuration items from global variables
32 public function testconfig_vars()
34 $vars = array ('sys_name',
35 'sys_user_reg_restricted',
37 'sys_scm_tarballs_path',
38 'sys_scm_snapshots_path',
41 'sys_default_timezone',
42 'sys_default_country_code',
62 'sys_use_project_vhost',
63 'sys_use_project_database',
64 'sys_use_project_multimedia',
67 $pattern = implode ('|', $vars) ;
69 $output = `cd .. ; find gforge tests -name '*.php' -type f | xargs pcregrep -n '\\$($pattern)\b(?! *=[^=])' \
70 | grep -v ^gforge/common/include/config-vars.php`;
71 $this->assertEquals('', $output, "Found deprecated \$var for var in ($pattern):");
73 $output = `cd .. ; find gforge tests -name '*.php' -type f | xargs pcregrep -n '\\\$GLOBALS\\[.?($pattern).?\\](?! *=[^=])' \
74 | grep -v ^gforge/common/include/config-vars.php`;
75 $this->assertEquals('', $output, "Found deprecated \$GLOBALS['\$var'] for var in ($pattern):");
81 // c-file-style: "bsd"