Skip to content

Commit 0d76297

Browse files
committed
Carry changes to unsupported submodules from latest 7.x-1.x.
1 parent 3dede93 commit 0d76297

34 files changed

+1446
-541
lines changed

modules/mongodb/tests.bash

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/usr/bin/env bash
2+
3+
# This script makes it easy to run the Simpletests for the modules in the
4+
# MongoDB package. Use it in just three steps if you havec Drush in your path:
5+
#
6+
# 1 enable Simpletest: "drush en -y simpletest"
7+
# 2 edit your your settings*.php to configure MongoDB connection and cache plugin.
8+
# 3 run: "bash tests.bash <absolute path to Drupal root>"
9+
#
10+
# Notice: the script itself uses Drush to flush caches.
11+
12+
# The path where the script will leave JUnit test results
13+
OUTPUT_DIR=/tmp/xml
14+
# The user name under which your web server runs
15+
WEB_USER=www-data
16+
# The prefix of the test groups to run.
17+
PREFIX="MongoDB:"
18+
# The test groups to run.
19+
TESTS="Base Cache Watchdog"
20+
# The Drupal root directory. Dynamic from script arguments.
21+
BASE=
22+
23+
# Is the specified directory a Drupal root ?
24+
#
25+
# @return int
26+
# - 0 on success
27+
# - 1 on failure (not a Drupal root)
28+
function isDrupal {
29+
local base=$1
30+
local result
31+
32+
if [ ! -d "$base" ]; then
33+
return 1
34+
fi
35+
36+
pushd "$base" > /dev/null
37+
[ -d includes -a -d misc -a -d modules -a -d profiles -a -d sites -a -d themes ]
38+
result=$?
39+
popd > /dev/null
40+
41+
return "$result"
42+
}
43+
44+
# Validate script arguments look sane.
45+
function validate_arguments {
46+
# http://tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF
47+
if [ "$#" -ne 1 ]; then
48+
echo -e "Usage:\nbash $0 <site-root-directory>"
49+
exit 64
50+
else
51+
BASE=$1
52+
isDrupal $BASE
53+
if [ $? -ne 0 ]; then
54+
echo "$BASE does not look like a Drupal 7 site root."
55+
exit 65
56+
fi
57+
fi
58+
}
59+
60+
# Run the module tests groups
61+
function run {
62+
local base=$1
63+
local user=$2
64+
local output_dir=$3
65+
local prefix=$4
66+
local tests=${@:5}
67+
local group
68+
69+
echo -e "Running tests in $base\n"
70+
cd "$base"
71+
mkdir -p "$output_dir"
72+
73+
# Do not wrap $tests in "". It needs to be split on IFS.
74+
for test in $tests; do
75+
group="$prefix $test"
76+
echo Running $group test group
77+
78+
# Testers might well have renamed run-tests.sh to run-tests.php,
79+
# so allow it with a wildcard.
80+
sudo -u $user php scripts/run-tests* \
81+
--php /usr/bin/php \
82+
--concurrency 1 \
83+
--color \
84+
--xml "$output_dir" \
85+
"$group"
86+
if [ $? -ne 0 ]; then
87+
break;
88+
fi
89+
done
90+
}
91+
92+
# Clean the Simpletest leftovers.
93+
function clean {
94+
local base=$1
95+
local user=$2
96+
local output=$3
97+
98+
echo "Cleaning leftover test results in $base"
99+
cd "$base"
100+
drush cc all
101+
echo "Cleaning leftover test collections in MongoDB"
102+
drush mdct
103+
sudo -u $user php scripts/run-tests* --clean
104+
echo "Removing results directory $output"
105+
rm -fr "$output"
106+
}
107+
108+
# ---- Main logic -------------------------------------------------------------
109+
110+
validate_arguments $1
111+
valid=$?
112+
if [ "$valid" -ne 0 ]; then
113+
exit "$valid"
114+
fi
115+
116+
run "$BASE" "$WEB_USER" "$OUTPUT_DIR" "$PREFIX" "$TESTS"
117+
clean "$BASE" "$WEB_USER" "$OUTPUT_DIR"

