function DrupalSolrNodeTestCase::testApacheSolrNodeAddDelete in Apache Solr Search 6.3
Same name and namespace in other branches
- 8 tests/apachesolr_base.test \DrupalSolrNodeTestCase::testApacheSolrNodeAddDelete()
- 7 tests/apachesolr_base.test \DrupalSolrNodeTestCase::testApacheSolrNodeAddDelete()
File
- tests/apachesolr_base.test, line 472
- Unit test class that provides tests for base functionality of the Apachesolr
Module without having the need of a Solr Server
Class
- DrupalSolrNodeTestCase
Code
function testApacheSolrNodeAddDelete() {
$this
->drupalLogin($this->admin_user);
apachesolr_index_set_bundles('solr', 'node', array(
'page',
'story',
));
content_clear_type_cache();
apachesolr_environments_clear_cache();
$types = array(
'page',
'story',
);
$table = apachesolr_get_indexer_table('node');
foreach ($types as $type) {
$edit = array();
$edit['uid'] = $this->admin_user->uid;
$edit['type'] = $type;
$edit['title'] = $this
->randomName(16);
$node = $this
->drupalCreateNode($edit);
$this
->assertTrue(is_object($node) && isset($node->nid), t('Article type @type has been created.', array(
'@type' => $type,
)));
$node = $this
->drupalGetNodeByTitle($edit['title']);
$this
->assertTrue($node, t('Created story @type found in database.', array(
'@type' => $type,
)));
$query = "SELECT status FROM {{$table}} WHERE entity_id = %d";
$db_node_status = db_result(db_query($query, $node->nid));
$this
->assertEqual($db_node_status, 1, t('Node @entity_id has status 1', array(
'@entity_id' => $node->nid,
)));
$this
->drupalPost('node/' . $node->nid . '/delete', array(), t('Delete'));
$query = "SELECT status FROM {{$table}} WHERE entity_id = %d";
$db_node_status = db_result(db_query($query, $node->nid));
$this
->assertEqual($db_node_status, 0, t('Node @entity_id has status 0', array(
'@entity_id' => $node->nid,
)));
$query = "SELECT count(*) as count FROM {node} WHERE nid = %d";
$count = db_result(db_query($query));
$this
->assertEqual($count, 0, t('No more nodes left in the node table.'));
}
}