Making WordPress.org

Changeset 11185


Ignore:
Timestamp:
08/18/2021 03:23:40 PM (3 years ago)
Author:
iandunn
Message:

Patterns: Test for single terms until phrase matching is implemented.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/patterns/1.0/tests/test-index.php

    r11184 r11185  
    2525    }
    2626
     27    /**
     28     * Asserts that the results contain the search term.
     29     *
     30     * @param array $patterns
     31     * @param string $search_term
     32     */
    2733    public function assertAllPatternsMatchSearchTerm( $patterns, $search_term ) {
    2834        $all_patterns_include_query = true;
     35        if ( false !== strpos( $search_term, ' ' ) ) {
     36            $this->markTestIncomplete( "This doesn't support phrase-matching quoted terms yet." );
     37        }
    2938
    3039        foreach ( $patterns as $pattern ) {
     
    174183     */
    175184    public function test_search_patterns( $search_term, $locale, $match_expected, $expected_post_ids ) : void {
    176         // wrap term in double quotes to match exact phrase.
    177         $response = send_request( '/patterns/1.0/?&search="' . $search_term . '"&pattern-keywords=11&locale=' . $locale );
     185        $response = send_request( "/patterns/1.0/?search=$search_term&pattern-keywords=11&locale=$locale" );
    178186
    179187        if ( $match_expected ) {
     
    202210            // Should find posts that have the term in the title, but _not_ in the description.
    203211            'match title only' => array(
    204                 'search_term'       => 'side by side',
     212                'search_term'       => 'side',
    205213                'locale'            => 'en_US',
    206214                'match_expected'    => true,
     
    210218            // Should find posts that have the term in the description, but _not_ in the title.
    211219            'match description only' => array(
    212                 'search_term'       => 'quote on top',
     220                'search_term'       => 'quote',
    213221                'locale'            => 'en_US',
    214222                'match_expected'    => true,
     
    270278            // @link https://translate.wordpress.org/projects/patterns/core/
    271279            "untranslated locales should have en_US posts as a fallback" => array(
    272                 'search_term'       => 'offset images', // Post ID 2226.
     280                'search_term'       => 'offset',
    273281                'locale'            => 'la',
    274282                'match_expected'    => true,
Note: See TracChangeset for help on using the changeset viewer.