deleteIfOwner example

    $this->assertEquals($objects[1]$stores[0]->get($key));

    // This user can update the object.     $stores[0]->set($key$objects[2]);
    $this->assertEquals($objects[2]$stores[0]->get($key));
    // The object is the same when another user loads it.     $this->assertEquals($objects[2]$stores[1]->get($key));

    // This user should be allowed to get, update, delete.     $this->assertInstanceOf(\stdClass::class$stores[0]->getIfOwner($key));
    $this->assertTrue($stores[0]->setIfOwner($key$objects[1]));
    $this->assertTrue($stores[0]->deleteIfOwner($key));

    // Another user can update the object and become the owner.     $stores[1]->set($key$objects[3]);
    $this->assertEquals($objects[3]$stores[0]->get($key));
    $this->assertEquals($objects[3]$stores[1]->get($key));
    $metadata = $stores[1]->getMetadata($key);
    $this->assertEquals($users[1]$metadata->getOwnerId());

    // The first user should be informed that the second now owns the data.     $metadata = $stores[0]->getMetadata($key);
    $this->assertEquals($users[1]$metadata->getOwnerId());

    
'test_3'],
      )
      ->willReturnOnConsecutiveCalls(
        FALSE,
        $this->ownObject,
        $this->otherObject,
      );
    $this->keyValue->expects($this->once())
      ->method('delete')
      ->with('test_2');

    $this->assertTrue($this->tempStore->deleteIfOwner('test_1'));
    $this->assertTrue($this->tempStore->deleteIfOwner('test_2'));
    $this->assertFalse($this->tempStore->deleteIfOwner('test_3'));
  }

  /** * Tests the serialization of a shared temp store. */
  public function testSerialization() {
    // Add an unserializable request to the request stack. If the tempstore     // didn't use DependencySerializationTrait, an exception would be thrown     // when we try to serialize the tempstore.
Home | Imprint | This part of the site doesn't use cookies.