function PrivateTempStoreTest::testDelete

Same name in other branches
  1. 8.9.x core/modules/user/tests/src/Unit/PrivateTempStoreTest.php \Drupal\Tests\user\Unit\PrivateTempStoreTest::testDelete()
  2. 8.9.x core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php \Drupal\Tests\Core\TempStore\PrivateTempStoreTest::testDelete()
  3. 10 core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php \Drupal\Tests\Core\TempStore\PrivateTempStoreTest::testDelete()
  4. 11.x core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php \Drupal\Tests\Core\TempStore\PrivateTempStoreTest::testDelete()

Tests the delete() method.

@covers ::delete

File

core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php, line 243

Class

PrivateTempStoreTest
@coversDefaultClass \Drupal\Core\TempStore\PrivateTempStore @group TempStore

Namespace

Drupal\Tests\Core\TempStore

Code

public function testDelete() {
    $this->lock
        ->expects($this->once())
        ->method('acquire')
        ->with('1:test_2')
        ->willReturn(TRUE);
    $this->keyValue
        ->expects($this->exactly(3))
        ->method('get')
        ->withConsecutive([
        '1:test_1',
    ], [
        '1:test_2',
    ], [
        '1:test_3',
    ])
        ->willReturnOnConsecutiveCalls(FALSE, $this->ownObject, $this->otherObject);
    $this->keyValue
        ->expects($this->once())
        ->method('delete')
        ->with('1:test_2');
    $this->assertTrue($this->tempStore
        ->delete('test_1'));
    $this->assertTrue($this->tempStore
        ->delete('test_2'));
    $this->assertFalse($this->tempStore
        ->delete('test_3'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.