Commit e477daff authored by amitaibu's avatar amitaibu Committed by GitHub

Merge pull request #255 from AronNovak/133-travis-7.x

.travis.yml fix for 7.x
parents 9f54414f dddfd864
language: php
php:
- 5.3
- 5.6
- 7.0
mysql:
database: drupal
......@@ -9,30 +10,42 @@ mysql:
encoding: utf8
before_script:
# navigate out of module directory to prevent blown stack by recursive module lookup
# Navigate out of module directory to prevent blown stack by recursive module lookup
- cd ../..
# install drush
- pear channel-discover pear.drush.org
- pear install drush/drush-5.8.0
- phpenv rehash
# Install Drush
- composer global require drush/drush
- export PATH=$PATH:~/.composer/vendor/bin
# install php packages required for running a web server from drush on php 5.3
# Install php packages required for running Drupal
- sudo apt-get update > /dev/null
- sudo apt-get install -y --force-yes php5-cgi php5-mysql
- sudo apt-get install -y --force-yes php5-mysql
# create new site, stubbing sendmail path with true to prevent delivery errors and manually resolving drush path
- mysql -e 'create database drupal'
- php -d sendmail_path=`which true` `pear config-get php_dir`/drush/drush.php --yes core-quick-drupal --profile=testing --no-server --db-url=mysql://root:@127.0.0.1/drupal --enable=simpletest og
# Try to avoid MySQL has gone away errors
- mysql -e "SET GLOBAL wait_timeout = 36000;"
- mysql -e "SET GLOBAL max_allowed_packet = 134209536;"
- mysql -e "SHOW VARIABLES LIKE 'max_allowed_packet';"
- mysql -e "SHOW VARIABLES LIKE 'wait_timeout';"
# reference and enable module in build site
- ln -s $(readlink -e $(cd -)) og/drupal/sites/all/modules/og
- cd og/drupal
# enable OG-UI, so drush will auto-download all dependencies
# Create new site, stubbing sendmail path with true to prevent delivery errors
- mysql -e 'CREATE DATABASE drupal'
- export PHP_OPTIONS="-d sendmail_path=`which true`"
- drush --yes core-quick-drupal --core=drupal-7.x --profile=testing --no-server --db-url=mysql://root:@127.0.0.1/drupal --enable=simpletest og
- export DRUPAL_ROOT=og/drupal-7.x
# Reference and enable module in build site
- ln -s $(readlink -e $(cd -)) $DRUPAL_ROOT/sites/all/modules/og
- cd $DRUPAL_ROOT
# Enable OG-UI, so drush will auto-download all dependencies
- drush --yes pm-enable og_ui
# start a web server on port 8080, run in the background; wait for initialization
# Create webserver for the Simpletest
# Mandatory despite the fact that the tests can be
# executed from CLI!
- drush runserver 127.0.0.1:8080 &
- until netstat -an 2>/dev/null | grep '8080.*LISTEN'; do true; done
script: drush test-run "Organic groups","Organic groups access","Organic groups context","Organic groups field access","Organic groups UI" --uri=http://127.0.0.1:8080
script:
- 'php scripts/run-tests.sh --url http://127.0.0.1:8080 --php $(phpenv which php) --concurrency 2 --verbose --color "Organic groups","Organic groups access","Organic groups context","Organic groups field access","Organic groups UI" 2>&1 | tee /tmp/simpletest-result.txt'
- '! egrep -i "([1-9]+ fail)|(Fatal error)|([1-9]+ exception)" /tmp/simpletest-result.txt'
......@@ -409,13 +409,13 @@ class OgAccessUseGroupDefaultsTestCase extends DrupalWebTestCase {
}
/**
* Tests group memberships that require approval.
* Tests moderated group memberships.
*/
class OgAccessModeratedGroupApproval extends DrupalWebTestCase {
class OgAccessModeratedGroup extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'OG group membership approval',
'name' => 'OG moderated group membership',
'description' => 'Test groups that require membership approval.',
'group' => 'Organic groups access',
);
......@@ -448,17 +448,22 @@ class OgAccessModeratedGroupApproval extends DrupalWebTestCase {
}
/**
* Test that membership requests made via direct API calls result in proper
* pending status for private groups that require approval.
* Test membership creation attempt made via direct API calls, by non-admins.
*/
public function testMemberShipRequestStatus() {
public function testMembershipRequest() {
// The call of drupalLogin() in setUp() is not effective for API calls,
// switching users here to test the permission check.
global $user;
$current_user = $user;
$user = $this->user;
// Save user as a member of the group, without passing state.
$this->user->og_user_node[LANGUAGE_NONE][0]['target_id'] = $this->group->nid;
user_save($this->user);
$user = $current_user;
// User's membership should be pending.
// User's membership should not exist.
$membership = og_get_membership('node', $this->group->nid, 'user', $this->user->uid);
$this->assertEqual($membership->state, OG_STATE_PENDING, t('User membership is pending.'));
$this->assertFalse(is_object($membership), t('Non-admins cannot add members to private groups.'));
}
/**
......
......@@ -1117,13 +1117,17 @@ function og_ui_get_group_admin($entity_type, $etid) {
}
// ensure we are invoking this on something worth doing it on
$entity = entity_load_single($entity_type, $etid);
if (!$entity) {
// It is a non-existing group Id, giving up.
return FALSE;
}
$entity_info = entity_get_info($entity_type);
// if this isn't a group type, skip invoking admin modules
if (empty($entity_info['entity keys']['bundle']) || !og_is_group_type($entity_type, $entity->{$entity_info['entity keys']['bundle']})) {
$cache["$entity_type:$etid"] = FALSE;
return FALSE;
}
$data = module_invoke_all('og_ui_get_group_admin', $entity_type, $etid);
......
......@@ -429,9 +429,18 @@ class OgUiManagePeopleTestCase extends DrupalWebTestCase {
public function testOgUiPath() {
$this->drupalGet('entity_test/' . $this->entity->pid . 'invalid/group');
$this->assertResponse(403);
// Numeric values that are not integers are forbidden, too.
$this->drupalGet('entity_test/' . $this->entity->pid . '.333/group');
// Numeric values that are not consist of decimal characters are forbidden.
// 0x1 for instance is equivalent to 1
// http://php.net/manual/en/language.types.integer.php
$this->drupalGet('entity_test/0x' . $this->entity->pid . '/group');
$this->assertResponse(403);
// Non-existing groups return 404 however.
$this->drupalGet('entity_test/666');
$this->assertResponse(404);
// For the same, admin area returns 403.
$this->drupalGet('entity_test/666/group');
$this->assertResponse(403);
}
}
......
......@@ -122,11 +122,7 @@ class OgBehaviorHandler extends EntityReference_BehaviorHandler_Abstract {
foreach ($items as $item) {
$gid = $item['target_id'];
// Must provide correct state in the event that approval is required.
if (empty($item['state']) && $entity_type == 'user' && !og_user_access($group_type, $gid, 'subscribe without approval', $entity) && !og_user_access($group_type, $gid, 'administer group')) {
$item['state'] = OG_STATE_PENDING;
}
elseif (empty($item['state']) || !in_array($gid, $diff['insert'])) {
if (empty($item['state']) || !in_array($gid, $diff['insert'])) {
// State isn't provided, or not an "insert" operation.
continue;
}
......
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