MonitoringRebuildTest.php in Monitoring 8
File
tests/src/Functional/MonitoringRebuildTest.php
View source
<?php
namespace Drupal\Tests\monitoring\Functional;
use Drupal\monitoring\Entity\SensorConfig;
class MonitoringRebuildTest extends MonitoringTestBase {
public static $modules = array(
'node',
'ultimate_cron',
'update',
'monitoring_test',
);
public function testRebuildNonAddable() {
$test_user = $this
->drupalCreateUser([
'monitoring reports',
'administer monitoring',
]);
$this
->drupalLogin($test_user);
SensorConfig::load('twig_debug_mode')
->delete();
SensorConfig::load('ultimate_cron_errors')
->delete();
SensorConfig::load('update_core')
->delete();
$sensor = SensorConfig::load('core_requirements_monitoring_test');
$this
->assertNotNull($sensor);
$result = $this
->runSensor('core_requirements_monitoring_test');
$this
->assertTrue($result
->isOk());
$result = $this
->runSensor('monitoring_disappeared_sensors');
$this
->assertTrue($result
->isOk());
\Drupal::state()
->set('monitoring_test_requirements_enabled', FALSE);
$this
->drupalGet('/admin/config/system/monitoring/sensors');
$this
->clickLink('Rebuild sensor list');
$this
->assertText('The sensor Ultimate cron errors has been created.');
$this
->assertText('The sensor Twig debug mode has been created.');
$this
->assertNotNull(SensorConfig::load('twig_debug_mode'));
$this
->assertNotNull(SensorConfig::load('ultimate_cron_errors'));
$this
->assertNotNull(SensorConfig::load('update_core'));
$this
->assertNull(SensorConfig::load('core_requirements_monitoring_test'));
$result = $this
->runSensor('monitoring_disappeared_sensors');
$this
->assertTrue($result
->isOk());
}
}