/[drupal]/contributions/modules/translation_overview/translation_overview.test
ViewVC logotype

Contents of /contributions/modules/translation_overview/translation_overview.test

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Thu Sep 11 23:21:07 2008 UTC (14 months, 2 weeks ago) by drewish
Branch: MAIN
CVS Tags: DRUPAL-6--2-3, DRUPAL-6--2-2, DRUPAL-6--2-1, DRUPAL-6--2-0, DRUPAL-6--2-0-BETA1, DRUPAL-6--2-0-BETA2, DRUPAL-6--2-0-BETA3, DRUPAL-6--2-1-BETA1, DRUPAL-6--2-1-BETA2, HEAD
Branch point for: DRUPAL-6--2
File MIME type: text/x-php
New 2.x branch with priority assignments.
1 <?php
2 class TranslationOverviewPriorityTestCase extends DrupalWebTestCase {
3 /**
4 * Implementation of getInfo().
5 */
6 function getInfo() {
7 return array(
8 'name' => t('Translation Priority'),
9 'description' => t('Submit priorities to the translation tab and ensure that they are saved.'),
10 'group' => t('Translation Overview'),
11 );
12 }
13
14 function setUp() {
15 parent::setUp('locale', 'translation', 'translation overview');
16
17 // Setup users.
18 $this->admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages'));
19 $this->translator = $this->drupalCreateUser(array('create page content', 'edit own page content', 'translate content'));
20
21 $this->drupalLogin($this->admin_user);
22
23 // Add languages.
24 $this->addLanguage('en');
25 $this->addLanguage('es');
26 $this->addLanguage('ja');
27 $this->addLanguage('ko');
28
29 // Set page content type to use multilingual support with translation.
30 $this->drupalGet('admin/content/node-type/page');
31 $this->drupalPost('admin/content/node-type/page', array('language_content_type' => '2'), t('Save content type'));
32 $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Page')), t('Page content type has been updated.'));
33
34 $this->drupalLogout();
35 $this->drupalLogin($this->translator);
36
37 // Create page in English.
38 $node_title = 'Test Translation ' . $this->randomName();
39 $this->en_node = $this->createPage($node_title, 'Node body.', 'en');
40 }
41
42 function testTranslationOverviewDatabaseRecord() {
43
44
45 // Submit translation in Spanish.
46 $node_trans_title = 'Test Traduccion ' . $this->randomName();
47 $node_trans = $this->createTranslation($this->en_node->nid, $node_trans_title, 'Nodo cuerpo.', 'es');
48
49 }
50
51
52 function testTranslationOverviewRelatedTab() {
53 $this->drupalGet('node/'. $this->en_node->nid .'/translate');
54 $this->assertRaw(t('Translation Priorites'), t('Tranlation Priorites injecting into the form.'));
55 }
56
57 /**
58 * Install a the specified language if it has not been already. Otherwise make sure that
59 * the language is enabled.
60 *
61 * @param string $language_code The langauge code the check.
62 */
63 function addLanguage($language_code) {
64 // Check to make sure that language has not already been installed.
65 $this->drupalGet('admin/settings/language');
66
67 if (strpos($this->drupalGetContent(), 'enabled[' . $language_code . ']') === FALSE) {
68 // Doesn't have language installed so add it.
69 $edit = array();
70 $edit['langcode'] = $language_code;
71 $this->drupalPost('admin/settings/language/add', $edit, t('Add language'));
72
73 $languages = language_list('language', TRUE); // make sure not using cached version
74 $this->assertTrue(array_key_exists($language_code, $languages), t('Language [' . $language_code . '] was installed successfully.'));
75 if (array_key_exists($language_code, $languages)) {
76 # $this->assertRaw(t('The language %language has been created and can now be used. More information is available on the <a href="@locale-help">help screen</a>.', array('%language' => t($languages[$language_code]->name), '@locale-help' => url('admin/help/locale'))), t('Language has been created.'));
77 }
78 }
79 else {
80 // Ensure that it is enabled.
81 $this->assertTrue(true, 'Language [' . $language_code . '] already installed.');
82 $this->drupalPost(NULL, array('enabled[' . $language_code . ']' => TRUE), t('Save configuration'));
83
84 $this->assertRaw(t('Configuration saved.'), t('Language successfully enabled.'));
85 }
86 }
87
88 /**
89 * Create a page in the specified language.
90 *
91 * @param string $title Title of page in specified language.
92 * @param string $body Body of page in specified language.
93 * @param string $language Langauge code.
94 */
95 function createPage($title, $body, $language) {
96 $edit = array();
97 $edit['title'] = $title;
98 $edit['body'] = $body;
99 $edit['language'] = $language;
100 $this->drupalPost('node/add/page', $edit, t('Save'));
101 $this->assertRaw(t('Page %title has been created.', array('%title' => $edit['title'])), t('Page created.'));
102
103 // Check to make sure the node was created.
104 $node = node_load(array('title' => $edit['title']));
105 $this->assertTrue($node, t('Node found in database.'));
106
107 return $node;
108 }
109
110 /**
111 * Create a translation for the specified page in the specified language.
112 *
113 * @param integer $nid Node id of page to create translation for.
114 * @param string $title Title of page in specified language.
115 * @param string $body Body of page in specified language.
116 * @param string $language Langauge code.
117 */
118 function createTranslation($nid, $title, $body, $language) {
119 $this->drupalGet('node/add/page', array('query' => array('translation' => $nid, 'language' => $language)));
120
121 $edit = array();
122 $edit['title'] = $title;
123 $edit['body'] = $body;
124 $this->drupalPost(NULL, $edit, t('Save'));
125 $this->assertRaw(t('Page %title has been created.', array('%title' => $edit['title'])), t('Translation created.'));
126
127 // Check to make sure that translation was successfull.
128 $node = node_load(array('title' => $edit['title']));
129 $this->assertTrue($node, t('Node found in database.'));
130
131 return $node;
132 }
133 }

  ViewVC Help
Powered by ViewVC 1.1.2