Skip to content

Commit 6712f1a

Browse files
committed
add session test
1 parent 8457ac8 commit 6712f1a

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

TODO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@
6666
- [v] Util
6767
- [v] PasswordValidator
6868
- [v] User
69+
- [v] Middleware
70+
- [v] Session
6971
- [ ] Mailer
7072
- [ ] MailTemplateGenerator
7173
- [ ] MailTemplates
7274
- [ ] Server
7375
- [ ] StorageServer
74-
- [-] Session
7576
- [-] SolidNotifications
7677
- [-] SolidPubSub
77-
- [-] Middleware
7878
- [-] Db

tests/phpunit/SessionTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
namespace Pdsinterop\PhpSolid;
3+
4+
use Pdsinterop\PhpSolid\Session;
5+
6+
function session_start($options=[]) {
7+
SessionTest::$sessionOptions = $options;
8+
}
9+
10+
class SessionTest extends \PHPUnit\Framework\TestCase
11+
{
12+
public static $sessionOptions = [];
13+
public function testStart() {
14+
Session::start("alice");
15+
$this->assertEquals($_SESSION['username'], "alice");
16+
$this->assertEquals(self::$sessionOptions, ['cookie_lifetime' => 86400]);
17+
}
18+
19+
public function testGetLoggedInUser() {
20+
Session::start("alice");
21+
$user = Session::getLoggedInUser();
22+
$this->assertEquals($user, "alice");
23+
}
24+
}

0 commit comments

Comments
 (0)