/
LogTest.php
64 lines (54 loc) · 1.54 KB
/
LogTest.php
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
namespace Microweber\tests;
class LogTest extends TestCase
{
private $data;
public $value;
public function __construct()
{
$now = date('YmdHis');
$this->value = $now;
$this->data = array (
'value' => $this->value,
'field' => 'log_test',
'rel_type' => 'log_unit_test'
);
}
public function testLogWrite()
{
$data = array();
$data['value'] = $this->value;
$data['field'] = 'log_test';
$data['rel_type'] = 'log_unit_test';
$save = mw()->log_manager->save($data);
$this->assertEquals(true, $save > 0);
}
public function testLogRead()
{
mw()->log_manager->save($this->data);
$data = array();
$data['field'] = 'log_test';
$data['value'] = $this->value;
$get = mw()->log_manager->get($data);
foreach ($get as $item) {
$this->assertEquals($this->value, $item['value']);
}
}
public function testDelete()
{
mw()->log_manager->save($this->data);
$data = array();
$data['field'] = 'log_test';
$get = mw()->log_manager->get($data);
$deleted = array();
foreach ($get as $item) {
$deleted[] = $item['id'];
$del = mw()->log_manager->delete_entry($item);
$this->assertEquals($del, $item['id']);
}
$data = array();
$data['ids'] = $deleted;
$get = mw()->log_manager->get($data);
$this->assertEquals(false, $get);
}
}