From 0dd8a536d001780e7e8786fb717b0ec222b0c57a Mon Sep 17 00:00:00 2001 From: Adam Malone Date: Sat, 4 Apr 2020 00:00:03 +1100 Subject: [PATCH] Adds a test for the lock. --- tests/AcquiaCliApplicationTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/AcquiaCliApplicationTest.php b/tests/AcquiaCliApplicationTest.php index fb75547..5d93ac4 100644 --- a/tests/AcquiaCliApplicationTest.php +++ b/tests/AcquiaCliApplicationTest.php @@ -8,9 +8,12 @@ use AcquiaCli\Cli\AcquiaCli; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Stopwatch\Stopwatch; +use Symfony\Component\Console\Command\LockableTrait; class AcquiaCliApplicationTest extends AcquiaCliTestCase { + use LockableTrait; + private $root; public function setUp() @@ -49,6 +52,18 @@ public function testVersion() $this->assertContains('AcquiaCli 2', $actualValue); } + public function testLock() + { + // Obtain an identical lock and then attempt to run acquiacli. + $this->lock('acquia-cli-command'); + $command = ['--version']; + $actualValue = $this->execute($command); + $this->assertContains('The command is already running in another process.', $actualValue); + + // Unlock to ensure tests are able to continue. + $this->release(); + } + public function testClientOptions() { $command = ['application:list', '--sort=label', '--filter=label=@*sample*', '--limit=2'];