Skip to content

Commit

Permalink
phpcbf
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccahum committed May 9, 2024
1 parent 5c91c11 commit 37a23f8
Show file tree
Hide file tree
Showing 18 changed files with 1,495 additions and 1,024 deletions.
2 changes: 1 addition & 1 deletion includes/mappings/post/5-0.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
* @param {array<string>} $filters Default filters
* @return {array<string>} New filters
*/
'filter' => apply_filters( 'ep_default_analyzer_filters', array( 'standard', 'ewp_word_delimiter', 'lowercase', 'stop', 'ewp_snowball' ) ),
'filter' => apply_filters( 'ep_default_analyzer_filters', array( 'standard', 'ewp_word_delimiter', 'lowercase', 'stop', 'ewp_snowball' ) ),
/**
* Filter Elasticsearch default language in mapping
*
Expand Down
2 changes: 1 addition & 1 deletion includes/mappings/post/pre-5-0.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* @param {array<string>} $filters Default filters
* @return {array<string>} New filters
*/
'filter' => apply_filters( 'ep_default_analyzer_filters', array( 'standard', 'ewp_word_delimiter', 'lowercase', 'stop', 'ewp_snowball' ) ),
'filter' => apply_filters( 'ep_default_analyzer_filters', array( 'standard', 'ewp_word_delimiter', 'lowercase', 'stop', 'ewp_snowball' ) ),
/**
* Filter Elasticsearch default language in mapping
*
Expand Down
2 changes: 1 addition & 1 deletion includes/partials/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
exit; // Exit if accessed directly.
}

$base_url = admin_url( 'admin.php?page=' ); // VIP: The network menu is disabled, go to the site menu.
$base_url = admin_url( 'admin.php?page=' ); // VIP: The network menu is disabled, go to the site menu.
$is_sync_page = 'sync' === Screen::factory()->get_current_screen();
?>

Expand Down
4 changes: 2 additions & 2 deletions tests/php/TestElasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testGetClusterStatus() {
*/
public function testGetDocuments() {

$post_ids = array();
$post_ids = array();
$post_ids[] = $this->ep_factory->post->create();
$post_ids[] = $this->ep_factory->post->create();

Expand Down Expand Up @@ -90,7 +90,7 @@ public function testGetDocuments() {
$this->assertIsArray( $documents );
$this->assertEmpty( $documents );

$documents = ElasticPress\Elasticsearch::factory()->get_documents( $index_name, 'post', [] );
$documents = ElasticPress\Elasticsearch::factory()->get_documents( $index_name, 'post', [] );

$this->assertIsArray( $documents );
$this->assertEmpty( $documents );
Expand Down
4 changes: 2 additions & 2 deletions tests/php/TestUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function testSanitizeCredentials() {
$creds = \ElasticPress\Utils\sanitize_credentials(
[
'username' => '<strong>hello</strong> world',
'token' => 'able <script>alert("baker");</script>',
'token' => 'able <script>alert("baker");</script>',
]
);

Expand All @@ -152,7 +152,7 @@ public function testSanitizeCredentials() {
$creds = \ElasticPress\Utils\sanitize_credentials(
[
'username' => 'my-user-name',
'token' => 'my-token',
'token' => 'my-token',
]
);

Expand Down
60 changes: 34 additions & 26 deletions tests/php/features/TestComments.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function tear_down() {
// make sure no one attached to this
remove_filter( 'ep_sync_terms_allow_hierarchy', array( $this, 'ep_allow_multiple_level_terms_sync' ), 100 );
$this->fired_actions = array();
}
}

/**
* Get Comment feature
Expand All @@ -75,37 +75,37 @@ protected function get_feature() {
* @since 3.6.0
* @group comments
*/
public function testConstruct() {
$instance = new ElasticPress\Feature\Comments\Comments();
public function testConstruct() {
$instance = new ElasticPress\Feature\Comments\Comments();

$this->assertEquals( 'comments', $instance->slug );
$this->assertEquals( 'Comments', $instance->title );
}
$this->assertEquals( 'comments', $instance->slug );
$this->assertEquals( 'Comments', $instance->title );
}

/**
* Test Comment Feature box summary
*
* @since 3.6.0
* @group comments
*/
public function testBoxSummary() {
public function testBoxSummary() {
ob_start();
$this->get_feature()->output_feature_box_summary();
$output = ob_get_clean();
$output = ob_get_clean();

$this->assertStringContainsString( 'Improve comment search relevancy and query performance.', $output );
}
}

/**
* Test Comment Feature box long text
*
* @since 3.6.0
* @group comments
*/
public function testBoxLong() {
public function testBoxLong() {
ob_start();
$this->get_feature()->output_feature_box_long();
$output = ob_get_clean();
$output = ob_get_clean();

$this->assertStringContainsString( 'This feature will empower your website to overcome traditional WordPress comment search and query limitations that can present themselves at scale.', $output );
}
Expand All @@ -120,27 +120,35 @@ public function testIntegrateSearchQueries() {
$this->assertTrue( $this->get_feature()->integrate_search_queries( true, null ) );
$this->assertFalse( $this->get_feature()->integrate_search_queries( false, null ) );

$query = new WP_Comment_Query( [
'ep_integrate' => false
] );
$query = new WP_Comment_Query(
[
'ep_integrate' => false,
]
);

$this->assertFalse( $this->get_feature()->integrate_search_queries( true, $query ) );

$query = new WP_Comment_Query( [
'ep_integrate' => 0
] );
$query = new WP_Comment_Query(
[
'ep_integrate' => 0,
]
);

$this->assertFalse( $this->get_feature()->integrate_search_queries( true, $query ) );

$query = new WP_Comment_Query( [
'ep_integrate' => 'false'
] );
$query = new WP_Comment_Query(
[
'ep_integrate' => 'false',
]
);

$this->assertFalse( $this->get_feature()->integrate_search_queries( true, $query ) );

$query = new WP_Comment_Query( [
'search' => 'blog'
] );
$query = new WP_Comment_Query(
[
'search' => 'blog',
]
);

$this->assertTrue( $this->get_feature()->integrate_search_queries( false, $query ) );
}
Expand All @@ -151,9 +159,9 @@ public function testIntegrateSearchQueries() {
* @since 3.6.0
* @group comments
*/
public function testRequirementsStatus() {
$status = $this->get_feature()->requirements_status();
public function testRequirementsStatus() {
$status = $this->get_feature()->requirements_status();

$this->assertEquals( 1, $status->code );
}
}
}
33 changes: 23 additions & 10 deletions tests/php/features/TestFacet.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ public function testGetSelected() {

parse_str( 'ep_filter_taxonomy=dolor,sit', $_GET );
$selected = $facet_feature->get_selected();
$this->assertSelectedTax( [ 'dolor' => true, 'sit' => true ], 'taxonomy', $selected );
$this->assertSelectedTax(
[
'dolor' => true,
'sit' => true,
],
'taxonomy',
$selected
);

parse_str( 'ep_filter_taxonomy=dolor,sit&ep_filter_othertax=amet', $_GET );
$selected = $facet_feature->get_selected();
Expand All @@ -38,7 +45,13 @@ public function testGetSelected() {
$this->assertCount( 2, $selected['taxonomies'] );
$this->assertArrayHasKey( 'taxonomy', $selected['taxonomies'] );
$this->assertArrayHasKey( 'othertax', $selected['taxonomies'] );
$this->assertSame( [ 'dolor' => true, 'sit' => true ], $selected['taxonomies']['taxonomy']['terms'] );
$this->assertSame(
[
'dolor' => true,
'sit' => true,
],
$selected['taxonomies']['taxonomy']['terms']
);
$this->assertSame( [ 'amet' => true ], $selected['taxonomies']['othertax']['terms'] );

parse_str( 's=searchterm&ep_filter_taxonomy=dolor', $_GET );
Expand Down Expand Up @@ -67,10 +80,10 @@ public function testBuildQueryUrl() {
'taxonomies' => [
'category' => [
'terms' => [
'augue' => 1
]
]
]
'augue' => 1,
],
],
],
];

$this->assertEquals( '/?ep_filter_category=augue', $facet_feature->build_query_url( $filters ) );
Expand All @@ -84,10 +97,10 @@ public function testBuildQueryUrl() {
'category' => [
'terms' => [
'augue' => 1,
'consectetur' => 1
]
]
]
'consectetur' => 1,
],
],
],
];

