Browse Source

enhance semaphore lock testing

pull/7528/head
Philipp Holzer 1 month ago
parent
commit
1237ac1062
No account linked to committer's email address
1 changed files with 19 additions and 2 deletions
  1. 19
    2
      tests/src/Core/Lock/SemaphoreLockTest.php

+ 19
- 2
tests/src/Core/Lock/SemaphoreLockTest.php View File

@@ -22,7 +22,7 @@ class SemaphoreLockTest extends LockTest
22 22
 		$configMock
23 23
 			->shouldReceive('get')
24 24
 			->with('system', 'temppath', NULL, false)
25
-			->andReturn('/tmp');
25
+			->andReturn('/tmp/');
26 26
 		$dice->shouldReceive('create')->with(Configuration::class)->andReturn($configMock);
27 27
 
28 28
 		// @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
@@ -43,11 +43,13 @@ class SemaphoreLockTest extends LockTest
43 43
 	}
44 44
 
45 45
 	/**
46
-	 * Test if semaphore locking works even for
46
+	 * Test if semaphore locking works even when trying to release locks, where the file exists
47
+	 * but it shouldn't harm locking
47 48
 	 */
48 49
 	public function testMissingFileNotOverriding()
49 50
 	{
50 51
 		$file = get_temppath() . '/test.sem';
52
+		touch($file);
51 53
 
52 54
 		$this->assertTrue(file_exists($file));
53 55
 		$this->assertFalse($this->instance->releaseLock('test', false));
@@ -64,9 +66,24 @@ class SemaphoreLockTest extends LockTest
64 66
 	public function testMissingFileOverriding()
65 67
 	{
66 68
 		$file = get_temppath() . '/test.sem';
69
+		touch($file);
67 70
 
68 71
 		$this->assertTrue(file_exists($file));
69 72
 		$this->assertFalse($this->instance->releaseLock('test', true));
70 73
 		$this->assertTrue(file_exists($file));
71 74
 	}
75
+
76
+	/**
77
+	 * Test acquire lock even the semaphore file exists, but isn't used
78
+	 */
79
+	public function testOverrideSemFile()
80
+	{
81
+		$file = get_temppath() . '/test.sem';
82
+		touch($file);
83
+
84
+		$this->assertTrue(file_exists($file));
85
+		$this->assertTrue($this->instance->acquireLock('test'));
86
+		$this->assertTrue($this->instance->isLocked('test'));
87
+		$this->assertTrue($this->instance->releaseLock('test'));
88
+	}
72 89
 }

Loading…
Cancel
Save