diff options
Diffstat (limited to 'modules/rdf/rdf.test')
-rw-r--r-- | modules/rdf/rdf.test | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/modules/rdf/rdf.test b/modules/rdf/rdf.test index 908cfec4c..fa0c8c58f 100644 --- a/modules/rdf/rdf.test +++ b/modules/rdf/rdf.test @@ -17,9 +17,6 @@ class RdfMappingHookTestCase extends DrupalWebTestCase { function setUp() { parent::setUp('rdf', 'rdf_test', 'field_test'); - // We need to trigger rdf_modules_installed() because - // hook_modules_installed() is not automatically invoked during testing. - rdf_modules_installed(array('rdf_test')); } /** @@ -53,7 +50,6 @@ class RdfMarkupTestCase extends DrupalWebTestCase { function setUp() { parent::setUp('rdf', 'field_test', 'rdf_test'); - rdf_modules_installed(array('field_test', 'rdf_test')); } /** @@ -193,31 +189,54 @@ class RdfCrudTestCase extends DrupalWebTestCase { * Test inserting, loading, updating, and deleting RDF mappings. */ function testCRUD() { - $test_mapping = rdf_test_rdf_mapping(); - // Verify loading of a default mapping. - $this->assertFalse(count(_rdf_mapping_load('test_entity', 'test_bundle')), t('Default mapping was found.')); + $mapping = _rdf_mapping_load('test_entity', 'test_bundle'); + $this->assertTrue(count($mapping), t('Default mapping was found.')); // Verify saving a mapping. - $mapping = (array) $test_mapping; - rdf_mapping_save($mapping[0]); - $this->assertEqual($mapping[0]['mapping'], $test_mapping[0]['mapping'], t('Saved mapping equals default mapping.')); - $this->assertTrue(rdf_mapping_save($mapping[1]) === SAVED_NEW, t('Second mapping was inserted.')); - $this->assertEqual($mapping[1]['mapping'], _rdf_mapping_load($test_mapping[1]['type'], $test_mapping[1]['bundle']), t('Second mapping equals default mapping.')); + $mapping = array( + 'type' => 'crud_test_entity', + 'bundle' => 'crud_test_bundle', + 'mapping' => array( + 'rdftype' => array('sioc:Post'), + 'title' => array( + 'predicates' => array('dc:title'), + ), + 'uid' => array( + 'predicates' => array('sioc:has_creator', 'dc:creator'), + 'type' => 'rel', + ), + ), + ); + $this->assertTrue(rdf_mapping_save($mapping) === SAVED_NEW, t('Mapping was saved.')); + + // Read the raw record from the {rdf_mapping} table. + $result = db_query('SELECT * FROM {rdf_mapping} WHERE type = :type AND bundle = :bundle', array(':type' => $mapping['type'], ':bundle' => $mapping['bundle'])); + $stored_mapping = $result->fetchAssoc(); + $stored_mapping['mapping'] = unserialize($stored_mapping['mapping']); + $this->assertEqual($mapping, $stored_mapping, t('Mapping was stored properly in the {rdf_mapping} table.')); // Verify loading of saved mapping. - $this->assertEqual($mapping[0]['mapping'], _rdf_mapping_load($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Saved mapping equals loaded default mapping.')); + $this->assertEqual($mapping['mapping'], _rdf_mapping_load($mapping['type'], $mapping['bundle']), t('Saved mapping loaded successfully.')); // Verify updating of mapping. - $mapping[0]['mapping']['boofar'] = array( - 'predicates' => array('foo:bar'), + $mapping['mapping']['title'] = array( + 'predicates' => array('dc2:bar2'), ); - $this->assertTrue(rdf_mapping_save($mapping[0]) === SAVED_UPDATED, t('Mapping was updated.')); - $this->assertEqual($mapping[0]['mapping'], _rdf_mapping_load($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Updated and loaded mapping are equal.')); + $this->assertTrue(rdf_mapping_save($mapping) === SAVED_UPDATED, t('Mapping was updated.')); + + // Read the raw record from the {rdf_mapping} table. + $result = db_query('SELECT * FROM {rdf_mapping} WHERE type = :type AND bundle = :bundle', array(':type' => $mapping['type'], ':bundle' => $mapping['bundle'])); + $stored_mapping = $result->fetchAssoc(); + $stored_mapping['mapping'] = unserialize($stored_mapping['mapping']); + $this->assertEqual($mapping, $stored_mapping, t('Updated mapping was stored properly in the {rdf_mapping} table.')); + + // Verify loading of saved mapping. + $this->assertEqual($mapping['mapping'], _rdf_mapping_load($mapping['type'], $mapping['bundle']), t('Saved mapping loaded successfully.')); // Verify deleting of mapping. - $this->assertTrue(rdf_mapping_delete($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Mapping was deleted.')); - $this->assertFalse(_rdf_mapping_load($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Deleted mapping is no longer found.')); + $this->assertTrue(rdf_mapping_delete($mapping['type'], $mapping['bundle']), t('Mapping was deleted.')); + $this->assertFalse(_rdf_mapping_load($mapping['type'], $mapping['bundle']), t('Deleted mapping is no longer found in the database.')); } } @@ -232,12 +251,6 @@ class RdfMappingDefinitionTestCase extends DrupalWebTestCase { function setUp() { parent::setUp('rdf', 'rdf_test', 'blog'); - // We need to trigger rdf_modules_installed() because - // hook_modules_installed() is not automatically invoked during testing. - rdf_modules_installed(array('rdf_test', 'node')); - // entity_info caches must be cleared during testing. This is done - // automatically during the manual installation. - entity_info_cache_clear(); } /** @@ -327,13 +340,6 @@ class RdfTrackerAttributesTestCase extends DrupalWebTestCase { function setUp() { parent::setUp('rdf', 'rdf_test', 'tracker'); - // We need to trigger rdf_modules_installed() because - // hook_modules_installed() is not automatically invoked during testing. - rdf_modules_installed(array('rdf_test', 'node')); - // entity_info caches must be cleared during testing. This is done - // automatically during the manual installation. - cache_clear_all('entity_info', 'cache'); - drupal_static_reset('entity_get_info'); // Enable anonymous posting of content. user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array( 'create article content' => TRUE, |