Skip to content
Snippets Groups Projects

Register middleware

Closed Michael Strelan requested to merge issue/drupal-3513875:3513875-test-middleware into 11.x
3 unresolved threads

Closes #3513875

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
167 167 'tags' => [['name' => 'event_subscriber']],
168 168 ];
169 169 }
170 // Register test middleware.
171 $services['services']['testing.http_client.middleware'] = [
172 'class' => 'Drupal\Core\Test\HttpClientMiddleware\TestHttpClientMiddleware',
173 'tags' => [['name' => 'http_client_middleware']],
174 ];
175 $services['services']['testing.http_middleware.wait_terminate_middleware'] = [
176 'class' => 'Drupal\Core\Test\StackMiddleware\TestWaitTerminateMiddleware',
177 'arguments' => ['@state', '@lock'],
178 'tags' => [['name' => 'http_middleware', 'priority' => -1024]],
179 ];
  • added 1 commit

    Compare with previous version

  • Michael Strelan added 8 commits

    added 8 commits

    Compare with previous version

  • znerol @znerol started a thread on the diff
  • 36 35 public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
    37 36 $result = $this->httpKernel->handle($request, $type, $catch);
    38 37
    39 if ($this->state->get('drupal.test_wait_terminate')) {
    40 // Set a header on the response to instruct the test runner that it must
    41 // await the lock. Note that the lock acquired here is automatically
    42 // released from within a shutdown function.
    43 $this->lock->acquire('test_wait_terminate');
    44 $result->headers->set('X-Drupal-Wait-Terminate', '1');
    38 if (!$this->waitForTerminate) {
    39 return $result;
    • Comment on lines +38 to +39

      The MR would be easier to review if it wouldn't switch the condition style here (i.e., just replace the condition without introducing an early return).

    • I originally removed the condition entirely but had to add it back, which is when I switched to an early return. I think that makes it much clearer. Since we're talking about moving 2 lines of code and 3 lines of comments, I don't think it's worth worrying about reviewability? It kind of forces the reviewer to read it and ensure the logic still makes sense.

    • Please register or sign in to reply
  • znerol @znerol started a thread on the diff
  • 56 55 * {@inheritdoc}
    57 56 */
    58 57 public function register(ContainerBuilder $container) {
    59 $this->registerTest($container);
    60
  • Adam Bramley added 24 commits

    added 24 commits

    Compare with previous version

  • closed

  • Please register or sign in to reply
    Loading