1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
<?php
/**
* Piwik - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Tests\Integration\DataAccess;
use Piwik\Common;
use Piwik\DataAccess\Actions;
use Piwik\Db;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
/**
* @group Core
*/
class ActionsTest extends IntegrationTestCase
{
/**
* @var Actions
*/
private $actionsAccess;
public function setUp(): void
{
parent::setUp();
$this->insertTestActions();
$this->actionsAccess = new Actions();
}
public function test_delete_DeletesSpecifiedActions()
{
$this->actionsAccess->delete(array(2,3,4,5));
$expectedActions = array(
array('name' => 'action1')
);
$actualActions = Db::fetchAll("SELECT name FROM ".Common::prefixTable('log_action'));
$this->assertEquals($expectedActions, $actualActions);
}
public function test_delete_ConvertsIdActionsToInt()
{
$this->actionsAccess->delete(array("2", "0, 1"));
$expectedActions = array(
array('name' => 'action1'),
array('name' => 'action3')
);
$actualActions = Db::fetchAll("SELECT name FROM ".Common::prefixTable('log_action'));
$this->assertEquals($expectedActions, $actualActions);
}
private function insertTestActions()
{
Db::query("INSERT INTO " . Common::prefixTable('log_action') . " (name, type, hash)
VALUES ('action1', 1, CRC32('action1')),
('action2', 1, CRC32('action2')),
('action3', 1, CRC32('action3'))");
}
}
|