monitoring.search_api.test in Monitoring 7
Contains \MonitoringSearchAPITest.
File
test/tests/monitoring.search_api.testView source
<?php
/**
* @file
* Contains \MonitoringSearchAPITest.
*/
/**
* Tests for search API sensor.
*/
class MonitoringSearchAPITest extends MonitoringTestBase {
public static function getInfo() {
return array(
'name' => 'Monitoring search API',
'description' => 'Search API sensors tests',
'group' => 'Monitoring',
'dependencies' => array(
'search_api',
'search_api_db',
),
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp(array(
'search_api',
'search_api_db',
));
}
/**
* Tests individual sensors.
*/
function testSensors() {
// Create content first to avoid a Division by zero error.
// @todo: This should be fixed in Search API in theme_search_api_index().
$this
->drupalCreateContentType(array(
'type' => 'article',
'name' => 'article',
));
$this
->drupalCreateNode(array(
'type' => 'article',
));
$this
->drupalCreateNode(array(
'type' => 'article',
));
// Configure Search API.
monitoring_setup_search_api();
// Reset sensor info so that sensor for newly created search api index
// gets picked up.
$this->sensorManager
->resetCache();
// Load indexes.
$indexes = search_api_index_load_multiple(FALSE);
// Two new articles, none indexed
$result = $this
->runSensor('search_api_monitoring_test_index');
$this
->assertEqual($result
->getValue(), 2);
// Index existing content.
search_api_index_items($indexes['monitoring_test_index']);
// Create additional content.
$this
->drupalCreateNode(array(
'type' => 'article',
));
$this
->drupalCreateNode(array(
'type' => 'article',
));
$this
->drupalCreateNode(array(
'type' => 'article',
));
// New articles are not yet indexed
$result = $this
->runSensor('search_api_monitoring_test_index');
$this
->assertEqual($result
->getValue(), 3);
// Index remaining articles.
search_api_index_items($indexes['monitoring_test_index']);
// Everything should be indexed.
$result = $this
->runSensor('search_api_monitoring_test_index');
$this
->assertEqual($result
->getValue(), 0);
}
}
Classes
Name | Description |
---|---|
MonitoringSearchAPITest | Tests for search API sensor. |