mirror of
https://github.com/danog/parallel.git
synced 2025-01-10 06:38:15 +01:00
30 lines
738 B
PHP
30 lines
738 B
PHP
<?php
|
|
|
|
namespace Amp\Concurrent\Test\Sync;
|
|
|
|
use Amp\Concurrent\Sync\Lock;
|
|
use Amp\Concurrent\Test\TestCase;
|
|
|
|
class LockTest extends TestCase {
|
|
public function testIsReleased() {
|
|
$lock = new Lock($this->createCallback(1));
|
|
$this->assertFalse($lock->isReleased());
|
|
$lock->release();
|
|
$this->assertTrue($lock->isReleased());
|
|
}
|
|
|
|
public function testIsReleasedOnDestruct() {
|
|
$lock = new Lock($this->createCallback(1));
|
|
unset($lock);
|
|
}
|
|
|
|
/**
|
|
* @expectedException \Amp\Concurrent\LockAlreadyReleasedError
|
|
*/
|
|
public function testThrowsOnMultiRelease() {
|
|
$lock = new Lock($this->createCallback(1));
|
|
$lock->release();
|
|
$lock->release();
|
|
}
|
|
}
|