diff options
author | LEDfan <tobia@ledfan.be> | 2016-01-20 12:30:25 +0300 |
---|---|---|
committer | LEDfan <tobia@ledfan.be> | 2016-01-20 12:30:25 +0300 |
commit | ff9bb25a8c844221c69a001cc20a6520ba052d91 (patch) | |
tree | 3bb129062258ca4136ea819431122c2ff5c5f293 /tests/integration | |
parent | 5fc9eb463f29351ab448a51978b6e06c5e7528e5 (diff) |
Setup redis at travis to test the MemLock
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/MemLockTest.php | 94 |
1 files changed, 94 insertions, 0 deletions
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 @@ +<?php +namespace OCA\OJSXC; + +use OCP\AppFramework\Db\DoesNotExistException; +use Test\TestCase; +use OCA\OJSXC\AppInfo\Application; +use OCA\OJSXC\MemLock; + +//function time() { +// return DbLockTest::$time; +//} + +/** + * @group DB + */ +class MemLockTest extends TestCase { + + /** + * @var \OCA\OJSXC\MemLock + */ + private $memLock; + + /** + * @var \OCA\OJSXC\MemLock + */ + private $memLock2; + + /** + * @var \OCP\AppFramework\IAppContainer + */ + private $container; + + public static $time; + + public function setUp() { + parent::setUp(); + $app = new Application(); + $this->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 |