modules/mongodb_block/mongodb_block.info

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
21
name = MongoDB Block
32
description = MongoDB based block system
43
package = MongoDB
5-
version = VERSION
64
dependencies[] = mongodb
75
core = 7.x
86
files[] = mongodb_block.module

modules/mongodb_block/mongodb_block.module

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ function mongodb_block_page_build(&$page) {
6969
$all_regions = system_region_list($theme);
7070

7171
$collection = mongodb_collection('block', $theme);
72-
if (!$collection->findOne()) {
72+
// Fastest way to check if collection is not empty, per #2072135.
73+
if (!$collection->find()->limit(1)->hasNext()) {
7374
_mongodb_block_rehash($theme);
7475
}
7576
$query = array();

modules/mongodb_block_ui/mongodb_block_ui.admin.inc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* Admin page callbacks for the mongodb_block_ui module.
66
*/
77

8-
98
/**
109
* Menu callback for admin/structure/mongodb_block_ui/demo.
1110
*/
@@ -17,7 +16,7 @@ function mongodb_block_ui_admin_demo($theme = NULL) {
1716
/**
1817
* Menu callback for admin/structure/mongodb_block_ui.
1918
*
20-
* @param $theme
19+
* @param $theme
2120
* The theme to display the administration page for. If not provided, defaults
2221
* to the currently used theme.
2322
*/
@@ -228,6 +227,13 @@ function mongodb_block_ui_admin_configure($form, &$form_state, $theme, $module,
228227
drupal_set_title(t("'%name' block", array('%name' => $info[$delta]['info'])), PASS_THROUGH);
229228
}
230229

230+
// Module-specific block configuration.
231+
if ($settings = module_invoke($module, 'block_configure', $delta)) {
232+
foreach ($settings as $k => $v) {
233+
$form['settings'][$k] = $v;
234+
}
235+
}
236+
231237
$title = t('Pages');
232238
$description = t("Specify pages by using their paths. Enter one path per line.
233239
The '%' character is a wildcard. Example paths are %blog for the blog page

modules/mongodb_block_ui/mongodb_block_ui.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#blocks tr.region-title td {
32
font-weight: bold;
43
}

modules/mongodb_block_ui/mongodb_block_ui.info

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name = MongoDB Block UI
22
description = Controls the visual building blocks a page is constructed with. Blocks are boxes of content rendered into an area, or region, of a web page.
33
package = MongoDB
4-
version = VERSION
54
core = 7.x
65
dependencies[] = mongodb_block
76
files[] = mongodb_block_ui.module
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/**
4+
* @file
5+
* Contains Drupal\mongodb_block_ui\Tests\BlockAdminThemeTest.
6+
*/
7+
8+
namespace Drupal\mongodb_block_ui\Tests;
9+
10+
11+
/**
12+
* Test the MongoDB block UI with admin themes.
13+
*/
14+
class BlockAdminThemeTest extends \DrupalWebTestCase {
15+
/**
16+
* Name the test
17+
*/
18+
public static function getInfo() {
19+
return array(
20+
'name' => 'Admin theme block admin accessibility',
21+
'description' => "Check whether the block administer page for a disabled theme acccessible if and only if it's the admin theme.",
22+
'group' => 'MongoDB: Block',
23+
);
24+
}
25+
26+
/**
27+
* Check for the accessibility of the admin theme on the block admin page.
28+
*/
29+
function testAdminTheme() {
30+
// Create administrative user.
31+
$adminuser = $this->drupalCreateUser(array('administer blocks', 'administer themes'));
32+
$this->drupalLogin($adminuser);
33+
34+
// Ensure that access to block admin page is denied when theme is disabled.
35+
$this->drupalGet('admin/structure/block/list/stark');
36+
$this->assertResponse(403, t('The block admin page for a disabled theme can not be accessed'));
37+
38+
// Enable admin theme and confirm that tab is accessible.
39+
$edit['admin_theme'] = 'stark';
40+
$this->drupalPost('admin/appearance', $edit, t('Save configuration'));
41+
$this->drupalGet('admin/structure/block/list/stark');
42+
$this->assertResponse(200, t('The block admin page for the admin theme can be accessed'));
43+
}
44+
}

0 commit comments

Comments
 (0)