]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Core/Lock/LockTest.php
Rename BlockedServers to ServerBlock
[friendica.git] / tests / src / Core / Lock / LockTest.php
index 2d11a71ae18946c153d726f0c56833d881914995..28f51733f428d9f7748dd0d52fa5a037a50bc047 100644 (file)
@@ -25,24 +25,16 @@ abstract class LockTest extends MockedTest
 
        protected function setUp()
        {
-               parent::setUp();
-               $this->instance = $this->getInstance();
-               $this->instance->releaseAll();
-
                // Reusable App object
                $this->setUpVfsDir();
-               $configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
-               $this->mockApp($this->root, $configMock);
+               $this->mockApp($this->root);
                $this->app
                        ->shouldReceive('getHostname')
                        ->andReturn('friendica.local');
 
-               // Default config
-               $this->mockConfigGet('config', 'hostname', 'localhost');
-               $this->mockConfigGet('system', 'throttle_limit_day', 100);
-               $this->mockConfigGet('system', 'throttle_limit_week', 100);
-               $this->mockConfigGet('system', 'throttle_limit_month', 100);
-               $this->mockConfigGet('system', 'theme', 'system_theme');
+               parent::setUp();
+               $this->instance = $this->getInstance();
+               $this->instance->releaseAll();
        }
 
        protected function tearDown()
@@ -95,7 +87,7 @@ abstract class LockTest extends MockedTest
                $this->assertTrue($this->instance->isLocked('bar'));
                $this->assertTrue($this->instance->isLocked('nice'));
 
-               $this->instance->releaseAll();
+               $this->assertTrue($this->instance->releaseAll());
 
                $this->assertFalse($this->instance->isLocked('foo'));
                $this->assertFalse($this->instance->isLocked('bar'));
@@ -113,18 +105,30 @@ abstract class LockTest extends MockedTest
                $this->assertTrue($this->instance->acquireLock('bar', 1));
                $this->assertTrue($this->instance->acquireLock('nice', 1));
 
-               $this->instance->releaseLock('foo');
+               $this->assertTrue($this->instance->releaseLock('foo'));
 
                $this->assertFalse($this->instance->isLocked('foo'));
                $this->assertTrue($this->instance->isLocked('bar'));
                $this->assertTrue($this->instance->isLocked('nice'));
 
-               $this->instance->releaseAll();
+               $this->assertTrue($this->instance->releaseAll());
 
                $this->assertFalse($this->instance->isLocked('bar'));
                $this->assertFalse($this->instance->isLocked('nice'));
        }
 
+       /**
+        * @small
+        */
+       public function testReleaseWitTTL()
+       {
+               $this->assertFalse($this->instance->isLocked('test'));
+               $this->assertTrue($this->instance->acquireLock('test', 1, 10));
+               $this->assertTrue($this->instance->isLocked('test'));
+               $this->assertTrue($this->instance->releaseLock('test'));
+               $this->assertFalse($this->instance->isLocked('test'));
+       }
+
        /**
         * @medium
         */