You are here

public function WriteSafeSessionHandlerTest::testOtherMethods in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php \Drupal\Tests\Core\Session\WriteSafeSessionHandlerTest::testOtherMethods()
  2. 9 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 132

Class

WriteSafeSessionHandlerTest
Tests \Drupal\Core\Session\WriteSafeSessionHandler.

Namespace

Drupal\Tests\Core\Session

Code

public function testOtherMethods($method, $expected_result, $args) {
  $invocation = $this->wrappedSessionHandler
    ->expects($this
    ->exactly(2))
    ->method($method)
    ->will($this
    ->returnValue($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);
}