Skip to content

Commit

Permalink
Merge pull request #54 from 10up/chore/composer-update-and-lint
Browse files Browse the repository at this point in the history
composer update + lint fix
  • Loading branch information
felipeelia committed Feb 28, 2023
2 parents 4a3fcaa + fb3c02f commit 29c0b9d
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 87 deletions.
45 changes: 23 additions & 22 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ function skip_translations_api() {
require_once $_tests_dir . '/includes/functions.php';
require_once $_tests_dir . '/includes/bootstrap.php';
require_once __DIR__ . '/phpunit/BaseTestCase.php';
require_once __DIR__ . '/phpunit/factory/UserFactory.php';
require_once __DIR__ . '/phpunit/factory/UserFactory.php';
12 changes: 6 additions & 6 deletions tests/phpunit/feature/TestBooleanSearchOperators.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TestBooleanSearchOperators extends \WP_UnitTestCase {
*/
public function set_up() {
$instance = new ElasticPressLabs\Feature\BooleanSearchOperators();
\ElasticPress\Features::factory()->register_feature($instance);
\ElasticPress\Features::factory()->register_feature( $instance );
}

/**
Expand All @@ -44,8 +44,8 @@ protected function get_feature() {
public function testConstruct() {
$instance = $this->get_feature();

$this->assertEquals( 'boolean_search_operators', $instance->slug );
$this->assertEquals( 'Boolean Search Operators', $instance->title );
$this->assertEquals( 'boolean_search_operators', $instance->slug );
$this->assertEquals( 'Boolean Search Operators', $instance->title );
}

/**
Expand All @@ -56,7 +56,7 @@ public function testConstruct() {
public function testBoxSummary() {
ob_start();
$this->get_feature()->output_feature_box_summary();
$output = ob_get_clean();
$output = ob_get_clean();

$this->assertStringContainsString( 'Allow boolean operators in search queries', $output );
}
Expand All @@ -69,7 +69,7 @@ public function testBoxSummary() {
public function testBoxLong() {
ob_start();
$this->get_feature()->output_feature_box_long();
$output = ob_get_clean();
$output = ob_get_clean();

$this->assertStringContainsString( 'Allows users to search using the following boolean operators:', $output );
}
Expand All @@ -80,7 +80,7 @@ public function testBoxLong() {
* @since 1.2.0
*/
public function testQueryUsesBooleanOperators() {
$feature = $this->get_feature();
$feature = $this->get_feature();

$this->assertTrue( $feature->query_uses_boolean_operators( '(museum (art))' ) );
$this->assertTrue( $feature->query_uses_boolean_operators( '"american museum"' ) );
Expand Down
46 changes: 23 additions & 23 deletions tests/phpunit/feature/TestCoAuthorsPlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TestCoAuthorsPlus extends \WP_UnitTestCase {
*/
public function set_up() {
$instance = new ElasticPressLabs\Feature\CoAuthorsPlus();
\ElasticPress\Features::factory()->register_feature($instance);
\ElasticPress\Features::factory()->register_feature( $instance );
}

/**
Expand All @@ -40,13 +40,13 @@ protected function get_feature() {
* Get protected function as public
*
* @since 1.1.0
* @param string $functionName
* @param string $className
* @param string $function_name Function name
* @param string $class_name Class name
* @return ReflectionClass
*/
protected function get_protected_function( $functionName, $className = 'ElasticPressLabs\Feature\CoAuthorsPlus' ) {
$reflector = new \ReflectionClass( $className );
$function = $reflector->getMethod( $functionName );
protected function get_protected_function( $function_name, $class_name = 'ElasticPressLabs\Feature\CoAuthorsPlus' ) {
$reflector = new \ReflectionClass( $class_name );
$function = $reflector->getMethod( $function_name );
$function->setAccessible( true );

return $function;
Expand All @@ -60,8 +60,8 @@ protected function get_protected_function( $functionName, $className = 'ElasticP
public function testConstruct() {
$instance = $this->get_feature();

$this->assertEquals( 'co_authors_plus', $instance->slug );
$this->assertEquals( 'Co-Authors Plus', $instance->title );
$this->assertEquals( 'co_authors_plus', $instance->slug );
$this->assertEquals( 'Co-Authors Plus', $instance->title );
}

/**
Expand All @@ -72,7 +72,7 @@ public function testConstruct() {
public function testBoxSummary() {
ob_start();
$this->get_feature()->output_feature_box_summary();
$output = ob_get_clean();
$output = ob_get_clean();

$this->assertStringContainsString( 'Add support for the Co-Authors Plus plugin in the Admin Post List screen by Author name', $output );
}
Expand All @@ -85,7 +85,7 @@ public function testBoxSummary() {
public function testBoxLong() {
ob_start();
$this->get_feature()->output_feature_box_long();
$output = ob_get_clean();
$output = ob_get_clean();

$this->assertStringContainsString( 'If using the Co-Authors Plus plugin and the Protected Content feature, enable this feature to visit the Admin Post List screen by Author name <code>wp-admin/edit.php?author_name=&lt;name&gt;</code> and see correct results.', $output );
}
Expand All @@ -96,25 +96,25 @@ public function testBoxLong() {
* @since 1.1.0
*/
public function testFilterOutAuthorNameAndId() {
$feature = $this->get_feature();
$feature = $this->get_feature();
$function_filter_out_author_name_and_id_from_es_filter = $this->get_protected_function( 'filter_out_author_name_and_id_from_es_filter' );

$this->assertEquals([], $function_filter_out_author_name_and_id_from_es_filter->invokeArgs( $feature, array([])));
$this->assertEquals( [], $function_filter_out_author_name_and_id_from_es_filter->invokeArgs( $feature, array( [] ) ) );

$this->assertEquals('', $function_filter_out_author_name_and_id_from_es_filter->invokeArgs( $feature, array( '' ) ) );
$this->assertEquals( '', $function_filter_out_author_name_and_id_from_es_filter->invokeArgs( $feature, array( '' ) ) );

$formatted_args = [
'post_filter' => [
'bool' => [
'must' => [
[
'term' => [
'post_author.display_name' => [ 'test' ]
]
]
]
]
]
'post_author.display_name' => [ 'test' ],
],
],
],
],
],
];

$filtered_formatted_args = $function_filter_out_author_name_and_id_from_es_filter->invokeArgs( $feature, [ $formatted_args ] );
Expand All @@ -123,8 +123,8 @@ public function testFilterOutAuthorNameAndId() {

$formatted_args['post_filter']['bool']['must'][] = [
'terms' => [
'post_type.raw' => [ 'post' ]
]
'post_type.raw' => [ 'post' ],
],
];

$filtered_formatted_args = $function_filter_out_author_name_and_id_from_es_filter->invokeArgs( $feature, [ $formatted_args ] );
Expand All @@ -135,8 +135,8 @@ public function testFilterOutAuthorNameAndId() {

$formatted_args['post_filter']['bool']['must'][] = [
'term' => [
'post_author.id' => [ 1 ]
]
'post_author.id' => [ 1 ],
],
];

$filtered_formatted_args = $function_filter_out_author_name_and_id_from_es_filter->invokeArgs( $feature, [ $formatted_args ] );
Expand Down
Loading

0 comments on commit 29c0b9d

Please sign in to comment.