You are here

public function ConfigReverterTest::testDelete in Configuration Update Manager 8

@covers \Drupal\config_update\ConfigReverter::delete @dataProvider deleteProvider

File

tests/src/Unit/ConfigReverterTest.php, line 301

Class

ConfigReverterTest
Tests the \Drupal\config_update\ConfigReverter class.

Namespace

Drupal\Tests\config_update\Unit

Code

public function testDelete($type, $name, $config_name, $expected) {

  // Clear dispatch log.
  $this->dispatchedEvents = [];
  $save_config = $this->configStorage;

  // Call the deleteer and test the Boolean result.
  $result = $this->configReverter
    ->delete($type, $name);
  $this
    ->assertEquals($result, $expected);
  if ($result) {

    // Verify that the config is missing after delete, and logging worked.
    $this
      ->assertTrue(!isset($this->configStorage[$config_name]));
    $this
      ->assertEquals(count($this->dispatchedEvents), 1);
    $this
      ->assertEquals($this->dispatchedEvents[0][0], ConfigDeleteInterface::DELETE);
  }
  else {

    // Verify that the config didn't change and no events were logged.
    $this
      ->assertEquals($this->configStorage, $save_config);
    $this
      ->assertEquals(count($this->dispatchedEvents), 0);
  }
}