public function EmailTestCase::testMarkup in Microdata 7
Tests whether microdata is correctly outputted, depending on the field formatter type.
File
- modules/
email/ email.test, line 104 - Tests for Email module.
Class
- EmailTestCase
- Test Email module microdata placement.
Code
public function testMarkup() {
$text = 'example@test.org';
$node = $this
->drupalCreateNode(array(
'type' => $this->bundleType,
'promote' => 1,
));
foreach ($this->fieldFormatterTypes as $type) {
$edit["{$type}[und][0][email]"] = $text;
}
$this
->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
// Get the microdata result for the page.
$md = $this
->parseMicrodata();
// Get the entity as a microdata item.
$item = $md->items[0];
// Test fields enriched with microdata.
foreach ($this->fieldFormatterTypesMicrodata as $type) {
$text_itemprop = $type;
$this
->assertEqual($text, $item->properties[$text_itemprop][0], "Itemprop is placed on {$type}");
}
// Test fields without microdata.
foreach ($this->fieldFormatterTypesNoMicrodata as $type) {
$text_itemprop = $type;
$this
->assertTrue(empty($item->properties[$text_itemprop][0]), "Itemprop is not placed on {$type}");
}
}