Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
b5ad27e3
Commit
b5ad27e3
authored
13 years ago
by
catch
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#135464
by Gábor Hojtsy: Follow-up, move tests to block module.
parent
933b844a
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/block/block.test
+186
-0
186 additions, 0 deletions
core/modules/block/block.test
core/modules/language/language.test
+0
-187
0 additions, 187 deletions
core/modules/language/language.test
with
186 additions
and
187 deletions
core/modules/block/block.test
+
186
−
0
View file @
b5ad27e3
...
...
@@ -844,3 +844,189 @@ class BlockHiddenRegionTestCase extends DrupalWebTestCase {
$this
->
assertText
(
'Search'
,
t
(
'Block was displayed on the front page.'
));
}
}
/**
* Functional tests for the language list configuration forms.
*/
class
BlockLanguageTestCase
extends
DrupalWebTestCase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Language block visibility'
,
'description'
=>
'Tests if a block can be configure to be only visibile on a particular language.'
,
'group'
=>
'Block'
,
);
}
function
setUp
()
{
parent
::
setUp
(
'language'
,
'block'
);
}
/**
* Tests the visibility settings for the blocks based on language.
*/
public
function
testLanguageBlockVisibility
()
{
// Create a new user, allow him to manage the blocks and the languages.
$admin_user
=
$this
->
drupalCreateUser
(
array
(
'administer languages'
,
'administer blocks'
,
));
$this
->
drupalLogin
(
$admin_user
);
// Add predefined language.
$edit
=
array
(
'predefined_langcode'
=>
'fr'
,
);
$this
->
drupalPost
(
'admin/config/regional/language/add'
,
$edit
,
t
(
'Add language'
));
$this
->
assertText
(
'French'
,
t
(
'Language added successfully.'
));
// Check if the visibility setting is available.
$this
->
drupalGet
(
'admin/structure/block/add'
);
$this
->
assertField
(
'langcodes[en]'
,
t
(
'Language visibility field is visible.'
));
// Create a new block.
$info_name
=
$this
->
randomString
(
10
);
$body
=
''
;
for
(
$i
=
0
;
$i
<=
100
;
$i
++
)
{
$body
.
=
chr
(
rand
(
97
,
122
));
}
$edit
=
array
(
'regions[stark]'
=>
'sidebar_first'
,
'info'
=>
$info_name
,
'title'
=>
'test'
,
'body[value]'
=>
$body
,
);
$this
->
drupalPost
(
'admin/structure/block/add'
,
$edit
,
t
(
'Save block'
));
// Set visibility setting for one language.
$edit
=
array
(
'langcodes[en]'
=>
TRUE
,
);
$this
->
drupalPost
(
'admin/structure/block/manage/block/1/configure'
,
$edit
,
t
(
'Save block'
));
// Change the default language.
$edit
=
array
(
'site_default'
=>
'fr'
,
);
$this
->
drupalPost
(
'admin/config/regional/language'
,
$edit
,
t
(
'Save configuration'
));
// Reset the static cache of the language list.
drupal_static_reset
(
'language_list'
);
// Check that a page has a block
$this
->
drupalGet
(
''
,
array
(
'language'
=>
language_load
(
'en'
)));
$this
->
assertText
(
$body
,
t
(
'The body of the custom block appears on the page.'
));
// Check that a page doesn't has a block for the current language anymore
$this
->
drupalGet
(
''
,
array
(
'language'
=>
language_load
(
'fr'
)));
$this
->
assertNoText
(
$body
,
t
(
'The body of the custom block does not appear on the page.'
));
}
/**
* Tests if the visibility settings are removed if the language is deleted.
*/
public
function
testLanguageBlockVisibilityLanguageDelete
()
{
// Create a new user, allow him to manage the blocks and the languages.
$admin_user
=
$this
->
drupalCreateUser
(
array
(
'administer languages'
,
'administer blocks'
,
));
$this
->
drupalLogin
(
$admin_user
);
// Add predefined language.
$edit
=
array
(
'predefined_langcode'
=>
'fr'
,
);
$this
->
drupalPost
(
'admin/config/regional/language/add'
,
$edit
,
t
(
'Add language'
));
$this
->
assertText
(
'French'
,
t
(
'Language added successfully.'
));
// Create a new block.
$info_name
=
$this
->
randomString
(
10
);
$body
=
''
;
for
(
$i
=
0
;
$i
<=
100
;
$i
++
)
{
$body
.
=
chr
(
rand
(
97
,
122
));
}
$edit
=
array
(
'regions[stark]'
=>
'sidebar_first'
,
'info'
=>
$info_name
,
'title'
=>
'test'
,
'body[value]'
=>
$body
,
);
$this
->
drupalPost
(
'admin/structure/block/add'
,
$edit
,
t
(
'Save block'
));
// Set visibility setting for one language.
$edit
=
array
(
'langcodes[fr]'
=>
TRUE
,
);
$this
->
drupalPost
(
'admin/structure/block/manage/block/1/configure'
,
$edit
,
t
(
'Save block'
));
// Check that we have an entry in the database after saving the setting.
$count
=
db_query
(
'SELECT COUNT(langcode) FROM {block_language} WHERE module = :module AND delta = :delta'
,
array
(
':module'
=>
'block'
,
':delta'
=>
'1'
))
->
fetchField
();
$this
->
assertTrue
(
$count
==
1
,
t
(
'The block language visibility has an entry in the database.'
));
// Delete the language.
$this
->
drupalPost
(
'admin/config/regional/language/delete/fr'
,
array
(),
t
(
'Delete'
));
// Check that the setting related to this language has been deleted.
$count
=
db_query
(
'SELECT COUNT(langcode) FROM {block_language} WHERE module = :module AND delta = :delta'
,
array
(
':module'
=>
'block'
,
':delta'
=>
'1'
))
->
fetchField
();
$this
->
assertTrue
(
$count
==
0
,
t
(
'The block language visibility do not have an entry in the database.'
));
}
/**
* Tests if the visibility settings are removed if the block is deleted.
*/
public
function
testLanguageBlockVisibilityBlockDelete
()
{
// Create a new user, allow him to manage the blocks and the languages.
$admin_user
=
$this
->
drupalCreateUser
(
array
(
'administer languages'
,
'administer blocks'
,
));
$this
->
drupalLogin
(
$admin_user
);
// Add predefined language.
$edit
=
array
(
'predefined_langcode'
=>
'fr'
,
);
$this
->
drupalPost
(
'admin/config/regional/language/add'
,
$edit
,
t
(
'Add language'
));
$this
->
assertText
(
'French'
,
t
(
'Language added successfully.'
));
// Create a new block.
$info_name
=
$this
->
randomString
(
10
);
$body
=
''
;
for
(
$i
=
0
;
$i
<=
100
;
$i
++
)
{
$body
.
=
chr
(
rand
(
97
,
122
));
}
$edit
=
array
(
'regions[stark]'
=>
'sidebar_first'
,
'info'
=>
$info_name
,
'title'
=>
'test'
,
'body[value]'
=>
$body
,
);
$this
->
drupalPost
(
'admin/structure/block/add'
,
$edit
,
t
(
'Save block'
));
// Set visibility setting for one language.
$edit
=
array
(
'langcodes[fr]'
=>
TRUE
,
);
$this
->
drupalPost
(
'admin/structure/block/manage/block/1/configure'
,
$edit
,
t
(
'Save block'
));
// Check that we have an entry in the database after saving the setting.
$count
=
db_query
(
'SELECT COUNT(langcode) FROM {block_language} WHERE module = :module AND delta = :delta'
,
array
(
':module'
=>
'block'
,
':delta'
=>
'1'
))
->
fetchField
();
$this
->
assertTrue
(
$count
==
1
,
t
(
'The block language visibility has an entry in the database.'
));
// Delete the custom block.
$this
->
drupalPost
(
'admin/structure/block/manage/block/1/delete'
,
array
(),
t
(
'Delete'
));
// Check that the setting related to this block has been deleted.
$count
=
db_query
(
'SELECT COUNT(langcode) FROM {block_language} WHERE module = :module AND delta = :delta'
,
array
(
':module'
=>
'block'
,
':delta'
=>
'1'
))
->
fetchField
();
$this
->
assertTrue
(
$count
==
0
,
t
(
'The block language visibility do not have an entry in the database.'
));
}
}
This diff is collapsed.
Click to expand it.
core/modules/language/language.test
+
0
−
187
View file @
b5ad27e3
...
...
@@ -266,190 +266,3 @@ class LanguageDependencyInjectionTest extends DrupalWebTestCase {
variable_del
(
'language_default'
);
}
}
/**
* Functional tests for the language list configuration forms.
*/
class
LanguageBlockVisibilityTest
extends
DrupalWebTestCase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Language block visibility'
,
'description'
=>
'Tests if a block can be configure to be only visibile on a particular language.'
,
'group'
=>
'Language'
,
);
}
function
setUp
()
{
parent
::
setUp
(
'language'
,
'locale'
,
'block'
);
}
/**
* Tests the visibility settings for the blocks based on language.
*/
public
function
testLanguageBlockVisibility
()
{
// Create a new user, allow him to manage the blocks and the languages.
$admin_user
=
$this
->
drupalCreateUser
(
array
(
'administer languages'
,
'administer blocks'
,
));
$this
->
drupalLogin
(
$admin_user
);
// Add predefined language.
$edit
=
array
(
'predefined_langcode'
=>
'fr'
,
);
$this
->
drupalPost
(
'admin/config/regional/language/add'
,
$edit
,
t
(
'Add language'
));
$this
->
assertText
(
'French'
,
t
(
'Language added successfully.'
));
// Check if the visibility setting is available.
$this
->
drupalGet
(
'admin/structure/block/add'
);
$this
->
assertField
(
'langcodes[en]'
,
t
(
'Language visibility field is visible.'
));
// Create a new block.
$info_name
=
$this
->
randomString
(
10
);
$body
=
''
;
for
(
$i
=
0
;
$i
<=
100
;
$i
++
)
{
$body
.
=
chr
(
rand
(
97
,
122
));
}
$edit
=
array
(
'regions[stark]'
=>
'sidebar_first'
,
'info'
=>
$info_name
,
'title'
=>
'test'
,
'body[value]'
=>
$body
,
);
$this
->
drupalPost
(
'admin/structure/block/add'
,
$edit
,
t
(
'Save block'
));
// Set visibility setting for one language.
$edit
=
array
(
'langcodes[en]'
=>
TRUE
,
);
$this
->
drupalPost
(
'admin/structure/block/manage/block/1/configure'
,
$edit
,
t
(
'Save block'
));
// Change the default language.
$edit
=
array
(
'site_default'
=>
'fr'
,
);
$this
->
drupalPost
(
'admin/config/regional/language'
,
$edit
,
t
(
'Save configuration'
));
// Reset the static cache of the language list.
drupal_static_reset
(
'language_list'
);
// Check that a page has a block
$this
->
drupalGet
(
''
,
array
(
'language'
=>
language_load
(
'en'
)));
$this
->
assertText
(
$body
,
t
(
'The body of the custom block appears on the page.'
));
// Check that a page doesn't has a block for the current language anymore
$this
->
drupalGet
(
''
,
array
(
'language'
=>
language_load
(
'fr'
)));
$this
->
assertNoText
(
$body
,
t
(
'The body of the custom block does not appear on the page.'
));
}
/**
* Tests if the visibility settings are removed if the language is deleted.
*/
public
function
testLanguageBlockVisibilityLanguageDelete
()
{
// Create a new user, allow him to manage the blocks and the languages.
$admin_user
=
$this
->
drupalCreateUser
(
array
(
'administer languages'
,
'administer blocks'
,
));
$this
->
drupalLogin
(
$admin_user
);
// Add predefined language.
$edit
=
array
(
'predefined_langcode'
=>
'fr'
,
);
$this
->
drupalPost
(
'admin/config/regional/language/add'
,
$edit
,
t
(
'Add language'
));
$this
->
assertText
(
'French'
,
t
(
'Language added successfully.'
));
// Create a new block.
$info_name
=
$this
->
randomString
(
10
);
$body
=
''
;
for
(
$i
=
0
;
$i
<=
100
;
$i
++
)
{
$body
.
=
chr
(
rand
(
97
,
122
));
}
$edit
=
array
(
'regions[stark]'
=>
'sidebar_first'
,
'info'
=>
$info_name
,
'title'
=>
'test'
,
'body[value]'
=>
$body
,
);
$this
->
drupalPost
(
'admin/structure/block/add'
,
$edit
,
t
(
'Save block'
));
// Set visibility setting for one language.
$edit
=
array
(
'langcodes[fr]'
=>
TRUE
,
);
$this
->
drupalPost
(
'admin/structure/block/manage/block/1/configure'
,
$edit
,
t
(
'Save block'
));
// Check that we have an entry in the database after saving the setting.
$count
=
db_query
(
'SELECT COUNT(langcode) FROM {block_language} WHERE module = :module AND delta = :delta'
,
array
(
':module'
=>
'block'
,
':delta'
=>
'1'
))
->
fetchField
();
$this
->
assertTrue
(
$count
==
1
,
t
(
'The block language visibility has an entry in the database.'
));
// Delete the language.
$this
->
drupalPost
(
'admin/config/regional/language/delete/fr'
,
array
(),
t
(
'Delete'
));
// Check that the setting related to this language has been deleted.
$count
=
db_query
(
'SELECT COUNT(langcode) FROM {block_language} WHERE module = :module AND delta = :delta'
,
array
(
':module'
=>
'block'
,
':delta'
=>
'1'
))
->
fetchField
();
$this
->
assertTrue
(
$count
==
0
,
t
(
'The block language visibility do not have an entry in the database.'
));
}
/**
* Tests if the visibility settings are removed if the block is deleted.
*/
public
function
testLanguageBlockVisibilityBlockDelete
()
{
// Create a new user, allow him to manage the blocks and the languages.
$admin_user
=
$this
->
drupalCreateUser
(
array
(
'administer languages'
,
'administer blocks'
,
));
$this
->
drupalLogin
(
$admin_user
);
// Add predefined language.
$edit
=
array
(
'predefined_langcode'
=>
'fr'
,
);
$this
->
drupalPost
(
'admin/config/regional/language/add'
,
$edit
,
t
(
'Add language'
));
$this
->
assertText
(
'French'
,
t
(
'Language added successfully.'
));
// Create a new block.
$info_name
=
$this
->
randomString
(
10
);
$body
=
''
;
for
(
$i
=
0
;
$i
<=
100
;
$i
++
)
{
$body
.
=
chr
(
rand
(
97
,
122
));
}
$edit
=
array
(
'regions[stark]'
=>
'sidebar_first'
,
'info'
=>
$info_name
,
'title'
=>
'test'
,
'body[value]'
=>
$body
,
);
$this
->
drupalPost
(
'admin/structure/block/add'
,
$edit
,
t
(
'Save block'
));
// Set visibility setting for one language.
$edit
=
array
(
'langcodes[fr]'
=>
TRUE
,
);
$this
->
drupalPost
(
'admin/structure/block/manage/block/1/configure'
,
$edit
,
t
(
'Save block'
));
// Check that we have an entry in the database after saving the setting.
$count
=
db_query
(
'SELECT COUNT(langcode) FROM {block_language} WHERE module = :module AND delta = :delta'
,
array
(
':module'
=>
'block'
,
':delta'
=>
'1'
))
->
fetchField
();
$this
->
assertTrue
(
$count
==
1
,
t
(
'The block language visibility has an entry in the database.'
));
// Delete the custom block.
$this
->
drupalPost
(
'admin/structure/block/manage/block/1/delete'
,
array
(),
t
(
'Delete'
));
// Check that the setting related to this block has been deleted.
$count
=
db_query
(
'SELECT COUNT(langcode) FROM {block_language} WHERE module = :module AND delta = :delta'
,
array
(
':module'
=>
'block'
,
':delta'
=>
'1'
))
->
fetchField
();
$this
->
assertTrue
(
$count
==
0
,
t
(
'The block language visibility do not have an entry in the database.'
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment