Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
cd15c2a7
Commit
cd15c2a7
authored
Sep 01, 2012
by
Angie Byron
Browse files
Missing tests. I bet it'll work better now.
parent
e6a4819e
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php
0 → 100644
View file @
cd15c2a7
<?php
/**
* @file
* Definition of Drupal\language\Tests\LanguageCustomConfigurationTest.
*/
namespace
Drupal\language\Tests
;
use
Drupal\simpletest\WebTestBase
;
use
Drupal\Core\Language\Language
;
/**
* Functional tests for language configuration.
*/
class
LanguageCustomLanguageConfigurationTest
extends
WebTestBase
{
/**
* Modules to enable.
*
* @var array
*/
public
static
$modules
=
array
(
'language'
);
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Custom Language configuration'
,
'description'
=>
'Adds and configures custom languages.'
,
'group'
=>
'Language'
,
);
}
/**
* Functional tests for adding, editing and deleting languages.
*/
public
function
testLanguageConfiguration
()
{
global
$base_url
;
// Create user with permissions to add and remove languages.
$admin_user
=
$this
->
drupalCreateUser
(
array
(
'administer languages'
,
'access administration pages'
));
$this
->
drupalLogin
(
$admin_user
);
// Add custom language.
$edit
=
array
(
'predefined_langcode'
=>
'custom'
,
);
$this
->
drupalPost
(
'admin/config/regional/language/add'
,
$edit
,
t
(
'Add custom language'
));
// Test validation on missing values.
$this
->
assertText
(
t
(
'!name field is required.'
,
array
(
'!name'
=>
t
(
'Language code'
))));
$this
->
assertText
(
t
(
'!name field is required.'
,
array
(
'!name'
=>
t
(
'Language name'
))));
$empty_language
=
new
Language
();
$this
->
assertFieldChecked
(
'edit-direction-'
.
$empty_language
->
direction
,
'Consistent usage of language direction.'
);
$this
->
assertEqual
(
$this
->
getUrl
(),
url
(
'admin/config/regional/language/add'
,
array
(
'absolute'
=>
TRUE
)),
'Correct page redirection.'
);
// Test validation of invalid values.
$edit
=
array
(
'predefined_langcode'
=>
'custom'
,
'langcode'
=>
'white space'
,
'name'
=>
'<strong>evil markup</strong>'
,
'direction'
=>
LANGUAGE_LTR
,
);
$this
->
drupalPost
(
'admin/config/regional/language/add'
,
$edit
,
t
(
'Add custom language'
));
$this
->
assertRaw
(
t
(
'%field may only contain characters a-z, underscores, or hyphens.'
,
array
(
'%field'
=>
t
(
'Language code'
))));
$this
->
assertRaw
(
t
(
'%field cannot contain any markup.'
,
array
(
'%field'
=>
t
(
'Language name'
))));
$this
->
assertEqual
(
$this
->
getUrl
(),
url
(
'admin/config/regional/language/add'
,
array
(
'absolute'
=>
TRUE
)),
'Correct page redirection.'
);
// Test validation of existing language values.
$edit
=
array
(
'predefined_langcode'
=>
'custom'
,
'langcode'
=>
'de'
,
'name'
=>
'German'
,
'direction'
=>
LANGUAGE_LTR
,
);
// Add the language the first time.
$this
->
drupalPost
(
'admin/config/regional/language/add'
,
$edit
,
t
(
'Add custom language'
));
$this
->
assertRaw
(
t
(
'The language %language has been created and can now be used.'
,
array
(
'%language'
=>
$edit
[
'name'
])
));
$this
->
assertEqual
(
$this
->
getUrl
(),
url
(
'admin/config/regional/language'
,
array
(
'absolute'
=>
TRUE
)),
'Correct page redirection.'
);
// Add the language a second time and confirm that this is not allowed.
$this
->
drupalPost
(
'admin/config/regional/language/add'
,
$edit
,
t
(
'Add custom language'
));
$this
->
assertRaw
(
t
(
'The language %language (%langcode) already exists.'
,
array
(
'%language'
=>
$edit
[
'name'
],
'%langcode'
=>
$edit
[
'langcode'
])
));
$this
->
assertEqual
(
$this
->
getUrl
(),
url
(
'admin/config/regional/language/add'
,
array
(
'absolute'
=>
TRUE
)),
'Correct page redirection.'
);
}
}
core/modules/locale/lib/Drupal/locale/TranslationsStream.php
0 → 100644
View file @
cd15c2a7
<?php
/**
* @file
* Definition of Drupal\locale\TranslationStream.
*/
namespace
Drupal\locale
;
use
Drupal\Core\StreamWrapper\LocalStream
;
/**
* Defines a Drupal translations (translations://) stream wrapper class.
*
* Provides support for storing translation files.
*/
class
TranslationsStream
extends
LocalStream
{
/**
* Implements Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath()
*/
function
getDirectoryPath
()
{
return
variable_get
(
'locale_translate_file_directory'
,
conf_path
()
.
'/files/translations'
);
}
/**
* Implements Drupal\Core\StreamWrapper\StreamWrapperInterface::getExternalUrl().
* @throws \LogicException PO files URL should not be public.
*/
function
getExternalUrl
()
{
throw
new
\
LogicException
(
'PO files URL should not be public.'
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment