public function UserCrudReactionTest::testUserInsert in Search API Saved Searches 8
Verifies correct reaction to the creation of a new user.
See also
search_api_saved_searches_user_insert()
File
- tests/src/ Kernel/ UserCrudReactionTest.php, line 107 
Class
- UserCrudReactionTest
- Verifies that the module reacts correctly to user CRUD operations.
Namespace
Drupal\Tests\search_api_saved_searches\KernelCode
public function testUserInsert() {
  $account = User::create([
    'name' => 'foo',
    'status' => TRUE,
    'mail' => 'foo@example.com',
  ]);
  $account
    ->save();
  // Creating a new user claimed all anonymously created alerts with the same
  // e-mail address.
  $this
    ->reloadSavedSearches();
  $this
    ->assertEquals($account
    ->id(), $this->savedSearches[1]
    ->getOwnerId());
  $this
    ->assertEquals($account
    ->id(), $this->savedSearches[2]
    ->getOwnerId());
  $this
    ->assertEquals(0, $this->savedSearches[3]
    ->getOwnerId());
  User::create([
    'name' => 'bar',
    'status' => FALSE,
    'mail' => 'bar@example.com',
  ])
    ->save();
  // Creating an inactive user didn't affect any alerts.
  $this
    ->reloadSavedSearches();
  $this
    ->assertEquals($account
    ->id(), $this->savedSearches[1]
    ->getOwnerId());
  $this
    ->assertEquals($account
    ->id(), $this->savedSearches[2]
    ->getOwnerId());
  $this
    ->assertEquals(0, $this->savedSearches[3]
    ->getOwnerId());
}