1<?php 2 3namespace dokuwiki\plugin\loglog\test; 4 5/** 6 * Tests for the loglog plugin 7 * 8 * @group plugin_loglog 9 * @group plugins 10 * 11 */ 12class Logging_loglog_test extends \DokuWikiTest 13{ 14 /** 15 * @var \helper_plugin_loglog_logging 16 */ 17 protected $logHelper; 18 19 public function setUp() 20 { 21 $this->pluginsEnabled[] = 'loglog'; 22 parent::setUp(); 23 24 $this->logHelper = plugin_load('helper', 'loglog_logging'); 25 } 26 27 public function test_readLinesInRange() 28 { 29 $min = strtotime('2020-10-01'); 30 $max = strtotime('2020-10-31'); 31 32 $expected = 4; 33 $actual = count($this->logHelper->readLines($min, $max)); 34 35 $this->assertEquals($expected, $actual); 36 } 37 38 public function test_reportStats() 39 { 40 $min = strtotime('2020-11-01'); 41 $max = strtotime('2020-11-30'); 42 $lines = $this->logHelper->readLines($min, $max); 43 44 /** @var \helper_plugin_loglog_report $reportHelper */ 45 $reportHelper = plugin_load('helper', 'loglog_report'); 46 $actual = $reportHelper->getStats($lines); 47 48 $expected = [ 49 \helper_plugin_loglog_main::LOGTYPE_AUTH_OK => 1, 50 \helper_plugin_loglog_main::LOGTYPE_AUTH_FAIL => 2, 51 'users' => 1, 52 'admin' => [ 53 'start' => 1, 54 'usermanager' => 1, 55 ] 56 ]; 57 58 $this->assertEquals($expected, $actual); 59 } 60} 61