mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/10714] Add unit tests for log class
PHPBB3-10714
This commit is contained in:
parent
7e80e4004e
commit
72d875ebde
1 changed files with 56 additions and 0 deletions
56
tests/log/add_test.php
Normal file
56
tests/log/add_test.php
Normal file
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue