// Ensure the default bundle mapping for node is used. These attributes come
// from the node default bundle definition.
$node_title=$this->xpath("//meta[@property='dc:title' and @content='$node->title']");
$node_meta=$this->xpath("//article[(@about='$url')]//span[contains(@property, 'dc:date') and contains(@property, 'dc:created') and @datatype='xsd:dateTime' and @content='$isoDate']");
$this->assertTrue(!empty($node_title),'Property dc:title is present in meta tag.');
$this->assertTrue(!empty($node_meta),'RDF type is present on post. Properties dc:date and dc:created are present on post date.');
// Ensure the mapping defined in rdf_module.test is used.
$test_bundle_title=$this->xpath("//meta[@property='dc:title' and @content='$node->title']");
$test_bundle_meta=$this->xpath("//article[(@about='$url') and contains(@typeof, 'foo:mapping_install1') and contains(@typeof, 'bar:mapping_install2')]//span[contains(@property, 'dc:date') and contains(@property, 'dc:created') and @datatype='xsd:dateTime' and @content='$isoDate']");
$this->assertTrue(!empty($test_bundle_title),'Property dc:title is present in meta tag.');
$this->assertTrue(!empty($test_bundle_meta),'RDF type is present on post. Properties dc:date and dc:created are present on post date.');
// Ensure the default bundle mapping for node is used. These attributes come
// from the node default bundle definition.
$random_bundle_title=$this->xpath("//meta[@property='dc:title' and @content='$node->title']");
$random_bundle_meta=$this->xpath("//article[(@about='$url') and contains(@typeof, 'sioc:Item') and contains(@typeof, 'foaf:Document')]//span[contains(@property, 'dc:date') and contains(@property, 'dc:created') and @datatype='xsd:dateTime' and @content='$isoDate']");
$this->assertTrue(!empty($random_bundle_title),'Property dc:title is present in meta tag.');
$this->assertTrue(!empty($random_bundle_meta),'RDF type is present on post. Properties dc:date and dc:created are present on post date.');
}
/**
* Tests if default mapping for user is being used.
*
* Creates a random user and ensures the default mapping for the user is
* being used.
*/
functiontestUserAttributesInMarkup(){
// Create two users, one with access to user profiles.
$user1=$this->drupalCreateUser(array('access user profiles'));
$user2=$this->drupalCreateUser();
$username=$user2->name;
$this->drupalLogin($user1);
// Browse to the user profile page.
$this->drupalGet('user/'.$user2->uid);
// Ensure the default bundle mapping for user is used on the user profile
// page. These attributes come from the user default bundle definition.
$user2_profile_about=$this->xpath('//article[@class="profile" and @typeof="sioc:UserAccount" and @about=:account-uri]',array(
':account-uri'=>$account_uri,
));
$this->assertTrue(!empty($user2_profile_about),'RDFa markup found on user profile page');
$user_account_holder=$this->xpath('//meta[contains(@typeof, "foaf:Person") and @about=:person-uri and @resource=:account-uri and contains(@rel, "foaf:account")]',array(
':person-uri'=>$person_uri,
':account-uri'=>$account_uri,
));
$this->assertTrue(!empty($user_account_holder),'URI created for account holder and username set on sioc:UserAccount.');
$user_username=$this->xpath('//meta[@about=:account-uri and contains(@property, "foaf:name") and @content=:username]',array(
':account-uri'=>$account_uri,
':username'=>$username,
));
$this->assertTrue(!empty($user_username),'foaf:name set on username.');
// Ensures the default bundle mapping for user is used on the Authored By
// information on the node.
$author_about=$this->xpath('//a[@typeof="sioc:UserAccount" and @about=:account-uri and @property="foaf:name" and @datatype="" and contains(@lang, "")]',array(
':account-uri'=>$account_uri,
));
$this->assertTrue(!empty($author_about),'RDFa markup found on author information on post. The lang attribute on username is set to empty string.');
}
/**
* Creates a random term and ensures the right RDFa markup is used.
*/
functiontestTaxonomyTermRdfaAttributes(){
$vocabulary=$this->createVocabulary();
$term=$this->createTerm($vocabulary);
// Views the term and checks that the RDFa markup is correct.
$this->drupalGet('taxonomy/term/'.$term->tid);
$term_url=url('taxonomy/term/'.$term->tid);
$term_label=$term->label();
$term_rdfa_meta=$this->xpath('//meta[@typeof="skos:Concept" and @about=:term-url and contains(@property, "rdfs:label") and contains(@property, "skos:prefLabel") and @content=:term-label]',array(
':term-url'=>$term_url,
':term-label'=>$term_label,
));
$this->assertTrue(!empty($term_rdfa_meta),'RDFa markup found on term page.');
$expected_mapping=array(
'rdftype'=>array('sioc:Item','foaf:Document'),
'title'=>array(
'predicates'=>array('dc:title'),
),
'body'=>array(
'predicates'=>array('content:encoded'),
),
'created'=>array(
'predicates'=>array('dc:date','dc:created'),
'callback'=>'date_iso8601',
'datatype'=>'xsd:dateTime',
),
);
$node=node_load($node->nid);
foreach($expected_mappingas$key=>$mapping){
$this->assertEqual($node->rdf_mapping[$key],$mapping,format_string('Expected mapping found for @key.',array('@key'=>$key)));
$this->assertTrue($graph->hasProperty($node_uri,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',$expected_value),'Node type found in RDF output (sioc:Item).');
// Node type.
$expected_value=array(
'type'=>'uri',
'value'=>'http://xmlns.com/foaf/0.1/Document',
);
$this->assertTrue($graph->hasProperty($node_uri,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',$expected_value),'Node type found in RDF output (foaf:Document).');
// Node title.
$expected_value=array(
'type'=>'literal',
'value'=>$node->title,
'lang'=>'en',
);
$this->assertTrue($graph->hasProperty($node_uri,'http://purl.org/dc/terms/title',$expected_value),'Node title found in RDF output (dc:title).');
$this->assertTrue($graph->hasProperty($term_uri,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',$expected_value),'Term type found in RDF output (skos:Concept).');
// Term label.
$expected_value=array(
'type'=>'literal',
'value'=>$term->label(),
'lang'=>'en',
);
$this->assertTrue($graph->hasProperty($term_uri,'http://www.w3.org/2000/01/rdf-schema#label',$expected_value),'Term label found in RDF output (rdfs:label).');
// Term label.
$expected_value=array(
'type'=>'literal',
'value'=>$term->label(),
'lang'=>'en',
);
$this->assertTrue($graph->hasProperty($term_uri,'http://www.w3.org/2004/02/skos/core#prefLabel',$expected_value),'Term label found in RDF output (skos:prefLabel).');