diff --git a/tests/lib/SimpleSAML/SessionTest.php b/tests/lib/SimpleSAML/SessionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e057d3bc3b972552d476823e40ed47deeb15f043 --- /dev/null +++ b/tests/lib/SimpleSAML/SessionTest.php @@ -0,0 +1,49 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\Utils; + +use PHPUnit\Framework\TestCase; +use SimpleSAML\Test\Utils\ClearStateTestCase; +use SimpleSAML\Session; +use SimpleSAML\Configuration; + +class SessionTest extends ClearStateTestCase +{ + /** @var \SimpleSAML\Session */ + protected $session; + + /** + * @return void + */ + public function setUp(): void + { + $this->session = Session::getSessionFromRequest(); + } + + /** + * @return void + */ + public function testSetRememberMeExpireDefaults(): void + { + // Not yet set + $this->assertNull($this->session->getRememberMeExpire()); + + // Set to default value + $this->session->setRememberMeExpire(); + + $this->assertEquals(time() + 14 * 86400, $this->session->getRememberMeExpire()); + } + + /** + * @return void + */ + public function testSetRememberMeExpireExplicit(): void + { + // Set to specific value + $this->session->setRememberMeExpire(1000); + + $this->assertEquals(time() + 1000, $this->session->getRememberMeExpire()); + } +}