1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Tests for Stats Shell. |
5
|
|
|
* |
6
|
|
|
* phpMyAdmin Error reporting server |
7
|
|
|
* Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) |
8
|
|
|
* |
9
|
|
|
* Licensed under The MIT License |
10
|
|
|
* For full copyright and license information, please see the LICENSE.txt |
11
|
|
|
* Redistributions of files must retain the above copyright notice. |
12
|
|
|
* |
13
|
|
|
* @copyright Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) |
14
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License |
15
|
|
|
* |
16
|
|
|
* @see https://www.phpmyadmin.net/ |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace App\Test\TestCase\Shell; |
20
|
|
|
|
21
|
|
|
use Cake\Cache\Cache; |
22
|
|
|
use Cake\Command\Command; |
23
|
|
|
use Cake\TestSuite\ConsoleIntegrationTestTrait; |
24
|
|
|
use Cake\TestSuite\TestCase; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* App\Shell\StatsShell Test Case |
28
|
|
|
*/ |
29
|
|
|
class StatsShellTest extends TestCase |
30
|
|
|
{ |
31
|
|
|
use ConsoleIntegrationTestTrait; |
32
|
|
|
|
33
|
|
|
public function setUp(): void |
34
|
|
|
{ |
35
|
|
|
parent::setUp(); |
36
|
|
|
$this->useCommandRunner(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Test execute method |
41
|
|
|
*/ |
42
|
|
|
public function testExecute(): void |
43
|
|
|
{ |
44
|
|
|
// Clear the existing cache |
45
|
|
|
Cache::clear(); |
46
|
|
|
|
47
|
|
|
// Run the shell command |
48
|
|
|
$this->exec('stats'); |
49
|
|
|
$this->assertExitCode(Command::CODE_SUCCESS); |
50
|
|
|
$Incidents = $this->getTableLocator()->get('Incidents'); |
51
|
|
|
foreach ($Incidents->filterTimes as $filter_string => $filter) { |
52
|
|
|
foreach ($Incidents->summarizableFields as $field) { |
53
|
|
|
// Make sure all the fields are covered |
54
|
|
|
$this->assertNotEquals( |
55
|
|
|
false, |
56
|
|
|
Cache::read($field . '_' . $filter_string) |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
// Make sure download stats value stored |
61
|
|
|
$this->assertNotEquals( |
62
|
|
|
false, |
63
|
|
|
Cache::read('downloadStats_' . $filter_string) |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|