diff --git a/metatag.inc b/metatag.inc index ee55190..b594e86 100644 --- a/metatag.inc +++ b/metatag.inc @@ -364,207 +364,6 @@ public function getValue(array $options = array()) { } /** - * Extended meta tag controller for tags supporting the full attribute set. - */ -class DrupalExtendedMetaTag extends DrupalTextMetaTag { - - /** - * Implements DrupalMetaTagInterface::getForm(). - */ - public function getForm(array $options = array()) { - // Ensure the 'token types' element is available. - $options += array( - 'token types' => array(), - ); - - $form['item'] = array( - '#type' => 'fieldset', - '#title' => $this->info['label'], - '#description' => !empty($this->info['description']) ? $this->info['description'] : '', - '#attributes' => array('class' => array('metatag-item', 'extended-metatag-item')), - // '#tree' => TRUE, - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['item']['value'] = isset($this->info['form']['value']) ? $this->info['form']['value'] : array(); - - // Check for old single value format. - if (!empty($this->data['value'])) { - $this->data['item']['value'] = $this->data['value']; - } - - $form['item']['value'] += array( - '#type' => 'textfield', - '#title' => t('Value'), - '#description' => t('The actual value to be used on this field.'), - '#default_value' => isset($this->data['item']['value']) ? $this->data['item']['value'] : '', - '#attributes' => array('class' => array('extended-metatag-field')), - '#element_validate' => array('token_element_validate'), - '#token_types' => $options['token types'], - '#maxlength' => 1024, - ); - - $form['item']['scheme'] = isset($this->info['form']['scheme']) ? $this->info['form']['scheme'] : array(); - - $form['item']['scheme'] += array( - '#type' => 'textfield', - '#title' => t('Scheme'), - '#description' => t('Some metadata standards specify encoding schemes, though it is rarely used.'), - '#default_value' => isset($this->data['item']['scheme']) ? $this->data['item']['scheme'] : '', - '#attributes' => array('class' => array('extended-metatag-field', 'metatag-exclude')), - '#element_validate' => array('token_element_validate'), - '#token_types' => $options['token types'], - ); - - $form['item']['lang'] = isset($this->info['form']['lang']) ? $this->info['form']['lang'] : array(); - - $form['item']['lang'] += array( - '#type' => 'textfield', - '#title' => t('Language'), - '#description' => t("A language code that identifies a natural language spoken, written, or otherwise used for the communication of information."), - '#default_value' => isset($this->data['item']['lang']) ? $this->data['item']['lang'] : '', - '#attributes' => array('class' => array('extended-metatag-field', 'metatag-exclude')), - '#element_validate' => array('token_element_validate'), - '#token_types' => $options['token types'], - ); - - $form['item']['dir'] = isset($this->info['form']['dir']) ? $this->info['form']['dir'] : array(); - - $form['item']['dir'] += array( - '#type' => 'select', - '#title' => t('Text direction'), - '#description' => t("Specifies the base direction of directionally-neutral text."), - '#default_value' => isset($this->data['item']['dir']) ? $this->data['item']['dir'] : '', - '#options' => array( - FALSE => t('- none -'), - 'ltr' => t('Left to right'), - 'rtl' => t('Right to left'), - ), - '#attributes' => array('class' => array('extended-metatag-field', 'metatag-exclude')), - ); - - return $form; - } - - /** - * Implements DrupalMetaTagInterface::getValue(). - */ - public function getValue(array $options = array()) { - $options += array( - 'token data' => array(), - 'clear' => TRUE, - 'sanitize' => TRUE, - 'raw' => FALSE, - ); - - // Check for old single value format. - if (!empty($this->data['value'])) { - $this->data['item']['value'] = $this->data['value']; - } - - if (!isset($this->data['item']['value'])) { - return NULL; - } - - $value = metatag_translate_metatag($this->data['item']['value'], $this->info['name'], $options); - if (empty($options['raw'])) { - // Give other modules the opportunity to use hook_metatag_pattern_alter() - // to modify defined token patterns and values before replacement. - drupal_alter('metatag_pattern', $value, $options['token data']); - $value = token_replace($value, $options['token data'], $options); - } - - $value = $this->tidyValue($value); - - return $value; - } - - /** - * Return the item attributes for the extended tag. - * - * @param array $options - * (optional) An array of options. - * - * @return array - * An array of values. - */ - public function getAttributes(array $options = array()) { - - $options += array( - 'token data' => array(), - 'clear' => TRUE, - 'sanitize' => TRUE, - 'raw' => FALSE, - ); - - $values = $this->data['item']; - - unset($values['value']); - - foreach ($values as $name => $value) { - if (empty($value)) { - unset($values[$name]); - } - } - - if (isset($values['lang'])) { - $values['xml:lang'] = $values['lang']; - } - - foreach ($values as $key => $value) { - if (empty($options['raw'])) { - $value = token_replace($value, $options['token data'], $options); - } - - $values[$key] = $this->tidyValue($value); - } - - return $values; - } - - /** - * Implements DrupalMetaTagInterface::getElement(). - */ - public function getElement(array $options = array()) { - - $element = isset($this->info['element']) ? $this->info['element'] : array(); - - $value = $this->getValue($options); - if (strlen($value) === 0) { - return array(); - } - - $element += array( - '#theme' => 'metatag', - '#tag' => 'meta', - '#id' => 'metatag_' . $this->info['name'], - '#name' => $this->info['name'], - '#value' => $value, - '#attributes' => $this->getAttributes($options), - ); - - // Add header information if desired. - if (!empty($this->info['header'])) { - $element['#attached']['drupal_add_http_header'][] = array( - $this->info['header'], - $value, - ); - } - - return array( - '#attached' => array( - 'drupal_add_html_head' => array( - array( - $element, - $element['#id'], - ), - ), - ), - ); - } -} - -/** * Link type meta tag controller. */ class DrupalLinkMetaTag extends DrupalTextMetaTag { diff --git a/metatag.info b/metatag.info index 0828f1d..6c37c27 100644 --- a/metatag.info +++ b/metatag.info @@ -31,8 +31,6 @@ files[] = tests/metatag.tags.test files[] = tests/metatag.node.test files[] = tests/metatag.term.test files[] = tests/metatag.user.test -; Handling of extended meta tags. -files[] = tests/metatag.extended.test ; Handling of core's default meta tags. files[] = tests/metatag.core_tag_removal.test ; The custom Bulk Revert functionality. diff --git a/metatag_dc/metatag_dc.metatag.inc b/metatag_dc/metatag_dc.metatag.inc index 73425ff..7fbc905 100644 --- a/metatag_dc/metatag_dc.metatag.inc +++ b/metatag_dc/metatag_dc.metatag.inc @@ -12,18 +12,18 @@ function metatag_dc_metatag_bundled_config_alter(array &$configs) { switch ($config->instance) { case 'global': $config->config += array( - 'dcterms.title' => array('item' => array('value' => '[current-page:title]')), - 'dcterms.identifier' => array('item' => array('value' => '[current-page:url:absolute]')), - 'dcterms.type' => array('item' => array('value' => 'Text')), - 'dcterms.format' => array('item' => array('value' => 'text/html')), + 'dcterms.format' => array('value' => 'text/html'), + 'dcterms.identifier' => array('value' => '[current-page:url:absolute]'), + 'dcterms.title' => array('value' => '[current-page:title]'), + 'dcterms.type' => array('value' => 'Text'), ); break; case 'global:frontpage': $config->config += array( - 'dcterms.description' => array('item' => array('value' => '[site:slogan]')), - 'dcterms.title' => array('item' => array('value' => '[site:name]')), - 'dcterms.identifier' => array('item' => array('value' => '[site:url]')), + 'dcterms.description' => array('value' => '[site:slogan]'), + 'dcterms.identifier' => array('value' => '[site:url]'), + 'dcterms.title' => array('value' => '[site:name]'), ); break; @@ -31,34 +31,33 @@ function metatag_dc_metatag_bundled_config_alter(array &$configs) { case 'global:403': case 'global:404': $config->config += array( - 'dcterms.identifier' => array('item' => array('value' => '[site:url]')), - 'dcterms.title' => array('item' => array('value' => '[site:name]')), + 'dcterms.identifier' => array('value' => '[site:url]'), + 'dcterms.title' => array('value' => '[site:name]'), ); break; case 'node': $config->config += array( - 'dcterms.creator' => array('item' => array('value' => '[node:author]')), - 'dcterms.date' => array('item' => array('value' => '[node:created:custom:Y-m-d\TH:iP]')), - 'dcterms.description' => array('item' => array('value' => '[node:summary]')), - 'dcterms.language' => array('item' => array('value' => '[node:language]')), - 'dcterms.title' => array('item' => array('value' => '[node:title]')), + 'dcterms.creator' => array('value' => '[node:author]'), + 'dcterms.date' => array('value' => '[node:created:custom:Y-m-d\TH:iP]'), + 'dcterms.description' => array('value' => '[node:summary]'), + 'dcterms.language' => array('value' => '[node:language]'), + 'dcterms.title' => array('value' => '[node:title]'), ); break; case 'taxonomy_term': $config->config += array( - 'dcterms.description' => array('item' => array('value' => '[term:description]')), - 'dcterms.title' => array('item' => array('value' => '[term:name]')), - 'dcterms.identifier' => array('item' => array('value' => '[current-page:url:absolute]')), + 'dcterms.description' => array('value' => '[term:description]'), + 'dcterms.title' => array('value' => '[term:name]'), ); break; case 'user': $config->config += array( - 'dcterms.creator' => array('item' => array('value' => '[user:name]')), - 'dcterms.date' => array('item' => array('value' => '[user:created:custom:Y-m-d\TH:iP]')), - 'dcterms.title' => array('item' => array('value' => '[user:name]')), + 'dcterms.creator' => array('value' => '[user:name]'), + 'dcterms.date' => array('value' => '[user:created:custom:Y-m-d\TH:iP]'), + 'dcterms.title' => array('value' => '[user:name]'), ); break; } @@ -83,19 +82,17 @@ function metatag_dc_metatag_info() { // Basic tags. $defaults = array( - 'class' => 'DrupalExtendedMetaTag', + 'class' => 'DrupalTextMetaTag', 'group' => 'dublin-core', 'element' => array( '#type' => 'term', + '#theme' => 'metatag_dc', ), ); $info['tags']['dcterms.title'] = array( 'label' => t('Title'), 'description' => t('The name given to the resource.'), - 'element' => array( - '#type' => 'term', - ), 'weight' => ++$weight, ) + $defaults; $info['tags']['dcterms.creator'] = array( diff --git a/metatag_dc/metatag_dc.module b/metatag_dc/metatag_dc.module index b41a573..648fab0 100644 --- a/metatag_dc/metatag_dc.module +++ b/metatag_dc/metatag_dc.module @@ -12,3 +12,29 @@ function metatag_dc_ctools_plugin_api($owner, $api) { return array('version' => 1); } } + +/** + * Implements hook_theme(). + */ +function metatag_dc_theme() { + $info['metatag_dc'] = array( + 'render element' => 'element', + ); + + return $info; +} + +/** + * Theme callback for a Dublin Core meta tag. + */ +function theme_metatag_dc($variables) { + $element = &$variables['element']; + $args = array( + '#name' => 'name', + '#schema' => 'schema', + '#value' => 'content', + ); + element_set_attributes($element, $args); + unset($element['#value']); + return theme('html_tag', $variables); +} diff --git a/tests/metatag.extended.test b/tests/metatag.extended.test deleted file mode 100644 index 7e75876..0000000 --- a/tests/metatag.extended.test +++ /dev/null @@ -1,114 +0,0 @@ - 'Extended metatag tests', - 'description' => 'Test extended meta tags functionality.', - 'group' => 'Metatag', - ); - } - - /** - * {@inheritdoc} - */ - function setUp(array $modules = array()) { - $modules[] = 'metatag_dc'; - parent::setUp($modules); - } - - /** - * Tests extended metatag as used by DC. - */ - public function testExtendedMetatag() { - $this->drupalCreateContentType(array( - 'type' => 'metatag_test', - 'name' => 'Test', - )); - $this->adminUser = $this->drupalCreateUser(array( - 'administer meta tags', - 'edit meta tags', - 'create metatag_test content', - 'delete any metatag_test content', - 'edit any metatag_test content', - )); - $this->drupalLogin($this->adminUser); - - $this->drupalGet('admin/config/search/metatags/config/add'); - $this->drupalPost(NULL, array( - 'instance' => 'node:metatag_test', - ), t('Add and configure')); - // Assert the default is sane. - $this->assertFieldByName('metatags[und][dcterms.title][item][value]', '[node:title]'); - $this->drupalPost(NULL, array( - 'metatags[und][dcterms.title][item][value]' => '[node:title]', - 'metatags[und][dcterms.creator][item][value]' => '[node:author]', - 'metatags[und][dcterms.date][item][value]' => '[node:created:custom:Y-m-d\TH:iP]', - 'metatags[und][dcterms.format][item][value]' => 'text/html', - 'metatags[und][dcterms.identifier][item][value]' => '[current-page:url:absolute]', - 'metatags[und][dcterms.language][item][value]' => '[node:language]', - ), t('Save')); - // Assert field values saved correctly. - $this->drupalGet('admin/config/search/metatags/config/node:metatag_test'); - $this->assertFieldByName('metatags[und][dcterms.title][item][value]', '[node:title]'); - // Submit a node and check default filtering. - $this->drupalGet('node/add/metatag-test'); - // Assert the default is sane. - $this->assertFieldByName('metatags[und][dcterms.title][item][value]', '[node:title]'); - $this->drupalPost(NULL, array( - 'metatags[und][dcterms.title][item][value]' => '[node:title] ponies', - 'metatags[und][robots][value][index]' => '1', - 'metatags[und][dcterms.title][item][dir]' => 'ltr', - 'title' => 'Who likes magic', - ), t('Save')); - $this->assertText(t('Test Who likes magic has been created.')); - $matches = array(); - if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) { - $nid = end($matches); - $node = node_load($nid); - // Only the non-default values are stored. - $expected = array( - 'und' => array( - 'robots' => array( - 'value' => array( - 'index' => 'index', - ), - ), - 'dcterms.title' => array( - 'item' => array( - 'value' => '[node:title] ponies', - 'dir' => 'ltr', - ), - ), - ), - ); - $this->assertEqual($expected, $node->metatags); - } - else { - $this->fail('Could not determine node ID for created node.'); - } - $xpath = $this->xpath("//meta[@name='dcterms.title']"); - $this->assertEqual(count($xpath), 1); - $this->assertEqual($xpath[0]['content'], 'Who likes magic ponies'); - $this->assertEqual($xpath[0]['dir'], 'ltr'); - $xpath = $this->xpath("//meta[@name='robots']"); - $this->assertEqual(count($xpath), 1); - $this->assertEqual($xpath[0]['content'], 'index'); - } - -} diff --git a/metatag_advanced_attributes/metatag_advanced_attributes.inc b/metatag_advanced_attributes/metatag_advanced_attributes.inc new file mode 100644 index 0000000..0fe6835 --- /dev/null +++ b/metatag_advanced_attributes/metatag_advanced_attributes.inc @@ -0,0 +1,201 @@ + array(), + ); + + $form['item'] = array( + '#type' => 'fieldset', + '#title' => $this->info['label'], + '#description' => !empty($this->info['description']) ? $this->info['description'] : '', + '#attributes' => array('class' => array('metatag-item', 'extended-metatag-item')), + // '#tree' => TRUE, + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $form['item']['value'] = isset($this->info['form']['value']) ? $this->info['form']['value'] : array(); + + // Check for old single value format. + if (!empty($this->data['value'])) { + $this->data['item']['value'] = $this->data['value']; + } + + $form['item']['value'] += array( + '#type' => 'textfield', + '#title' => t('Value'), + '#description' => t('The actual value to be used on this field.'), + '#default_value' => isset($this->data['item']['value']) ? $this->data['item']['value'] : '', + '#attributes' => array('class' => array('extended-metatag-field')), + '#element_validate' => array('token_element_validate'), + '#token_types' => $options['token types'], + '#maxlength' => 1024, + ); + + $form['item']['scheme'] = isset($this->info['form']['scheme']) ? $this->info['form']['scheme'] : array(); + + $form['item']['scheme'] += array( + '#type' => 'textfield', + '#title' => t('Scheme'), + '#description' => t('Some metadata standards specify encoding schemes, though it is rarely used.'), + '#default_value' => isset($this->data['item']['scheme']) ? $this->data['item']['scheme'] : '', + '#attributes' => array('class' => array('extended-metatag-field', 'metatag-exclude')), + '#element_validate' => array('token_element_validate'), + '#token_types' => $options['token types'], + ); + + $form['item']['lang'] = isset($this->info['form']['lang']) ? $this->info['form']['lang'] : array(); + + $form['item']['lang'] += array( + '#type' => 'textfield', + '#title' => t('Language'), + '#description' => t("A language code that identifies a natural language spoken, written, or otherwise used for the communication of information."), + '#default_value' => isset($this->data['item']['lang']) ? $this->data['item']['lang'] : '', + '#attributes' => array('class' => array('extended-metatag-field', 'metatag-exclude')), + '#element_validate' => array('token_element_validate'), + '#token_types' => $options['token types'], + ); + + $form['item']['dir'] = isset($this->info['form']['dir']) ? $this->info['form']['dir'] : array(); + + $form['item']['dir'] += array( + '#type' => 'select', + '#title' => t('Text direction'), + '#description' => t("Specifies the base direction of directionally-neutral text."), + '#default_value' => isset($this->data['item']['dir']) ? $this->data['item']['dir'] : '', + '#options' => array( + FALSE => t('- none -'), + 'ltr' => t('Left to right'), + 'rtl' => t('Right to left'), + ), + '#attributes' => array('class' => array('extended-metatag-field', 'metatag-exclude')), + ); + + return $form; + } + + /** + * Implements DrupalMetaTagInterface::getValue(). + */ + public function getValue(array $options = array()) { + $options += array( + 'token data' => array(), + 'clear' => TRUE, + 'sanitize' => TRUE, + 'raw' => FALSE, + ); + + // Check for old single value format. + if (!empty($this->data['value'])) { + $this->data['item']['value'] = $this->data['value']; + } + + if (!isset($this->data['item']['value'])) { + return NULL; + } + + $value = metatag_translate_metatag($this->data['item']['value'], $this->info['name'], $options); + if (empty($options['raw'])) { + // Give other modules the opportunity to use hook_metatag_pattern_alter() + // to modify defined token patterns and values before replacement. + drupal_alter('metatag_pattern', $value, $options['token data']); + $value = token_replace($value, $options['token data'], $options); + } + + $value = $this->tidyValue($value); + + return $value; + } + + /** + * Return the item attributes for the extended tag. + * + * @param array $options + * (optional) An array of options. + * + * @return array + * An array of values. + */ + public function getAttributes(array $options = array()) { + $options += array( + 'token data' => array(), + 'clear' => TRUE, + 'sanitize' => TRUE, + 'raw' => FALSE, + ); + + $values = $this->data['item']; + + unset($values['value']); + + foreach ($values as $name => $value) { + if (empty($value)) { + unset($values[$name]); + } + } + + if (isset($values['lang'])) { + $values['xml:lang'] = $values['lang']; + } + + foreach ($values as $key => $value) { + if (empty($options['raw'])) { + $value = token_replace($value, $options['token data'], $options); + } + + $values[$key] = $this->tidyValue($value); + } + + return $values; + } + + /** + * Implements DrupalMetaTagInterface::getElement(). + */ + public function getElement(array $options = array()) { + $element = isset($this->info['element']) ? $this->info['element'] : array(); + + $value = $this->getValue($options); + if (strlen($value) === 0) { + return array(); + } + + $element += array( + '#theme' => 'metatag', + '#tag' => 'meta', + '#id' => 'metatag_' . $this->info['name'], + '#name' => $this->info['name'], + '#value' => $value, + '#attributes' => $this->getAttributes($options), + ); + + // Add header information if desired. + if (!empty($this->info['header'])) { + $element['#attached']['drupal_add_http_header'][] = array( + $this->info['header'], + $value, + ); + } + + return array( + '#attached' => array( + 'drupal_add_html_head' => array( + array( + $element, + $element['#id'], + ), + ), + ), + ); + } + +} diff --git a/metatag_advanced_attributes/metatag_advanced_attributes.info b/metatag_advanced_attributes/metatag_advanced_attributes.info new file mode 100644 index 0000000..86eada5 --- /dev/null +++ b/metatag_advanced_attributes/metatag_advanced_attributes.info @@ -0,0 +1,11 @@ +name = Metatag: Advanced Attributes +description = "Allow all of the meta tag attributes." +package = SEO +core = 7.x +dependencies[] = metatag + +; The new Metatag class is stored in this file. +files[] = metatag_advanced_attributes.inc + +; Tests. +files[] = tests/metatag_advanced_attributes.test diff --git a/metatag_advanced_attributes/metatag_advanced_attributes.module b/metatag_advanced_attributes/metatag_advanced_attributes.module new file mode 100644 index 0000000..44a3a06 --- /dev/null +++ b/metatag_advanced_attributes/metatag_advanced_attributes.module @@ -0,0 +1,24 @@ + &$tag_info) { + if ($tag_info['class'] == '') { + $tag_info['class'] = 'DrupalExtendedMetaTag'; + if (isset($tag_info['element']['#theme']) && $tag_info['element']['#theme'] == 'metatag_dc') { + unset($tag_info['element']['#theme']); + } + } + } +} diff --git a/metatag_advanced_attributes/tests/metatag_advanced_attributes.test b/metatag_advanced_attributes/tests/metatag_advanced_attributes.test new file mode 100644 index 0000000..8d55c23 --- /dev/null +++ b/metatag_advanced_attributes/tests/metatag_advanced_attributes.test @@ -0,0 +1,124 @@ + 'Metatag Advanced Attributes', + 'description' => 'Test the advanced attributes module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_advanced_attributes'; + $modules[] = 'metatag_dc'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + + /** + * Tests extended metatag as used by DC. + */ + public function testExtendedMetatag() { + $this->drupalCreateContentType(array( + 'type' => 'metatag_test', + 'name' => 'Test', + )); + $this->adminUser = $this->drupalCreateUser(array( + 'administer meta tags', + 'edit meta tags', + 'create metatag_test content', + 'delete any metatag_test content', + 'edit any metatag_test content', + )); + $this->drupalLogin($this->adminUser); + + $this->drupalGet('admin/config/search/metatags/config/add'); + $this->drupalPost(NULL, array( + 'instance' => 'node:metatag_test', + ), t('Add and configure')); + // Assert the default is sane. + $this->assertFieldByName('metatags[und][dcterms.title][item][value]', '[node:title]'); + $this->drupalPost(NULL, array( + 'metatags[und][dcterms.title][item][value]' => '[node:title]', + 'metatags[und][dcterms.creator][item][value]' => '[node:author]', + 'metatags[und][dcterms.date][item][value]' => '[node:created:custom:Y-m-d\TH:iP]', + 'metatags[und][dcterms.format][item][value]' => 'text/html', + 'metatags[und][dcterms.identifier][item][value]' => '[current-page:url:absolute]', + 'metatags[und][dcterms.language][item][value]' => '[node:language]', + ), t('Save')); + // Assert field values saved correctly. + $this->drupalGet('admin/config/search/metatags/config/node:metatag_test'); + $this->assertFieldByName('metatags[und][dcterms.title][item][value]', '[node:title]'); + // Submit a node and check default filtering. + $this->drupalGet('node/add/metatag-test'); + // Assert the default is sane. + $this->assertFieldByName('metatags[und][dcterms.title][item][value]', '[node:title]'); + $this->drupalPost(NULL, array( + 'metatags[und][dcterms.title][item][value]' => '[node:title] ponies', + 'metatags[und][robots][value][index]' => '1', + 'metatags[und][dcterms.title][item][dir]' => 'ltr', + 'title' => 'Who likes magic', + ), t('Save')); + $this->assertText(t('Test Who likes magic has been created.')); + $matches = array(); + if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) { + $nid = end($matches); + $node = node_load($nid); + // Only the non-default values are stored. + $expected = array( + 'und' => array( + 'robots' => array( + 'value' => array( + 'index' => 'index', + ), + ), + 'dcterms.title' => array( + 'item' => array( + 'value' => '[node:title] ponies', + 'dir' => 'ltr', + ), + ), + ), + ); + $this->assertEqual($expected, $node->metatags); + } + else { + $this->fail('Could not determine node ID for created node.'); + } + $xpath = $this->xpath("//meta[@name='dcterms.title']"); + $this->assertEqual(count($xpath), 1); + $this->assertEqual($xpath[0]['content'], 'Who likes magic ponies'); + $this->assertEqual($xpath[0]['dir'], 'ltr'); + $xpath = $this->xpath("//meta[@name='robots']"); + $this->assertEqual(count($xpath), 1); + $this->assertEqual($xpath[0]['content'], 'index'); + } + +}