-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSessionTest.php
More file actions
78 lines (62 loc) · 1.73 KB
/
SessionTest.php
File metadata and controls
78 lines (62 loc) · 1.73 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
namespace cases\database;
use ocunit\library\catalog as catalog;
use ocunit\library\MySQLPDO;
use PHPUnit\Framework\TestCase;
/**
* Expensive operations.
*/
class SessionTest extends TestCase
{
public static function setUpBeforeClass(): void
{
self::_truncate();
}
private static function _truncate()
{
$pdo = new MySQLPDO();
$pdo->raw("TRUNCATE TABLE `" . DB_PREFIX . "session`;");
}
public function setUp(): void
{
$this->_delete();
/**
* Just browse the home page.
* It should create a guest session in the database.
*/
$catalog = new catalog();
$index = $catalog->browse_index();
}
private function _delete()
{
$pdo = new MySQLPDO();
$pdo->raw("DELETE FROM `" . DB_PREFIX . "session`;");
}
public function tearDown(): void
{
# $this->delete();
}
/**
* @todo Do NOT run against the live database!
*/
public function testSessionIsCreated()
{
$total = $this->_counter();
$this->assertEquals(1, $total, "Invalid session data count: {$total}.");
}
private function _counter(): int
{
$pdo = new MySQLPDO();
$sql = "SELECT COUNT(*) total FROM `" . DB_PREFIX . "session`;";
$total = (int)$pdo->query($sql)[0]["total"];
return $total;
}
public function testAtLeastOneStoreIsActive()
{
$catalog = new catalog();
$index1 = $catalog->browse_index();
$index2 = $catalog->browse_index();
$total = $this->_counter();
$this->assertTrue($total > 0, "Session not created.");
}
}