You are here

function OAuthTest::testConsumerDeletion in OAuth 1.0 8

Same name and namespace in other branches
  1. 8.2 src/Tests/OAuthTest.php \Drupal\oauth\Tests\OAuthTest::testConsumerDeletion()

Tests automatic consumer deletion.

File

src/Tests/OAuthTest.php, line 117
Contains \Drupal\oauth\Tests\OAuthTest.

Class

OAuthTest
Tests oauth functionality.

Namespace

Drupal\oauth\Tests

Code

function testConsumerDeletion() {

  // Create a user with permissions to manage its own consumers.
  $permissions = array(
    'access own consumers',
  );
  $account = $this
    ->drupalCreateUser($permissions);

  // Initiate user session.
  $this
    ->drupalLogin($account);

  // Generate a set of consumer keys.
  $this
    ->drupalPostForm('oauth/consumer/add', array(), 'Add');

  // Delete the user.
  $uid = $account
    ->id();
  $account
    ->delete();

  // Check that its consumers were deleted.
  $consumer = db_query('select cid FROM {oauth_consumer} WHERE uid = :uid', array(
    ':uid' => $uid,
  ))
    ->fetchField();
  $this
    ->assertFalse($consumer, t('Consumer keys were deleted on user deletion.'));
}