php-ipc/tests/Sem/SemaphoreTest.php

27 lines
631 B
PHP
Raw Normal View History

2018-04-15 18:48:22 +00:00
<?php
namespace NoccyLabs\Ipc\Sem;
use NoccyLabs\Ipc\Key\FileKey;
class SemaphoreTest extends \PhpUnit\Framework\TestCase
{
public function testCreatingAndAquiringSemaphore()
{
$key = new FileKey(__FILE__);
$sem = new Semaphore($key, 2);
$this->assertTrue($sem->acquire());
$this->assertTrue($sem->acquire());
$this->assertFalse($sem->acquire());
$this->assertTrue($sem->release());
$this->assertTrue($sem->acquire());
$this->assertFalse($sem->acquire());
$this->assertTrue($sem->release());
$this->assertTrue($sem->release());
}
}