- Timestamp:
- Dec 11, 2013 6:09:07 PM (10 years ago)
- Location:
- branches/eli_branch
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eli_branch/lib/App.inc.php
r442 r446 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 31 31 32 32 //ob_start(); 33 33 34 34 // Message Types. 35 35 define('MSG_ERR', 1); … … 88 88 'session_name' => '_session', 89 89 'session_use_cookies' => true, 90 90 91 91 // Pass the session-id through URLs if cookies are not enabled? 92 92 // Disable this to prevent session ID theft. … … 192 192 // Initialize default parameters. 193 193 $this->_params = array_merge($this->_params, $this->_param_defaults); 194 194 195 195 // Begin timing script. 196 196 require_once dirname(__FILE__) . '/ScriptTimer.inc.php'; … … 246 246 247 247 // Error reporting. 248 /*249 248 ini_set('error_reporting', $this->getParam('error_reporting')); 250 249 ini_set('display_errors', $this->getParam('display_errors')); … … 253 252 ini_set('error_log', $this->getParam('log_directory') . '/' . $this->getParam('php_error_log')); 254 253 } 255 */ 254 256 255 // Set character set to use for multi-byte string functions. 257 256 mb_internal_encoding($this->getParam('character_set')); … … 276 275 277 276 if (true === $this->getParam('enable_db')) { 278 277 279 278 // DB connection parameters taken from environment variables in the httpd.conf file, readable only by root. 280 279 if (!empty($_SERVER['DB_SERVER'])) { … … 367 366 $this->setParam(array('site_url' => sprintf('%s://%s', ('on' == getenv('HTTPS') ? 'https' : 'http'), getenv('HTTP_HOST')))); 368 367 } 369 368 370 369 // In case site_email isn't set, use something halfway presentable. 371 370 if (isset($_SERVER['HTTP_HOST']) && '' != $_SERVER['HTTP_HOST'] && '' == $this->getParam('site_email')) { … … 380 379 // Character set. This should also be printed in the html header template. 381 380 //header('Content-type: text/html; charset=' . $this->getParam('character_set')); 382 381 383 382 // Set the version of the codebase we're using. 384 383 $codebase_version_file = dirname(__FILE__) . '/../docs/version.txt'; … … 438 437 return false; 439 438 } 440 439 441 440 // Avoid duplicate full-stops.. 442 441 $message = trim(preg_replace('/\.{2}$/', '.', $message)); … … 453 452 ); 454 453 } 455 454 456 455 if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) { 457 456 $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_NOTICE, __FILE__, __LINE__); 458 457 } 459 458 } 460 459 461 460 /** 462 461 * Returns an array of the raised messages. … … 476 475 return isset($_SESSION['_app'][$this->_ns]['messages']) ? $_SESSION['_app'][$this->_ns]['messages'] : array(); 477 476 } 478 477 479 478 /** 480 479 * Resets the message list. … … 490 489 return false; 491 490 } 492 491 493 492 $_SESSION['_app'][$this->_ns]['messages'] = array(); 494 493 } … … 507 506 public function printRaisedMessages($above='', $below='', $print_gotohash_js=false, $hash='sc-msg') 508 507 { 509 508 510 509 if (!$this->running) { 511 510 $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__); 512 511 return false; 513 512 } 514 513 515 514 $messages = $this->getRaisedMessages(); 516 515 if (!empty($messages)) { … … 595 594 trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $this->getParam('log_directory')), E_USER_NOTICE); 596 595 } 597 596 598 597 // Before we get any further, let's see if ANY log events are configured to be reported. 599 598 if ((false === $this->getParam('log_file_priority') || $priority > $this->getParam('log_file_priority')) … … 631 630 $site_hash = md5(empty($_SERVER['SERVER_NAME']) ? $_SERVER['SCRIPT_FILENAME'] : $_SERVER['SERVER_NAME']); 632 631 $lock_dir = $this->getParam('tmp_dir') . "/codebase_msgs_$site_hash/"; 633 // Just use the file and line for the msg_id to limit the number of possible messages 632 // Just use the file and line for the msg_id to limit the number of possible messages 634 633 // (the message string itself shan't be used as it may contain innumerable combinations). 635 634 $lock_file = $lock_dir . md5($file . ':' . $line); … … 652 651 } 653 652 } 654 653 655 654 // Data to be stored for a log event. 656 655 $event = array( … … 690 689 mb_send_mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers); 691 690 } 692 691 693 692 // SCREEN ACTION 694 693 if (false !== $this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) { 695 echo "[{$event['type']}] [{$event['message']}]\n";694 file_put_contents('php://stderr', "[{$event['type']}] [{$event['message']}]\n", FILE_APPEND); 696 695 } 697 696 698 697 // Restore original locale. 699 698 setlocale(LC_TIME, $locale); 700 699 701 700 return true; 702 701 } … … 776 775 777 776 /** 778 * dropQuery() is the opposite of carryQuery(). The specified value will not appear in 777 * dropQuery() is the opposite of carryQuery(). The specified value will not appear in 779 778 * url()/ohref()/printHiddenSession() modified URLs unless explicitly written in. 780 * 779 * 781 780 * @access public 782 781 * @param mixed $query_key The key (or keys, as an array) of the query argument to remove. -
branches/eli_branch/tests/AppTest.php
r442 r446 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 30 30 * Created with PHPUnit_Skeleton on 2005-08-09 31 31 */ 32 //33 32 34 33 class AppTest extends PHPUnit_Framework_TestCase { 35 34 36 35 var $App; 37 36 38 37 static $shared_session; 39 38 … … 96 95 { 97 96 $db =& DB::getInstance(); 98 97 99 98 $qid = $db->query("SELECT 2 + 2"); 100 99 list($result) = mysql_fetch_row($qid); -
branches/eli_branch/tests/AuthSQLTest.php
r442 r446 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 33 33 34 34 var $Auth_SQL; 35 35 36 36 static $shared_session; 37 37 38 38 function setUp() 39 39 { … … 76 76 { 77 77 $db =& DB::getInstance(); 78 78 79 79 unset($this->Auth_SQL); 80 80 $db->query("DROP TABLE IF EXISTS test_user_tbl"); … … 145 145 $after_logged_in = $this->Auth_SQL->isloggedin(); 146 146 $this->assertFalse($after_logged_in, '3. User is still logged in but should not be.'); 147 147 148 148 // Testing wrong password. 149 149 $login2 = $this->Auth_SQL->login('testuser', 'wrongpass'); … … 164 164 { 165 165 $db =& DB::getInstance(); 166 166 167 167 $this->Auth_SQL->login('testuser', 'testpass'); 168 168 $this->Auth_SQL->blockaccount(null, 'blocktestuser'); … … 178 178 { 179 179 $db =& DB::getInstance(); 180 180 181 181 $db->query(" 182 182 UPDATE test_user_tbl SET blocked_reason = 'blocktestuser' … … 240 240 { 241 241 $db =& DB::getInstance(); 242 242 243 243 $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1_HARDENED)); 244 244 $this->Auth_SQL->setpassword(null, '123'); … … 255 255 $result = $this->Auth_SQL->resetpassword(1, 'Because this is a test.'); 256 256 $this->assertInternalType('array', $result); 257 257 258 258 } 259 259 -
branches/eli_branch/tests/Auth_FileTest.php
r438 r446 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. -
branches/eli_branch/tests/Auth_SQLTest.php
r438 r446 30 30 * Created with PHPUnit_Skeleton on 2005-08-09 31 31 */ 32 require_once 'PHPUnit.php'; 32 33 33 class Auth_SQLTest extends PHPUnit_TestCase { 34 34 -
branches/eli_branch/tests/_config.inc.php
r442 r446 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 28 28 */ 29 29 require_once '../lib/App.inc.php'; 30 31 $_SERVER['DB_SERVER'] = 'localhost';32 $_SERVER['DB_USER'] = 'sc';33 $_SERVER['DB_NAME'] = 'sc_db';34 $_SERVER['DB_PASS'] = '1234';35 30 36 31 $app =& App::getInstance('testapp'); -
branches/eli_branch/tests/bootstrap.php
r442 r446 1 1 <?php 2 session_start();3 // set_include_path(get_include_path() . PATH_SEPARATOR . '../..');4 ini_set('include_path',get_include_path().PATH_SEPARATOR.'/opt'.PATH_SEPARATOR.'..');5 // die(get_include_path());2 // session_start(); 3 // //set_include_path(get_include_path() . PATH_SEPARATOR . '../..'); 4 // ini_set('include_path',get_include_path().PATH_SEPARATOR.'/opt'.PATH_SEPARATOR.'..'); 5 // //die(get_include_path()); -
branches/eli_branch/tests/phpunit.xml
r442 r446 1 <php 1 <!-- 2 For config options see: 3 http://phpunit.de/manual/current/en/appendixes.configuration.html 4 5 Run all scripts by executing ./run_tests.sh 6 --> 7 <phpunit 2 8 convertErrorsToExceptions="false" 3 9 convertNoticesToExceptions="false" 4 10 convertWarningsToExceptions="false" 5 11 bootstrap="bootstrap.php" 12 strict="true" 13 verbose="true" 14 debug="true" 15 tap="true" 16 stopOnError="true" 17 stopOnFailure="true" 18 stopOnIncomplete="false" 19 stopOnSkipped="true" 6 20 > 7 <includePath>.</includePath> 8 <includePath>/opt</includePath> 9 <env name="DB_NAME" value="sc_db"/> 10 <env name="DB_USER" value="sc"/> 11 <env name="DB_PASS" value="1234"/> 12 <env name="DB_SERVER" value="localhost"/> 13 <testsuites> 14 <testsuite name="Codebase_Tests"> 15 <file>AppTest.php</file> 16 <file>AuthFileTest.php</file> 17 <file>AuthorizeNetTest.php</file> 18 <file>AuthSQLTest.php</file> 19 <file>CSSTest.php</file> 20 <file>DBSessionHandlerTest.php</file> 21 <file>EmailTest.php</file> 22 <file>FormValidatorTest.php</file> 23 <file>LockTest.php</file> 24 <file>PayPalTest.php</file> 25 <file>VersionTest.php</file> 26 </testsuite> 27 </testsuites> 28 </php> 21 <includePath>.</includePath> 22 <includePath>/opt</includePath> 23 <testsuites> 24 <testsuite name="Codebase_Tests"> 25 <file>AppTest.php</file> 26 <file>AuthFileTest.php</file> 27 <file>AuthorizeNetTest.php</file> 28 <file>AuthSQLTest.php</file> 29 <file>CSSTest.php</file> 30 <file>DBSessionHandlerTest.php</file> 31 <file>EmailTest.php</file> 32 <file>FormValidatorTest.php</file> 33 <file>LockTest.php</file> 34 <file>PayPalTest.php</file> 35 <file>VersionTest.php</file> 36 </testsuite> 37 </testsuites> 38 </phpunit> -
branches/eli_branch/tests/run_tests.sh
r399 r446 1 1 #!/bin/sh 2 3 # This script sets-up the test environment and runs all tests. 4 # You'll want to define your local mysql credentials for a test 5 # database as environment variables, e.g., in ~/.bash_profile: 6 # export DB_NAME="test" 7 # export DB_USER="test" 8 # export DB_PASS="..." 2 9 3 10 # Be in the directory with all the tests. 4 11 cd `dirname $0`; 5 12 13 # Get required ENV variables. 14 if [[ -z "$DB_USER$DB_PASS$DB_NAME" ]]; then 15 echo "MySQL test DB credential environment variables are missing.\nSet these in ~/.bash_profile to avoid seeing these prompts each time."; 16 fi 17 for E in DB_USER DB_PASS DB_NAME; do 18 while [[ -z ${!E} ]]; do 19 read -p "$E: " $E; 20 done 21 export $E; 22 done 23 6 24 # Create database. 7 25 mysql -e 'CREATE DATABASE IF NOT EXISTS `test`'; 8 26 9 # Run tests sequentially. 10 for foo in *Test.php; 11 do 12 php $foo; 13 done; 27 # Go! 28 echo "Running the tests!"; 29 echo "You'll want to 'tail -f /tmp/codebase_test_log' and watch for errors."; 30 31 # Config options go in phpunit.xml 32 # phpunit --tap | grep -v '^ok ' 33 phpunit
Note: See TracChangeset
for help on using the changeset viewer.