diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2012-03-18 12:23:32 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2012-08-21 11:59:28 +0200 |
commit | 72d875ebdee08f8c6af7c016b15d3e89442ed0e1 (patch) | |
tree | c498142e48aebcf5a57d992002209c5bc81933e3 /tests | |
parent | 7e80e4004e92ddcf3ad147d05d43bb411010e9e0 (diff) | |
download | forums-72d875ebdee08f8c6af7c016b15d3e89442ed0e1.tar forums-72d875ebdee08f8c6af7c016b15d3e89442ed0e1.tar.gz forums-72d875ebdee08f8c6af7c016b15d3e89442ed0e1.tar.bz2 forums-72d875ebdee08f8c6af7c016b15d3e89442ed0e1.tar.xz forums-72d875ebdee08f8c6af7c016b15d3e89442ed0e1.zip |
[ticket/10714] Add unit tests for log class
PHPBB3-10714
Diffstat (limited to 'tests')
-rw-r--r-- | tests/log/add_test.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/log/add_test.php b/tests/log/add_test.php new file mode 100644 index 0000000000..a2b763f2b7 --- /dev/null +++ b/tests/log/add_test.php @@ -0,0 +1,56 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_log_add_test extends phpbb_database_test_case +{ + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/empty_log.xml'); + } + + public function test_log_enabled() + { + $log = new phpbb_log(LOG_TABLE); + $this->assertTrue($log->is_enabled()); + + $log->disable(); + $this->assertFalse($log->is_enabled()); + + $log->enable(); + $this->assertTrue($log->is_enabled()); + } + + public function test_log_add() + { + global $db; + + $db = $this->new_dbal(); + + $mode = 'critical'; + $user_id = ANONYMOUS; + $log_ip = 'user_ip'; + $log_time = time(); + $log_operation = 'LOG_OPERATION'; + $additional_data = array(); + + // Add an entry successful + $log = new phpbb_log(LOG_TABLE); + $this->assertEquals(1, $log->add($mode, $user_id, $log_ip, $log_operation, $log_time)); + + // Disable logging + $log->disable(); + $this->assertFalse($log->add($mode, $user_id, $log_ip, $log_operation, $log_time)); + $log->enable(); + + // Invalid mode specified + $this->assertFalse($log->add('mode_does_not_exist', $user_id, $log_ip, $log_operation, $log_time)); + } +} |