Making WordPress.org

Changeset 11186


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

Patterns: Use explicit pass/fail for clarity.

File:
1 edited

Legend:

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

    r11185 r11186  
    1818
    1919        $patterns = json_decode( $response->body );
     20        $this->assertIsArray( $patterns );
    2021        $this->assertGreaterThan( 0, count( $patterns ) );
    2122        $this->assertIsString( $patterns[0]->title->rendered );
     
    3233     */
    3334    public function assertAllPatternsMatchSearchTerm( $patterns, $search_term ) {
    34         $all_patterns_include_query = true;
    3535        if ( false !== strpos( $search_term, ' ' ) ) {
    3636            $this->markTestIncomplete( "This doesn't support phrase-matching quoted terms yet." );
     
    4242
    4343            if ( false === $match_in_title && false === $match_in_description ) {
    44                 $all_patterns_include_query = false;
    45                 break;
     44                $this->fail( "`$search_term` not found in `{$pattern->title->rendered}` pattern (ID {$pattern->id})" );
    4645            }
    4746        }
    4847
    49         $this->assertTrue( $all_patterns_include_query );
     48        $this->pass();
     49    }
     50
     51    /**
     52     * PHPUnit provides `fail()`, but no equivalent for success. This makes calling code more obvious and self-documenting.
     53     */
     54    public function pass() {
     55        $this->assertTrue( true );
    5056    }
    5157
Note: See TracChangeset for help on using the changeset viewer.