コード例 #1
0
 public function testGetSetStorage()
 {
     $fileA = self::DIR . "/testA.sync";
     $fileB = self::DIR . "/testB.sync";
     $storageA = new StorageFile($fileA);
     $storageB = new StorageFile($fileB);
     $shared = new SharedMemory($storageA);
     $this->assertEquals($storageA, $shared->getStorage());
     $shared->hello = 'world';
     $this->assertEquals('world', $shared->hello);
     $this->assertEquals($storageB, $shared->setStorage($storageB)->getStorage());
     $shared->foo = 'bar';
     $this->assertEquals('bar', $shared->foo);
     $this->assertNull($shared->hello);
     $this->assertEquals($storageA, $shared->setStorage($storageA)->getStorage());
     $this->assertNull($shared->foo);
     $this->assertEquals('world', $shared->hello);
 }