Commit 63985a31 authored by RenatoG's avatar RenatoG Committed by RenatoG

Issue #2906618 by RenatoG: Fix Drupal Coding Standards for XML sitemap i18n

parent 327ccba3
......@@ -4,5 +4,4 @@ package = XML sitemap
core = 7.x
dependencies[] = xmlsitemap
dependencies[] = i18n
files[] = xmlsitemap_i18n.module
files[] = xmlsitemap_i18n.test
<?php
/**
* @file
* Main file for XML sitemap i18n.
*/
/**
* Implements hook_xmlsitemap_context_info().
*/
......@@ -88,14 +93,18 @@ function xmlsitemap_i18n_query_xmlsitemap_generate_alter(QueryAlterableInterface
// Current language and language neutral.
$query->condition('x.language', array($current, LANGUAGE_NONE));
break;
case 'mixed':
// Mixed current language (if available) or default language (if not) and language neutral.
// Mixed current language (if available) or default language (if not) and
// language neutral.
$query->condition('x.language', array($current, $default, LANGUAGE_NONE));
break;
case 'default':
// Only default language and language neutral.
$query->condition('x.language', array($default, LANGUAGE_NONE));
break;
case 'strict':
// Only current language (for nodes), simple for all other types.
$node_condition = db_and();
......@@ -109,6 +118,7 @@ function xmlsitemap_i18n_query_xmlsitemap_generate_alter(QueryAlterableInterface
$condition->condition($normal_condition);
$query->condition($condition);
break;
case 'off':
// All content. No language conditions apply.
break;
......
......@@ -2,19 +2,29 @@
/**
* @file
* Unit tests for the xmlsitemap_i18n module.
* Unit tests for the xmlsitemap_i18n project.
*/
/**
* Common base test class for XML sitemap internationalization tests.
*/
class XMLSitemapI18nWebTestCase extends XMLSitemapTestHelper {
/**
* Admin User.
*
* @var string
*
* @codingStandardsIgnoreStart
*/
protected $admin_user;
/**
* Set up an administrative user account and testing keys.
*
* @codingStandardsIgnoreEnd
*/
function setUp($modules = array()) {
public function setUp($modules = array()) {
// Call parent::setUp() allowing test cases to pass further modules.
$modules[] = 'locale';
$modules[] = 'translation';
......@@ -30,6 +40,7 @@ class XMLSitemapI18nWebTestCase extends XMLSitemapTestHelper {
// Create the two different language-context sitemaps.
db_query("DELETE FROM {xmlsitemap_sitemap}");
$sitemap = new stdClass();
$sitemap->context = array('language' => 'en');
xmlsitemap_sitemap_save($sitemap);
......@@ -37,9 +48,17 @@ class XMLSitemapI18nWebTestCase extends XMLSitemapTestHelper {
$sitemap->context = array('language' => 'fr');
xmlsitemap_sitemap_save($sitemap);
}
}
/**
* I18n Test.
*/
class XMLSitemapI18nTest extends XMLSitemapI18nWebTestCase {
/**
* Get Info.
*/
public static function getInfo() {
return array(
'name' => 'XML sitemap i18n tests',
......@@ -49,7 +68,10 @@ class XMLSitemapI18nTest extends XMLSitemapI18nWebTestCase {
);
}
function testLanguageSelection() {
/**
* Language Selection.
*/
public function testLanguageSelection() {
// Create our three different language nodes.
$node = $this->addSitemapLink(array('type' => 'node', 'language' => LANGUAGE_NONE));
$node_en = $this->addSitemapLink(array('type' => 'node', 'language' => 'en'));
......@@ -104,9 +126,17 @@ class XMLSitemapI18nTest extends XMLSitemapI18nWebTestCase {
$this->assertRawSitemapLinks($node_fr, $link, $link_fr);
$this->assertNoRawSitemapLinks($node, $node_en, $link_en);
}
}
/**
* Node Test.
*/
class XMLSitemapI18nNodeTest extends XMLSitemapI18nWebTestCase {
/**
* Get Info.
*/
public static function getInfo() {
return array(
'name' => 'XML sitemap i18n node tests',
......@@ -116,7 +146,10 @@ class XMLSitemapI18nNodeTest extends XMLSitemapI18nWebTestCase {
);
}
function setUp($modules = array()) {
/**
* Setup.
*/
public function setUp($modules = array()) {
$modules[] = 'xmlsitemap_node';
parent::setUp($modules);
......@@ -125,7 +158,10 @@ class XMLSitemapI18nNodeTest extends XMLSitemapI18nWebTestCase {
$this->drupalLogin($this->admin_user);
}
function testNodeLanguageData() {
/**
* Node Language Data.
*/
public function testNodeLanguageData() {
$node = $this->drupalCreateNode(array());
$this->drupalPost('node/' . $node->nid . '/edit', array('language' => 'en'), t('Save'));
......@@ -136,4 +172,5 @@ class XMLSitemapI18nNodeTest extends XMLSitemapI18nWebTestCase {
$link = $this->assertSitemapLink('node', $node->nid);
$this->assertIdentical($link['language'], 'fr');
}
}
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