1
0
mirror of https://github.com/danog/parallel.git synced 2025-01-10 14:48:18 +01:00
parallel/test/Sync/LockTest.php

30 lines
738 B
PHP
Raw Normal View History

<?php
2016-08-19 00:36:58 +02:00
namespace Amp\Concurrent\Test\Sync;
2016-08-18 18:04:48 +02:00
use Amp\Concurrent\Sync\Lock;
2016-08-19 00:36:58 +02:00
use Amp\Concurrent\Test\TestCase;
2016-08-19 00:36:58 +02:00
class LockTest extends TestCase {
public function testIsReleased() {
$lock = new Lock($this->createCallback(1));
$this->assertFalse($lock->isReleased());
$lock->release();
$this->assertTrue($lock->isReleased());
}
2016-08-19 00:36:58 +02:00
public function testIsReleasedOnDestruct() {
$lock = new Lock($this->createCallback(1));
unset($lock);
}
/**
2016-08-19 00:36:58 +02:00
* @expectedException \Amp\Concurrent\LockAlreadyReleasedError
*/
2016-08-19 00:36:58 +02:00
public function testThrowsOnMultiRelease() {
$lock = new Lock($this->createCallback(1));
$lock->release();
$lock->release();
}
}