You are here

protected function NodeRevisionsAutocleanTest::setUp in Node Revisions Autoclean 8

Setups tests.

Overrides BrowserTestBase::setUp

File

tests/src/Functional/NodeRevisionsAutocleanTest.php, line 40

Class

NodeRevisionsAutocleanTest
Class NodeRevisionsAutocleanTest.

Namespace

Drupal\Tests\node_revisions_autoclean\Functional

Code

protected function setUp() {
  parent::setUp();
  $this->languageManager = \Drupal::service('language_manager');

  // Create, log in user & Install French language.
  $user = $this
    ->drupalCreateUser([
    'administer languages',
    'access administration pages',
  ]);
  $this
    ->drupalLogin($user);
  $edit = [
    'predefined_langcode' => 'fr',
  ];
  $this
    ->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
  $this
    ->rebuildContainer();

  // Creates default node types.
  $config = \Drupal::configFactory()
    ->getEditable('node_revisions_autoclean.settings');
  $config
    ->set('enable_on_cron', 0)
    ->set('enable_on_node_update', 0)
    ->save(TRUE);
  $type = $this->container
    ->get('entity_type.manager')
    ->getStorage('node_type')
    ->create([
    'type' => 'article',
    'name' => 'Article',
  ]);
  $type
    ->save();
  $type = $this->container
    ->get('entity_type.manager')
    ->getStorage('node_type')
    ->create([
    'type' => 'page',
    'name' => 'Page',
  ]);
  $type
    ->save();
  $this->container
    ->get('router.builder')
    ->rebuild();
}