Commit c5511547 authored by Phil Norton's avatar Phil Norton
Browse files

Issue #3272786: Added test for delete all button.

parent ecb17aa8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -180,6 +180,9 @@ class UserSessionInspector extends ControllerBase {
          'button',
          'button--danger',
        ],
        'data-test' => [
          'session-operation-delete-all',
        ],
      ],
    ];

+0 −3
Original line number Diff line number Diff line
@@ -5,12 +5,9 @@ namespace Drupal\session_inspector\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\session_inspector\Event\SessionEvent;
use Drupal\session_inspector\Event\SessionInspectorEvents;
use Drupal\session_inspector\SessionDeletionInterface;
use Drupal\session_inspector\SessionInspectorInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
 * Defines a confirmation form to allow users to delete sessions.
+18 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ class SessionInspectorTest extends BrowserTestBase {
    $this->assertEquals($uid, $this->container->get('state')->get('session_event.uid'));
    $this->assertEquals($sid, $this->container->get('state')->get('session_event.sid'));

    // The response is an access denied as the user is logged out.
    // The response is access denied as the user is logged out.
    $this->assertSession()->responseContains('Access denied');

    // Ensure that we are not logged in anymore.
@@ -94,4 +94,21 @@ class SessionInspectorTest extends BrowserTestBase {
    $this->assertSession()->responseContains('Access denied');
  }

  /**
   * Test that a user can delete all other sessions.
   */
  public function testUserCanDeleteAllOtherSessions() {
    $user = $this->createUser(['inspect own user sessions']);
    $this->drupalLogin($user);

    $this->drupalGet('user/' . $user->id() . '/sessions');

    // Delete all other sessions.
    $this->click('[data-test="session-operation-delete-all"]');
    $this->click('[id="edit-submit"]');

    // User is still logged in.
    $this->assertSession()->responseNotContains('Access denied');
  }

}