-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2991 from 10up/burhan/fix-1781
Add Support for site__in and site__not_in parameters
- Loading branch information
Showing
12 changed files
with
1,173 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,61 @@ on: | |
- '[0-9].[0-9x]*' # Version branches: 4.x.x, 4.1.x, 5.x | ||
|
||
jobs: | ||
phpunit: | ||
name: PHP Unit | ||
phpunit_single_site: | ||
name: PHP Unit (Single Site) | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Start MySQL | ||
run: sudo systemctl start mysql.service | ||
|
||
- name: Configure sysctl limits | ||
run: | | ||
sudo swapoff -a | ||
sudo sysctl -w vm.swappiness=1 | ||
sudo sysctl -w fs.file-max=262144 | ||
sudo sysctl -w vm.max_map_count=262144 | ||
- name: Setup Elasticsearch | ||
uses: getong/[email protected] | ||
with: | ||
elasticsearch version: '7.5.0' | ||
|
||
- name: Set standard 10up cache directories | ||
run: | | ||
composer config -g cache-dir "${{ env.COMPOSER_CACHE }}" | ||
- name: Prepare composer cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ env.COMPOSER_CACHE }} | ||
key: composer-${{ env.COMPOSER_VERSION }}-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
composer-${{ env.COMPOSER_VERSION }}- | ||
- name: Set PHP version | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '7.4' | ||
coverage: none | ||
|
||
- name: Install dependencies | ||
run: composer install | ||
|
||
- name: Setup WP Tests | ||
run: | | ||
bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 | ||
sleep 10 | ||
- name: PHPUnit | ||
run: | | ||
composer run-script test-single-site | ||
phpunit_multisite: | ||
name: PHP Unit (Multisite) | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
@@ -69,4 +122,3 @@ jobs: | |
- name: PHPUnit | ||
run: | | ||
composer run-script test | ||
composer run-script test-single-site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Class for category factory. | ||
*/ | ||
|
||
namespace ElasticPressTest; | ||
|
||
use ElasticPress; | ||
|
||
/** | ||
* Unit test factory for the category. | ||
* | ||
* @since 4.4.0 | ||
*/ | ||
class CategoryFactory extends \WP_UnitTest_Factory_For_Term { | ||
|
||
/** | ||
* Inserts a comment and "sync" it to Elasticsearch | ||
* | ||
* @param array $args The category details. | ||
* | ||
* @return int|false The category's ID on success, false on failure. | ||
*/ | ||
public function create_object( $args ) { | ||
|
||
$args['taxonomy'] = 'category'; | ||
$id = parent::create_object( $args ); | ||
|
||
ElasticPress\Indexables::factory()->get( 'term' )->index( $id, true ); | ||
|
||
return $id; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Class for comment factory. | ||
*/ | ||
|
||
namespace ElasticPressTest; | ||
|
||
use ElasticPress; | ||
|
||
/** | ||
* Unit test factory for the comment. | ||
* | ||
* @since 4.4.0 | ||
*/ | ||
class CommentFactory extends \WP_UnitTest_Factory_For_Comment { | ||
|
||
/** | ||
* Inserts a comment. | ||
* | ||
* @param array $args The comment details. | ||
* | ||
* @return int|false The comment's ID on success, false on failure. | ||
*/ | ||
public function create_object( $args ) { | ||
$id = wp_insert_comment( $this->addslashes_deep( $args ) ); | ||
|
||
ElasticPress\Indexables::factory()->get( 'comment' )->index( $id ); | ||
|
||
return $id; | ||
} | ||
|
||
} |
Oops, something went wrong.