25 lines
589 B
PHP
25 lines
589 B
PHP
<?php
|
|
|
|
namespace NoccyLabs\Ipc\Shm;
|
|
|
|
use NoccyLabs\Ipc\Key\FileKey;
|
|
|
|
|
|
|
|
|
|
|
|
class SharedMemoryBlockTest extends \PhpUnit\Framework\TestCase
|
|
{
|
|
public function testWritingAndReading()
|
|
{
|
|
$key = new FileKey(__DIR__);
|
|
$shm = new SharedMemoryBlock($key, SharedMemoryBlock::FLAG_CREATE, 64);
|
|
|
|
$this->assertEquals(11, $shm->write("Hello World", 0));
|
|
$this->assertEquals("Hello World", $shm->read(11, 0));
|
|
$this->assertEquals(3, $shm->write("foo", 2));
|
|
$this->assertEquals("Hefoo World", $shm->read(11, 0));
|
|
|
|
$shm->destroy();
|
|
}
|
|
} |