From ff9bb25a8c844221c69a001cc20a6520ba052d91 Mon Sep 17 00:00:00 2001 From: LEDfan Date: Wed, 20 Jan 2016 10:30:25 +0100 Subject: Setup redis at travis to test the MemLock --- tests/integration/MemLockTest.php | 94 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 tests/integration/MemLockTest.php (limited to 'tests/integration') diff --git a/tests/integration/MemLockTest.php b/tests/integration/MemLockTest.php new file mode 100644 index 0000000..465c82b --- /dev/null +++ b/tests/integration/MemLockTest.php @@ -0,0 +1,94 @@ +container = $app->getContainer(); + } + + /** + * Tests the setLock and stillLocked function by setting up and lock + * and then setting a new lock. + */ + public function testLock() { + self::$time = 4; + $this->memLock = new MemLock( + 'john', + $this->container->getServer()->getMemCacheFactory() + ); + $this->memLock->setLock(); + + +// $result = $this->fetchLocks(); +// $this->assertCount(1, $result); +// $this->assertEquals($result[0]['userid'], 'john'); +// $this->assertEquals($result[0]['appid'], 'ojsxc'); +// $this->assertEquals($result[0]['configkey'], 'longpolling'); +// $this->assertEquals($result[0]['configvalue'], '4'); + $this->assertTrue($this->memLock->stillLocked()); +// +// +// self::$time = 5; +// $this->dbLock2 = new DbLock( +// 'john', +// $this->container->getServer()->getDb(), +// $this->container->getServer()->getConfig() +// ); // simulate new lock/request +// $this->dbLock2->setLock(); +// +// $this->assertFalse($this->dbLock->stillLocked()); +// $this->assertTrue($this->dbLock2->stillLocked()); +// $result = $this->fetchLocks(); +// $this->assertCount(1, $result); +// $this->assertEquals($result[0]['userid'], 'john'); +// $this->assertEquals($result[0]['appid'], 'ojsxc'); +// $this->assertEquals($result[0]['configkey'], 'longpolling'); +// $this->assertEquals($result[0]['configvalue'], '5'); +// $this->assertTrue($this->dbLock2->stillLocked()); + + } + + private function fetchLocks() { +// $stmt = $this->con->executeQuery("SELECT * FROM `*PREFIX*preferences` WHERE `appid`='ojsxc' AND `configkey`='longpolling'"); +// +// $reuslt = []; +// +// while($row = $stmt->fetch()){ +// $result[] = $row; +// } +// return $result; + } + +} \ No newline at end of file -- cgit v1.2.3