X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fsecurity%2FSessionManagerTest.php;h=6830d7146640c0a7b163275d6aa073e9b59eba0a;hb=0640c1a6db6d9a13e5d0079f0bf42497010edbc7;hp=60695dcf944de720ac8e16163ef7df346f434513;hpb=af41d5ab5d2bd3ba64d052c997bc6afa6966a63c;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/security/SessionManagerTest.php b/tests/security/SessionManagerTest.php index 60695dcf..6830d714 100644 --- a/tests/security/SessionManagerTest.php +++ b/tests/security/SessionManagerTest.php @@ -2,7 +2,8 @@ namespace Shaarli\Security; -use PHPUnit\Framework\TestCase; +use Shaarli\FakeConfigManager; +use Shaarli\TestCase; /** * Test coverage for SessionManager @@ -12,7 +13,7 @@ class SessionManagerTest extends TestCase /** @var array Session ID hashes */ protected static $sidHashes = null; - /** @var \FakeConfigManager ConfigManager substitute for testing */ + /** @var FakeConfigManager ConfigManager substitute for testing */ protected $conf = null; /** @var array $_SESSION array for testing */ @@ -24,7 +25,7 @@ class SessionManagerTest extends TestCase /** * Assign reference data */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { self::$sidHashes = \ReferenceSessionIdHashes::getHashes(); } @@ -32,9 +33,9 @@ class SessionManagerTest extends TestCase /** * Initialize or reset test resources */ - public function setUp() + protected function setUp(): void { - $this->conf = new \FakeConfigManager([ + $this->conf = new FakeConfigManager([ 'credentials.login' => 'johndoe', 'credentials.salt' => 'salt', 'security.session_protection_disabled' => false, @@ -207,15 +208,16 @@ class SessionManagerTest extends TestCase 'expires_on' => time() + 1000, 'username' => 'johndoe', 'visibility' => 'public', - 'untaggedonly' => false, + 'untaggedonly' => true, ]; $this->sessionManager->logout(); - $this->assertFalse(isset($this->session['ip'])); - $this->assertFalse(isset($this->session['expires_on'])); - $this->assertFalse(isset($this->session['username'])); - $this->assertFalse(isset($this->session['visibility'])); - $this->assertFalse(isset($this->session['untaggedonly'])); + $this->assertArrayNotHasKey('ip', $this->session); + $this->assertArrayNotHasKey('expires_on', $this->session); + $this->assertArrayNotHasKey('username', $this->session); + $this->assertArrayNotHasKey('visibility', $this->session); + $this->assertArrayHasKey('untaggedonly', $this->session); + $this->assertTrue($this->session['untaggedonly']); } /**