Make WordPress Core

Changeset 58235


Ignore:
Timestamp:
05/29/2024 12:20:56 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use more specific assertions in a few tests.

Follow-up to [121/tests], [915/tests], [34903], [36307], [43548], [44154], [52286], [57337].

See #60705.

Location:
trunk/tests/phpunit/tests
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/block-template-utils.php

    r57919 r58235  
    380380                $filename = wp_generate_block_templates_export_file();
    381381                $this->assertFileExists( $filename, 'zip file is created at the specified path' );
    382                 $this->assertTrue( filesize( $filename ) > 0, 'zip file is larger than 0 bytes' );
     382                $this->assertGreaterThan( 0, filesize( $filename ), 'zip file is larger than 0 bytes' );
    383383
    384384                // Open ZIP file and make sure the directories exist.
  • trunk/tests/phpunit/tests/formatting/utf8UriEncode.php

    r56536 r58235  
    2323        public function test_output_is_not_longer_than_optional_length_argument( $utf8, $unused_for_this_test ) {
    2424                $max_length = 30;
    25                 $this->assertTrue( strlen( utf8_uri_encode( $utf8, $max_length ) ) <= $max_length );
     25                $this->assertLessThanOrEqual( $max_length, strlen( utf8_uri_encode( $utf8, $max_length ) ) );
    2626        }
    2727
  • trunk/tests/phpunit/tests/l10n/wpTranslationsConvert.php

    r57513 r58235  
    502502                $this->assertNull( $destination->error() );
    503503
    504                 $this->assertTrue( filesize( $destination_file ) > 0 );
     504                $this->assertGreaterThan( 0, filesize( $destination_file ) );
    505505
    506506                $destination_read = WP_Translation_File::create( $destination_file, $destination_format );
  • trunk/tests/phpunit/tests/multisite/site.php

    r58097 r58235  
    12141214                                        $this->assertEquals( $expected_data[ $key ], $value );
    12151215                                } elseif ( 'last_updated' === $key ) {
    1216                                         $this->assertTrue( $old_site->last_updated <= $value );
     1216                                        $this->assertLessThanOrEqual( $value, $old_site->last_updated );
    12171217                                } else {
    12181218                                        $this->assertSame( $old_site->$key, $value );
  • trunk/tests/phpunit/tests/oembed/controller.php

    r58044 r58235  
    343343                $this->assertSame( $post->post_title, $data['title'] );
    344344                $this->assertSame( 'rich', $data['type'] );
    345                 $this->assertTrue( $data['width'] <= $request['maxwidth'] );
     345                $this->assertLessThanOrEqual( $request['maxwidth'], $data['width'] );
    346346        }
    347347
    … …  
    386386                $this->assertSame( $post->post_title, $data['title'] );
    387387                $this->assertSame( 'rich', $data['type'] );
    388                 $this->assertTrue( $data['width'] <= $request['maxwidth'] );
     388                $this->assertLessThanOrEqual( $request['maxwidth'], $data['width'] );
    389389
    390390                update_option( 'show_on_front', 'posts' );
    … …  
    431431                $this->assertSame( $post->post_title, $data['title'] );
    432432                $this->assertSame( 'rich', $data['type'] );
    433                 $this->assertTrue( $data['width'] <= $request['maxwidth'] );
     433                $this->assertLessThanOrEqual( $request['maxwidth'], $data['width'] );
    434434        }
    435435
    … …  
    717717                $this->assertSame( $post->post_title, $data['title'] );
    718718                $this->assertSame( 'rich', $data['type'] );
    719                 $this->assertTrue( $data['width'] <= $request['maxwidth'] );
     719                $this->assertLessThanOrEqual( $request['maxwidth'], $data['width'] );
    720720        }
    721721
    … …  
    766766                $this->assertSame( $post->post_title, $data['title'] );
    767767                $this->assertSame( 'rich', $data['type'] );
    768                 $this->assertTrue( $data['width'] <= $request['maxwidth'] );
     768                $this->assertLessThanOrEqual( $request['maxwidth'], $data['width'] );
    769769
    770770                update_option( 'show_on_front', 'posts' );
  • trunk/tests/phpunit/tests/oembed/getResponseData.php

    r52132 r58235  
    249249                $this->assertArrayHasKey( 'thumbnail_width', $data );
    250250                $this->assertArrayHasKey( 'thumbnail_height', $data );
    251                 $this->assertTrue( 400 >= $data['thumbnail_width'] );
     251                $this->assertLessThanOrEqual( 400, $data['thumbnail_width'] );
    252252        }
    253253
    … …  
    268268                $this->assertArrayHasKey( 'thumbnail_width', $data );
    269269                $this->assertArrayHasKey( 'thumbnail_height', $data );
    270                 $this->assertTrue( 400 >= $data['thumbnail_width'] );
     270                $this->assertLessThanOrEqual( 400, $data['thumbnail_width'] );
    271271        }
    272272}
Note: See TracChangeset for help on using the changeset viewer.