$this->assertEquals( '/?ep_filter_category=augue%2Cconsectetur', $facet_feature->build_query_url( $filters ) );
Expand Down
12 changes: 7 additions & 5 deletions tests/php/features/TestProtectedContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ public function testAdminCategories() {
ElasticPress\Features::factory()->activate_feature( 'protected_content' );
ElasticPress\Features::factory()->setup_features();

$cat1 = $this->factory->category->create( array ( 'name' => 'category one' ) );
$cat2 = $this->factory->category->create( array ( 'name' => 'category two' ) );
$cat1 = $this->factory->category->create( array( 'name' => 'category one' ) );
$cat2 = $this->factory->category->create( array( 'name' => 'category two' ) );

$this->ep_factory->post->create( array( 'post_category' => array( $cat1 ) ) );
$this->ep_factory->post->create( array( 'post_category' => array( $cat2 ) ) );
Expand Down Expand Up @@ -275,7 +275,8 @@ public function testSyncPasswordedPost() {
array(
'ID' => $post_id,
'post_password' => '',
) );
)
);

ElasticPress\Indexables::factory()->get( 'post' )->index( $post_id, true );
ElasticPress\Elasticsearch::factory()->refresh_indices();
Expand All @@ -290,7 +291,8 @@ public function testSyncPasswordedPost() {
array(
'ID' => $post_id,
'post_password' => 'test',
) );
)
);

