From 5120088706ee6f1d723d8d5a4d58407f6cd3a28a Mon Sep 17 00:00:00 2001 From: Avior Date: Thu, 18 Apr 2019 00:44:00 +0200 Subject: [PATCH] Started working on Cache testing --- tests/SessionCacheTest.php | 89 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 tests/SessionCacheTest.php diff --git a/tests/SessionCacheTest.php b/tests/SessionCacheTest.php new file mode 100644 index 0000000..3c01ee4 --- /dev/null +++ b/tests/SessionCacheTest.php @@ -0,0 +1,89 @@ +session = new SessionCache(); + } + + public function testCacheCanStart() + { + $this->assertEquals( + session_status(), + PHP_SESSION_ACTIVE + ); + } + + public function testCanSet() + { + + $this->assertEquals( + true, + $this->session->set("key", "value") + ); + } + + public function testCanGet() + { + $this->assertTrue( + $this->session->set("key", "value") + ); + $this->assertEquals( + 'value', + $this->session->get('key') + ); + } + + + public function testCanDelete() + { + $this->assertTrue( + $this->session->set("key", "value") + ); + $this->assertTrue( + $this->session->delete('key') + ); + $this->assertNull( + $this->session->get('key') + ); + } + + public function testCanSetGetMultiple() + { + + $this->assertTrue( + $this->session->setMultiple(array( + "key1" => "value", + "key2" => "value" + )) + ); + + $result = $this->session->getMultiple(array( + "key1", + "key2" + )); + $this->assertEquals( + "value", + $result["key1"] + ); + $this->assertEquals( + "value", + $result["key2"] + ); + + $this->assertTrue( + $this->session->deleteMultiple(array( + "key1", + "key2" + )) + ); + } +}