You are here

public function NodeRevisionDeleteConfigTest::testSaveContentTypeConfig in Node Revision Delete 8

Tests the NodeRevisionDelete::saveContentTypeConfig method.

File

tests/src/Kernel/NodeRevisionDeleteConfigTest.php, line 71

Class

NodeRevisionDeleteConfigTest
Test the module configurations related to the node_revision_delete service.

Namespace

Drupal\Tests\node_revision_delete\Kernel

Code

public function testSaveContentTypeConfig() {
  foreach ($this->testTrackArray as $content_type => $content_type_info) {

    // Getting the config file.
    $config = $this->container
      ->get('config.factory')
      ->getEditable('node.type.' . $content_type);

    // Saving the array to have values in the config.
    $config
      ->set('third_party_settings', $content_type_info)
      ->save();
    $info = $content_type_info['node_revision_delete'];

    // Saving the configuration for a content type.
    $this->nodeRevisionDelete
      ->saveContentTypeConfig($content_type, $info['minimum_revisions_to_keep'], $info['minimum_age_to_delete'], $info['when_to_delete']);

    // Asserting.
    $this
      ->assertEquals($content_type_info, $config
      ->get('third_party_settings'));
  }
}