ElasticPress\Indexables::factory()->get( 'post' )->index( $post_id, true );
ElasticPress\Elasticsearch::factory()->refresh_indices();
Expand Down Expand Up @@ -318,7 +320,7 @@ public function testAdminPasswordedPost() {
array(
'post_title' => 'findmetitle 123',
'post_content' => 'findmecontent 123',
'post_password' => 'test'
'post_password' => 'test',
)
);

Expand Down
5 changes: 3 additions & 2 deletions tests/php/features/TestRelatedPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ public function testGetRelatedQuery() {
$post_id = $this->ep_factory->post->create( array( 'post_content' => 'findme test 1' ) );

$related_post_title = 'related post test';
$this->ep_factory->post->create( array(
$this->ep_factory->post->create(
array(
'post_title' => $related_post_title,
'post_content' => 'findme test 2'
'post_content' => 'findme test 2',
)
);

Expand Down
12 changes: 6 additions & 6 deletions tests/php/features/TestSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function testAllowedTags() {
ElasticPress\Features::factory()->get_registered_feature( 'search' )->search_setup();

// a tag that is in the array of allowed tags
$allowed_tag = 'span';
$allowed_tag = 'span';
$search_feature = ElasticPress\Features::factory()->get_registered_feature( 'search' );

$this->assertTrue( 'span' === $search_feature->get_highlighting_tag( $allowed_tag ) );
Expand All @@ -273,7 +273,7 @@ public function testNotAllowedTags() {

// a tag that is not in the array of allowed tags
$not_allowed_tag = 'div';
$search_feature = ElasticPress\Features::factory()->get_registered_feature( 'search' );
$search_feature = ElasticPress\Features::factory()->get_registered_feature( 'search' );

$this->assertTrue( 'mark' === $search_feature->get_highlighting_tag( $not_allowed_tag ) );
}
Expand All @@ -294,9 +294,9 @@ public function testHighlightSetting() {
ElasticPress\Features::factory()->update_feature(
'search',
array(
'active' => true,
'active' => true,
'highlight_enabled' => true,
'highlight_tag' => 'span',
'highlight_tag' => 'span',
)
);

Expand Down Expand Up @@ -326,7 +326,7 @@ public function testBadTagSetting() {
array(
'active' => true,
'highlight_enabled' => true,
'highlight_tag' => 'div'
'highlight_tag' => 'div',
)
);

Expand Down Expand Up @@ -354,7 +354,7 @@ public function testExcerptSetting() {
array(
'active' => true,
'highlight_enabled' => true,
'highlight_excerpt' => true
'highlight_excerpt' => true,
)
);

Expand Down
Loading

0 comments on commit 37a23f8

Please sign in to comment.