public function UserCrudReactionTest::testUserActivate in Search API Saved Searches 8
Verifies correct reaction to the activation of a user account.
See also
search_api_saved_searches_user_update()
_search_api_saved_searches_claim_anonymous_searches()
File
- tests/
src/ Kernel/ UserCrudReactionTest.php, line 141
Class
- UserCrudReactionTest
- Verifies that the module reacts correctly to user CRUD operations.
Namespace
Drupal\Tests\search_api_saved_searches\KernelCode
public function testUserActivate() {
$account = User::create([
'name' => 'foo',
'status' => FALSE,
'mail' => 'foo@example.com',
]);
$account
->save();
// Creating an inactive user didn't affect any alerts.
$this
->reloadSavedSearches();
$this
->assertEquals(0, $this->savedSearches[1]
->getOwnerId());
$this
->assertEquals(0, $this->savedSearches[2]
->getOwnerId());
$this
->assertEquals(0, $this->savedSearches[3]
->getOwnerId());
$account
->activate()
->save();
// Once activated, all anonymously created alerts with the same e-mail
// address are moved to that user.
$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());
}