function WriteSafeSessionHandlerTest::testOtherMethods

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php \Drupal\Tests\Core\Session\WriteSafeSessionHandlerTest::testOtherMethods()
  2. 8.9.x core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php \Drupal\Tests\Core\Session\WriteSafeSessionHandlerTest::testOtherMethods()
  3. 11.x core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php \Drupal\Tests\Core\Session\WriteSafeSessionHandlerTest::testOtherMethods()

Tests that other invocations are passed unmodified to the wrapped handler.

@covers ::setSessionWritable
@covers ::open
@covers ::read
@covers ::close
@covers ::destroy
@covers ::gc
@dataProvider providerTestOtherMethods

File

core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php, line 139

Class

WriteSafeSessionHandlerTest
Tests \Drupal\Core\Session\WriteSafeSessionHandler.

Namespace

Drupal\Tests\Core\Session

Code

public function testOtherMethods($method, $expected_result, $args) : void {
  $invocation = $this->wrappedSessionHandler
    ->expects($this->exactly(2))
    ->method($method)
    ->willReturn($expected_result);
  // Set the parameter matcher.
  call_user_func_array([
    $invocation,
    'with',
  ], $args);
  // Test with writable session.
  $this->assertTrue($this->sessionHandler
    ->isSessionWritable());
  $actual_result = call_user_func_array([
    $this->sessionHandler,
    $method,
  ], $args);
  $this->assertSame($expected_result, $actual_result);
  // Test with non-writable session.
  $this->sessionHandler
    ->setSessionWritable(FALSE);
  $this->assertFalse($this->sessionHandler
    ->isSessionWritable());
  $actual_result = call_user_func_array([
    $this->sessionHandler,
    $method,
  ], $args);
  $this->assertSame($expected_result, $actual_result);
}

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