Ticket #2782: 2782.2.diff
File 2782.2.diff, 7.4 KB (added by , 10 years ago) |
---|
-
Gruntfile.js
239 239 cmd: 'phpunit', 240 240 args: [ '-c', 'phpunit.xml.dist' ] 241 241 }, 242 buddypress: { 243 cmd: 'phpunit', 244 args: [ '-c', 'tests/phpunit/buddypress.xml' ] 245 }, 242 246 multisite: { 243 247 cmd: 'phpunit', 244 248 args: [ '-c', 'tests/phpunit/multisite.xml' ] … … 334 338 grunt.registerTask( 'release', [ 'build' ] ); 335 339 336 340 // PHPUnit test task. 337 grunt.registerMultiTask( 'phpunit', 'Runs PHPUnit tests, including the ajaxand multisite tests.', function() {341 grunt.registerMultiTask( 'phpunit', 'Runs PHPUnit tests, including the BuddyPress and multisite tests.', function() { 338 342 grunt.util.spawn( { 339 343 cmd: this.data.cmd, 340 344 args: this.data.args, -
phpunit.xml.dist
7 7 convertWarningsToExceptions="true" 8 8 > 9 9 <testsuites> 10 <testsuite> 11 <directory suffix=".php">tests/phpunit/testcases/</directory> 12 </testsuite> 13 </testsuites> 10 <testsuite> 11 <directory suffix=".php">tests/phpunit/testcases/</directory> 12 </testsuite> 13 </testsuites> 14 <groups> 15 <exclude> 16 <group>buddypress</group> 17 </exclude> 18 </groups> 14 19 </phpunit> -
src/includes/extend/buddypress/groups.php
143 143 add_filter( 'bbp_current_user_can_access_create_topic_form', array( $this, 'form_permissions' ) ); 144 144 add_filter( 'bbp_current_user_can_access_create_reply_form', array( $this, 'form_permissions' ) ); 145 145 } 146 147 // Enforce forum privacy. 148 add_filter( 'bbp_is_forum_public', array( $this, 'enforce_forum_privacy' ), 10, 3 ); 146 149 } 147 150 148 151 /** … … 1462 1465 1463 1466 return $args; 1464 1467 } 1468 1469 public function enforce_forum_privacy( $is_public, $forum_id, $check_ancestors ) { 1470 $group_ids = bbp_get_forum_group_ids( $forum_id ); 1471 1472 if ( ! empty( $group_ids ) ) { 1473 foreach ( $group_ids as $group_id ) { 1474 $group = groups_get_group( array( 'group_id' => $group_id ) ); 1475 1476 // A single non-public group will force the forum to private. 1477 if ( 'public' !== $group->status ) { 1478 $is_public = false; 1479 break; 1480 } 1481 } 1482 } 1483 1484 return $is_public; 1485 } 1465 1486 } 1466 1487 endif; -
tests/phpunit/bootstrap.php
21 21 * Load bbPress's PHPUnit test suite loader 22 22 */ 23 23 function _load_loader() { 24 25 // Check if we're running the BuddyPress test suite 26 if ( defined( 'BBP_TESTS_BUDDYPRESS' ) ) { 27 28 // If BuddyPress is found, set it up and require it. 29 if ( defined( 'BP_TESTS_DIR' ) ) { 30 require BP_TESTS_DIR . '/includes/loader.php'; 31 } 32 } 33 24 34 require( BBP_TESTS_DIR . '/includes/loader.php' ); 25 35 } 26 36 tests_add_filter( 'muplugins_loaded', '_load_loader' ); … … 30 40 31 41 echo "Loading bbPress testcase...\n"; 32 42 require( BBP_TESTS_DIR . '/includes/testcase.php' ); 43 require( BBP_TESTS_DIR . '/includes/factory.php' ); 44 45 if ( defined( 'BBP_TESTS_BUDDYPRESS' ) ) { 46 echo "Loading BuddyPress testcase...\n"; 47 require BP_TESTS_DIR . '/includes/testcase.php'; 48 } else { 49 echo "Not running BuddyPress tests. To execute these, use --group buddypress\n"; 50 } -
tests/phpunit/buddypress.xml
1 <phpunit 2 bootstrap="bootstrap.php" 3 backupGlobals="false" 4 colors="true" 5 convertErrorsToExceptions="true" 6 convertNoticesToExceptions="true" 7 convertWarningsToExceptions="true" 8 > 9 <php> 10 <const name="BBP_TESTS_BUDDYPRESS" value="1" /> 11 </php> 12 <testsuites> 13 <testsuite> 14 <directory suffix=".php">./testcases/</directory> 15 </testsuite> 16 </testsuites> 17 <groups> 18 <include> 19 <group>buddypress</group> 20 </include> 21 </groups> 22 </phpunit> -
tests/phpunit/includes/define-constants.php
52 52 } else { 53 53 die( "wp-tests-config.php could not be found.\n" ); 54 54 } 55 56 // Determine whether BuddyPress is present. 57 if ( ! defined( 'BP_TESTS_DIR' ) ) { 58 $wp_content_dir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ); 59 if ( file_exists( $wp_content_dir . '/buddypress/tests/phpunit/bootstrap.php' ) ) { 60 define( 'BP_TESTS_DIR', $wp_content_dir . '/buddypress/tests/phpunit' ); 61 } 62 } -
tests/phpunit/includes/factory.php
1 1 <?php 2 2 3 3 class BBP_UnitTest_Factory extends WP_UnitTest_Factory { 4 function __construct() { 4 5 public $forum = null; 6 7 public function __construct() { 5 8 parent::__construct(); 9 10 $this->forum = new BBP_UnitTest_Factory_For_Forum( $this ); 6 11 } 7 12 } 13 14 class BBP_UnitTest_Factory_For_Forum extends WP_UnitTest_Factory_For_Thing { 15 16 public function __construct( $factory = null ) { 17 parent::__construct( $factory ); 18 19 $this->default_generation_definitions = array( 20 'post_title' => new WP_UnitTest_Generator_Sequence( 'Forum %s' ), 21 'post_content' => new WP_UnitTest_Generator_Sequence( 'Content of Forum %s' ), 22 ); 23 } 24 25 public function create_object( $args ) { 26 return bbp_insert_forum( $args ); 27 } 28 29 public function update_object( $forum_id, $fields ) { 30 $fields['forum_id'] = $forum_id; 31 return bbp_update_forum( $fields ); 32 } 33 34 public function get_object_by_id( $forum_id ) { 35 return bbp_get_forum( $forum_id ); 36 } 37 } -
tests/phpunit/includes/loader.php
5 5 6 6 echo "Determining installation type...\n"; 7 7 system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/install.php' ) . ' ' . escapeshellarg( WP_TESTS_CONFIG_PATH ) . ' ' . escapeshellarg( WP_TESTS_DIR ) . ' ' . $multisite ); 8 9 require dirname( __FILE__ ) . '/../../../src/bbpress.php'; -
tests/phpunit/includes/testcase.php
29 29 } 30 30 31 31 $this->factory = new BBP_UnitTest_Factory; 32 33 if ( class_exists( 'BP_UnitTest_Factory' ) ) { 34 $this->bp_factory = new BP_UnitTest_Factory(); 35 } 32 36 } 33 37 34 38 function clean_up_global_scope() { -
tests/phpunit/multisite.xml
14 14 <directory suffix=".php">./testcases/</directory> 15 15 </testsuite> 16 16 </testsuites> 17 <groups> 18 <exclude> 19 <group>buddypress</group> 20 </exclude> 21 </groups> 17 22 </phpunit>