You are here

public function BlockedDeleteTest::setUp in Auto Purge Users 8.3

Overrides BrowserTestBase::setUp

File

tests/src/Functional/BlockedDeleteTest.php, line 21

Class

BlockedDeleteTest
Purge users who have been blocked for a specific period.

Namespace

Drupal\Tests\purge_users\Functional

Code

public function setUp() : void {
  parent::setUp();
  $this->nodeStorage = $this->container
    ->get('entity_type.manager')
    ->getStorage('node');
  $this->userStorage = $this->container
    ->get('entity_type.manager')
    ->getStorage('user');

  // Set the users for this scenario.
  $this
    ->addAdminUser();

  // Blocked user created 150 days ago, never logged in, status = 0.
  $this->blockedUser = $this
    ->createUser();
  $this->blockedUser->created = strtotime("-150 day");
  $this->blockedUser->login = 0;
  $this->blockedUser->status = 0;
  $this->blockedUser
    ->save();

  // Set the user that will be deleted.
  $this
    ->createTestUser();

  // Active user created 20 months ago and logged in 3 days ago.
  $this->activeUser = $this
    ->createUser();
  $this->activeUser->created = strtotime("-20 month");
  $this->activeUser->login = strtotime("-3 day");
  $this->activeUser
    ->save();

  // Set the basic configuration and add the specific changes.
  $this
    ->setBasicConfig();
  $this
    ->config('purge_users.settings')
    ->set('user_blocked_value', '100')
    ->set('user_blocked_period', 'days')
    ->set('enabled_blocked_users', TRUE)
    ->save();
}