mirror of
https://github.com/amphp/parallel.git
synced 2025-07-22 05:51:18 +02:00
30 lines
724 B
PHP
30 lines
724 B
PHP
<?php
|
|
|
|
namespace Amp\Parallel\Test\Sync;
|
|
|
|
use Amp\Parallel\Sync\Lock;
|
|
use Amp\PHPUnit\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\Parallel\LockAlreadyReleasedError
|
|
*/
|
|
public function testThrowsOnMultiRelease() {
|
|
$lock = new Lock($this->createCallback(1));
|
|
$lock->release();
|
|
$lock->release();
|
|
}
|
|
}
|