Commit 07149c42 authored by alexpott's avatar alexpott

Issue #2381921 by tibbsa, hussainweb: Clean-up RDF module test members -...

Issue #2381921 by tibbsa, hussainweb: Clean-up RDF module test members - ensure property definition and use of camelCase naming convention
parent 44162ebd
......@@ -25,6 +25,20 @@ class CommentAttributesTest extends CommentTestBase {
*/
public static $modules = array('views', 'node', 'comment', 'rdf');
/**
* URI of the front page of the Drupal site.
*
* @var string
*/
protected $baseUri;
/**
* URI of the test node created by CommentTestBase::setUp().
*
* @var string
*/
protected $nodeUri;
protected function setUp() {
parent::setUp();
......@@ -42,8 +56,8 @@ protected function setUp() {
$this->setCommentSettings('comment_default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
// Prepares commonly used URIs.
$this->base_uri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
$this->node_uri = $this->node->url('canonical', ['absolute' => TRUE]);
$this->baseUri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
$this->nodeUri = $this->node->url('canonical', ['absolute' => TRUE]);
// Set relation between node and comment.
$article_mapping = rdf_get_mapping('node', 'article');
......@@ -112,7 +126,7 @@ public function testNumberOfCommentsRdfaMarkup() {
$this->drupalLogin($this->web_user);
$parser = new \EasyRdf_Parser_Rdfa();
$graph = new \EasyRdf_Graph();
$parser->parse($graph, $this->drupalGet('node'), 'rdfa', $this->base_uri);
$parser->parse($graph, $this->drupalGet('node'), 'rdfa', $this->baseUri);
// Number of comments.
$expected_value = array(
......@@ -120,13 +134,13 @@ public function testNumberOfCommentsRdfaMarkup() {
'value' => 2,
'datatype' => 'http://www.w3.org/2001/XMLSchema#integer',
);
$this->assertTrue($graph->hasProperty($this->node_uri, 'http://rdfs.org/sioc/ns#num_replies', $expected_value), 'Number of comments found in RDF output of teaser view (sioc:num_replies).');
$this->assertTrue($graph->hasProperty($this->nodeUri, 'http://rdfs.org/sioc/ns#num_replies', $expected_value), 'Number of comments found in RDF output of teaser view (sioc:num_replies).');
// Tests number of comments in full node view, expected value is the same.
$parser = new \EasyRdf_Parser_Rdfa();
$graph = new \EasyRdf_Graph();
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->base_uri);
$this->assertTrue($graph->hasProperty($this->node_uri, 'http://rdfs.org/sioc/ns#num_replies', $expected_value), 'Number of comments found in RDF output of full node view mode (sioc:num_replies).');
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
$this->assertTrue($graph->hasProperty($this->nodeUri, 'http://rdfs.org/sioc/ns#num_replies', $expected_value), 'Number of comments found in RDF output of full node view mode (sioc:num_replies).');
}
/**
......@@ -143,14 +157,14 @@ public function testCommentRdfaMarkup() {
$this->drupalLogin($this->web_user);
$parser = new \EasyRdf_Parser_Rdfa();
$graph = new \EasyRdf_Graph();
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->base_uri);
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
$this->_testBasicCommentRdfaMarkup($graph, $comment1);
// Tests comment #1 with no access to the user profile (as anonymous user).
$this->drupalLogout();
$parser = new \EasyRdf_Parser_Rdfa();
$graph = new \EasyRdf_Graph();
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->base_uri);
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
$this->_testBasicCommentRdfaMarkup($graph, $comment1);
// Posts comment #2 as anonymous user.
......@@ -163,14 +177,14 @@ public function testCommentRdfaMarkup() {
// Tests comment #2 as anonymous user.
$parser = new \EasyRdf_Parser_Rdfa();
$graph = new \EasyRdf_Graph();
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->base_uri);
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
$this->_testBasicCommentRdfaMarkup($graph, $comment2, $anonymous_user);
// Tests comment #2 as logged in user.
$this->drupalLogin($this->web_user);
$parser = new \EasyRdf_Parser_Rdfa();
$graph = new \EasyRdf_Graph();
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->base_uri);
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
$this->_testBasicCommentRdfaMarkup($graph, $comment2, $anonymous_user);
}
......@@ -190,19 +204,19 @@ public function testCommentReplyOfRdfaMarkup() {
$parser = new \EasyRdf_Parser_Rdfa();
$graph = new \EasyRdf_Graph();
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->base_uri);
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
// Tests the reply_of relationship of a first level comment.
$expected_value = array(
'type' => 'uri',
'value' => $this->node_uri,
'value' => $this->nodeUri,
);
$this->assertTrue($graph->hasProperty($comment_1_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its node found in RDF output (sioc:reply_of).');
// Tests the reply_of relationship of a second level comment.
$expected_value = array(
'type' => 'uri',
'value' => $this->node_uri,
'value' => $this->nodeUri,
);
$this->assertTrue($graph->hasProperty($comment_2_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its node found in RDF output (sioc:reply_of).');
$expected_value = array(
......
......@@ -31,7 +31,7 @@ class CrudTest extends KernelTestBase {
/**
* @var string
*/
protected $entity_type;
protected $entityType;
/**
* @var string
......@@ -41,17 +41,17 @@ class CrudTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
$this->prefix = 'rdf.mapping';
$this->entity_type = $this->bundle = 'entity_test';
$this->entityType = $this->bundle = 'entity_test';
}
/**
* Tests creation of RDF mapping.
*/
function testMappingCreation() {
$mapping_config_name = "{$this->prefix}.{$this->entity_type}.{$this->bundle}";
$mapping_config_name = "{$this->prefix}.{$this->entityType}.{$this->bundle}";
// Save bundle mapping config.
rdf_get_mapping($this->entity_type, $this->bundle)->save();
rdf_get_mapping($this->entityType, $this->bundle)->save();
// Test that config file was saved.
$mapping_config = \Drupal::configFactory()->listAll('rdf.mapping.');
$this->assertTrue(in_array($mapping_config_name, $mapping_config), 'Rdf mapping config saved.');
......@@ -63,19 +63,19 @@ function testMappingCreation() {
function testBundleMapping() {
// Test that the bundle mapping can be saved.
$types = array('sioc:Post', 'foaf:Document');
rdf_get_mapping($this->entity_type, $this->bundle)
rdf_get_mapping($this->entityType, $this->bundle)
->setBundleMapping(array('types' => $types))
->save();
$bundle_mapping = rdf_get_mapping($this->entity_type, $this->bundle)
$bundle_mapping = rdf_get_mapping($this->entityType, $this->bundle)
->getBundleMapping();
$this->assertEqual($types, $bundle_mapping['types'], 'Bundle mapping saved.');
// Test that the bundle mapping can be edited.
$types = array('schema:BlogPosting');
rdf_get_mapping($this->entity_type, $this->bundle)
rdf_get_mapping($this->entityType, $this->bundle)
->setBundleMapping(array('types' => $types))
->save();
$bundle_mapping = rdf_get_mapping($this->entity_type, $this->bundle)
$bundle_mapping = rdf_get_mapping($this->entityType, $this->bundle)
->getBundleMapping();
$this->assertEqual($types, $bundle_mapping['types'], 'Bundle mapping updated.');
}
......@@ -92,10 +92,10 @@ function testFieldMapping() {
'datatype' => 'xsd:dateTime',
'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
);
rdf_get_mapping($this->entity_type, $this->bundle)
rdf_get_mapping($this->entityType, $this->bundle)
->setFieldMapping($field_name, $mapping)
->save();
$field_mapping = rdf_get_mapping($this->entity_type, $this->bundle)
$field_mapping = rdf_get_mapping($this->entityType, $this->bundle)
->getFieldMapping($field_name);
$this->assertEqual($mapping, $field_mapping, 'Field mapping saved.');
......@@ -105,10 +105,10 @@ function testFieldMapping() {
'datatype' => 'foo:bar',
'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
);
rdf_get_mapping($this->entity_type, $this->bundle)
rdf_get_mapping($this->entityType, $this->bundle)
->setFieldMapping($field_name, $mapping)
->save();
$field_mapping = rdf_get_mapping($this->entity_type, $this->bundle)
$field_mapping = rdf_get_mapping($this->entityType, $this->bundle)
->getFieldMapping($field_name);
$this->assertEqual($mapping, $field_mapping, 'Field mapping updated.');
}
......
......@@ -41,7 +41,7 @@ class EntityReferenceRdfaTest extends FieldRdfaTestBase {
*
* @var \Drupal\taxonomy\Entity\Term
*/
protected $target_entity;
protected $targetEntity;
/**
* {@inheritdoc}
......@@ -62,13 +62,13 @@ protected function setUp() {
))->save();
// Create the entity to be referenced.
$this->target_entity = entity_create($this->entityType, array('name' => $this->randomMachineName()));
$this->target_entity->save();
$this->targetEntity = entity_create($this->entityType, array('name' => $this->randomMachineName()));
$this->targetEntity->save();
// Create the entity that will have the entity reference field.
$this->entity = entity_create($this->entityType, array('name' => $this->randomMachineName()));
$this->entity->save();
$this->entity->{$this->fieldName}->entity = $this->target_entity;
$this->entity->{$this->fieldName}->entity = $this->targetEntity;
$this->entity->{$this->fieldName}->access = TRUE;
$this->uri = $this->getAbsoluteUri($this->entity);
}
......@@ -77,7 +77,7 @@ protected function setUp() {
* Tests all the entity reference formatters.
*/
public function testAllFormatters() {
$entity_uri = $this->getAbsoluteUri($this->target_entity);
$entity_uri = $this->getAbsoluteUri($this->targetEntity);
// Tests the label formatter.
$this->assertFormatterRdfa(array('type' => 'entity_reference_label'), 'http://schema.org/knows', array('value' => $entity_uri, 'type' => 'uri'));
......
......@@ -29,7 +29,7 @@ class StandardProfileTest extends WebTestBase {
/**
* @var string
*/
protected $base_uri;
protected $baseUri;
/**
* @var \Drupal\user\UserInterface
......@@ -104,7 +104,7 @@ class StandardProfileTest extends WebTestBase {
protected function setUp() {
parent::setUp();
$this->base_uri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
$this->baseUri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
// Create two test users.
$this->adminUser = $this->drupalCreateUser(array(
......@@ -526,7 +526,7 @@ protected function saveComment($nid, $uid, $contact = NULL, $pid = 0) {
protected function getRdfGraph($path) {
$parser = new \EasyRdf_Parser_Rdfa();
$graph = new \EasyRdf_Graph();
$parser->parse($graph, $this->drupalGet($path), 'rdfa', $this->base_uri);
$parser->parse($graph, $this->drupalGet($path), 'rdfa', $this->baseUri);
return $graph;
}
}
......@@ -23,6 +23,13 @@ class TaxonomyAttributesTest extends TaxonomyTestBase {
*/
public static $modules = array('rdf', 'views');
/**
* Vocabulary created for testing purposes.
*
* @var \Drupal\taxonomy\VocabularyInterface
*/
protected $vocabulary;
protected function setUp() {
parent::setUp();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment