Skip to content
Snippets Groups Projects
Verified Commit b896f004 authored by Kent Richards's avatar Kent Richards :speech_balloon:
Browse files

Issue #2631220: Remove redundant test


Per feedback.

Co-authored-by: default avatarznerol <46208-znerol@users.noreply.drupalcode.org>
parent 6d6c2b79
No related branches found
No related tags found
1 merge request!10482Issue #2631220: Apply changes from MR 2210 to 11.x
......@@ -98,14 +98,6 @@ session_test.trace_handler:
requirements:
_access: 'TRUE'
session_test.trace_handler_get:
path: '/session-test/trace-handler-get'
defaults:
_title: 'Returns a preexisting trace recorded by test proxy session handlers as JSON'
_controller: '\Drupal\session_test\Controller\SessionTestController::traceHandlerGet'
requirements:
_access: 'TRUE'
session_test.trace_handler_rewrite_unmodified:
path: '/session-test/trace-handler-rewrite-unmodified'
defaults:
......
......@@ -167,26 +167,6 @@ public function traceHandler(Request $request) {
return new JsonResponse($trace);
}
/**
* Returns a preexisting trace recorded by test proxy session handlers as JSON.
*
* Expects that there is an existing stacked session handler trace as recorded
* by `traceHandler()`.
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
* The response.
*
* @throws \AssertionError
*/
public function traceHandlerGet() {
$this->assertExistingStackedHandlerTrace();
// Collect traces and return them in JSON format.
$trace = \Drupal::service('session_test.session_handler_proxy_trace')->getArrayCopy();
return new JsonResponse($trace);
}
/**
* Returns an updated trace recorded by test proxy session handlers as JSON.
*
......@@ -205,7 +185,11 @@ public function traceHandlerGet() {
* @throws \AssertionError
*/
public function traceHandlerRewriteUnmodified(Request $request) {
$this->assertExistingStackedHandlerTrace();
// Assert that there is an existing session with stacked handler trace data.
assert(
is_int($_SESSION['trace-handler']) && $_SESSION['trace-handler'] > 0,
'Existing stacked session handler trace not found'
);
// Save unmodified session data.
assert(
......@@ -339,16 +323,4 @@ public function triggerWriteException(Request $request) {
return new Response();
}
/**
* Asserts that there is an existing session with stacked handler trace data.
*
* @throws \AssertionError
*/
protected function assertExistingStackedHandlerTrace(): void {
assert(
is_int($_SESSION['trace-handler']) && $_SESSION['trace-handler'] > 0,
'Existing stacked session handler trace not found'
);
}
}
......@@ -53,43 +53,6 @@ public function testRequest(): void {
$this->assertEquals($expect_trace, $actual_trace);
}
/**
* Tests a session read request with a valid session cookie.
*
* The trace should include `validateId` because a session cookie is included.
*
* The trace should not include `write` or `updateTimestamp` because the
* session data is only read.
*/
public function testRequestReadInvokesValidateId(): void {
$options['query'][MainContentViewSubscriber::WRAPPER_FORMAT] = 'drupal_ajax';
$headers = ['X-Requested-With' => 'XMLHttpRequest'];
// Call the write trace handler to store the trace and retrieve a session
// cookie.
$this->drupalGet('session-test/trace-handler');
// Call the read-only trace handler with the session cookie.
$actual_trace = json_decode($this->drupalGet('session-test/trace-handler-get', $options, $headers));
$sessionId = $this->getSessionCookies()->getCookieByName($this->getSessionName())->getValue();
$expect_trace = [
["BEGIN", "test_argument", "open"],
["BEGIN", NULL, "open"],
["END", NULL, "open"],
["END", "test_argument", "open"],
["BEGIN", "test_argument", "validateId", $sessionId],
["BEGIN", NULL, "validateId", $sessionId],
["END", NULL, "validateId", $sessionId],
["END", "test_argument", "validateId", $sessionId],
["BEGIN", "test_argument", "read", $sessionId],
["BEGIN", NULL, "read", $sessionId],
["END", NULL, "read", $sessionId],
["END", "test_argument", "read", $sessionId],
];
$this->assertEquals($expect_trace, $actual_trace);
}
/**
* Tests a session modify request with a valid session cookie.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment