getIfOwner example

$stores[0]->setIfNotExists($key$objects[1]);
    // This time it should succeed.     $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.
->withConsecutive(
        ['test_2'],
        ['test'],
        ['test'],
      )
      ->willReturnOnConsecutiveCalls(
        FALSE,
        $this->ownObject,
        $this->otherObject,
      );

    $this->assertNull($this->tempStore->getIfOwner('test_2'));
    $this->assertSame($this->ownObject->data, $this->tempStore->getIfOwner('test'));
    $this->assertNull($this->tempStore->getIfOwner('test'));
  }

  /** * Tests the set() method with no lock available. * * @covers ::set */
  public function testSetWithNoLockAvailable() {
    $this->lock->expects($this->exactly(2))
      
Home | Imprint | This part of the site doesn't use cookies.