From: James Valleroy <jvalleroy@mailbox.org>
Date: Thu, 30 Dec 2021 10:13:00 -0500
Subject: Patch out tests that use Eloquent\Liberator

Last upstream activity was in 2014, so it is not likely to be
packaged.

Forwarded: not-needed
---
 tests/mutex/FlockMutexTest.php       | 106 -----------------------------------
 tests/mutex/MutexConcurrencyTest.php |  17 ------
 tests/mutex/MutexTest.php            |  17 ------
 3 files changed, 140 deletions(-)
 delete mode 100644 tests/mutex/FlockMutexTest.php

diff --git a/tests/mutex/FlockMutexTest.php b/tests/mutex/FlockMutexTest.php
deleted file mode 100644
index a194563..0000000
--- a/tests/mutex/FlockMutexTest.php
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php
-
-namespace malkusch\lock\mutex;
-
-use Eloquent\Liberator\Liberator;
-use malkusch\lock\exception\DeadlineException;
-use malkusch\lock\exception\TimeoutException;
-use malkusch\lock\util\PcntlTimeout;
-use PHPUnit\Framework\TestCase;
-
-/**
- * @author Willem Stuursma-Ruwen <willem@stuursma.name>
- * @link bitcoin:1P5FAZ4QhXCuwYPnLZdk3PJsqePbu1UDDA Donations
- * @license WTFPL
- * @see CASMutex
- */
-class FlockMutexTest extends TestCase
-{
-    /**
-     * @var FlockMutex
-     */
-    private $mutex;
-
-    /**
-     * @var string
-     */
-    private $file;
-
-    protected function setUp(): void
-    {
-        parent::setUp();
-
-        $this->file = tempnam(sys_get_temp_dir(), 'flock-');
-        $this->mutex = Liberator::liberate(new FlockMutex(fopen($this->file, 'r'), 1)); // @phpstan-ignore-line
-    }
-
-    protected function tearDown(): void
-    {
-        unlink($this->file);
-
-        parent::tearDown();
-    }
-
-    /**
-     * @dataProvider dpTimeoutableStrategies
-     */
-    public function testCodeExecutedOutsideLockIsNotThrown(int $strategy)
-    {
-        $this->mutex->strategy = $strategy; // @phpstan-ignore-line
-
-        $this->assertTrue($this->mutex->synchronized(function (): bool {
-            usleep(1100 * 1000);
-
-            return true;
-        }));
-    }
-
-    /**
-     * @dataProvider dpTimeoutableStrategies
-     */
-    public function testTimeoutOccurs(int $strategy)
-    {
-        $this->expectException(TimeoutException::class);
-        $this->expectExceptionMessage('Timeout of 1 seconds exceeded.');
-
-        $another_resource = fopen($this->file, 'r');
-        flock($another_resource, LOCK_EX);
-
-        $this->mutex->strategy = $strategy; // @phpstan-ignore-line
-
-        try {
-            $this->mutex->synchronized(
-                function () {
-                    $this->fail('Did not expect code to be executed');
-                }
-            );
-        } finally {
-            fclose($another_resource);
-        }
-    }
-
-    public function dpTimeoutableStrategies()
-    {
-        return [
-            [FlockMutex::STRATEGY_PCNTL],
-            [FlockMutex::STRATEGY_BUSY],
-        ];
-    }
-
-    public function testNoTimeoutWaitsForever()
-    {
-        $this->expectException(DeadlineException::class);
-
-        $another_resource = fopen($this->file, 'r');
-        flock($another_resource, LOCK_EX);
-
-        $this->mutex->strategy = FlockMutex::STRATEGY_BLOCK; // @phpstan-ignore-line
-
-        $timebox = new PcntlTimeout(1);
-        $timebox->timeBoxed(function () {
-            $this->mutex->synchronized(function (): void {
-                $this->fail('Did not expect code execution.');
-            });
-        });
-    }
-}
diff --git a/tests/mutex/MutexConcurrencyTest.php b/tests/mutex/MutexConcurrencyTest.php
index d3e4b7f..5ea7873 100644
--- a/tests/mutex/MutexConcurrencyTest.php
+++ b/tests/mutex/MutexConcurrencyTest.php
@@ -2,7 +2,6 @@
 
 namespace malkusch\lock\mutex;
 
-use Eloquent\Liberator\Liberator;
 use PHPUnit\Framework\Constraint\IsType;
 use PHPUnit\Framework\TestCase;
 use Predis\Client;
@@ -235,22 +234,6 @@ class MutexConcurrencyTest extends TestCase
                 return new FlockMutex($file);
             }],
 
-            'flockWithTimoutPcntl' => [function ($timeout = 3) use ($filename): Mutex {
-                $file = fopen($filename, 'w');
-                $lock = Liberator::liberate(new FlockMutex($file, $timeout));
-                $lock->stategy = FlockMutex::STRATEGY_PCNTL; // @phpstan-ignore-line
-
-                return $lock->popsValue();
-            }],
-
-            'flockWithTimoutBusy' => [function ($timeout = 3) use ($filename): Mutex {
-                $file = fopen($filename, 'w');
-                $lock = Liberator::liberate(new FlockMutex($file, $timeout));
-                $lock->stategy = FlockMutex::STRATEGY_BUSY; // @phpstan-ignore-line
-
-                return $lock->popsValue();
-            }],
-
             'semaphore' => [function ($timeout = 3) use ($filename): Mutex {
                 $semaphore = sem_get(ftok($filename, 'b'));
                 $this->assertThat(
diff --git a/tests/mutex/MutexTest.php b/tests/mutex/MutexTest.php
index d5d0437..b743bba 100644
--- a/tests/mutex/MutexTest.php
+++ b/tests/mutex/MutexTest.php
@@ -2,7 +2,6 @@
 
 namespace malkusch\lock\mutex;
 
-use Eloquent\Liberator\Liberator;
 use Memcached;
 use org\bovigo\vfs\vfsStream;
 use PHPUnit\Framework\TestCase;
@@ -56,22 +55,6 @@ class MutexTest extends TestCase
                 return new FlockMutex($file);
             }],
 
-            'flockWithTimoutPcntl' => [function (): Mutex {
-                $file = fopen(vfsStream::url('test/lock'), 'w');
-                $lock = Liberator::liberate(new FlockMutex($file, 3));
-                $lock->stategy = FlockMutex::STRATEGY_PCNTL; // @phpstan-ignore-line
-
-                return $lock->popsValue();
-            }],
-
-            'flockWithTimoutBusy' => [function ($timeout = 3): Mutex {
-                $file = fopen(vfsStream::url('test/lock'), 'w');
-                $lock = Liberator::liberate(new FlockMutex($file, 3));
-                $lock->stategy = FlockMutex::STRATEGY_BUSY; // @phpstan-ignore-line
-
-                return $lock->popsValue();
-            }],
-
             'SemaphoreMutex' => [function (): Mutex {
                 return new SemaphoreMutex(sem_get(ftok(__FILE__, 'a')));
             }],
