You are here

public function WriteSafeSessionHandlerTest::testOtherMethods in Drupal 8

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

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
    ->assertSame(TRUE, $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
    ->assertSame(FALSE, $this->sessionHandler
    ->isSessionWritable());
  $actual_result = call_user_func_array([
    $this->sessionHandler,
    $method,
  ], $args);
  $this
    ->assertSame($expected_result, $actual_result);
}