WordPress.org

Make WordPress Core

Changeset 44510


Ignore:
Timestamp:
01/09/2019 10:30:49 AM (8 months ago)
Author:
pento
Message:

Tests: Improve REST API tests for categories and tags.

Props birgire, SergeyBiryukov.
See #39122.
Fixes #45077.

Location:
trunk/tests/phpunit/tests/rest-api
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-categories-controller.php

    r43571 r44510  
    691691    }
    692692
     693    /**
     694     * @ticket 39122
     695     */
    693696    public function test_get_item_meta() {
    694697        $request  = new WP_REST_Request( 'GET', '/wp/v2/categories/1' );
     
    699702        $meta = (array) $data['meta'];
    700703        $this->assertArrayHasKey( 'test_single', $meta );
    701         $this->assertEquals( $meta['test_single'], '' );
     704        $this->assertSame( $meta['test_single'], '' );
    702705        $this->assertArrayHasKey( 'test_multi', $meta );
    703         $this->assertEquals( $meta['test_multi'], array() );
     706        $this->assertSame( $meta['test_multi'], array() );
    704707        $this->assertArrayHasKey( 'test_cat_single', $meta );
    705         $this->assertEquals( $meta['test_cat_single'], '' );
     708        $this->assertSame( $meta['test_cat_single'], '' );
    706709        $this->assertArrayHasKey( 'test_cat_multi', $meta );
    707         $this->assertEquals( $meta['test_cat_multi'], array() );
    708     }
    709 
     710        $this->assertSame( $meta['test_cat_multi'], array() );
     711    }
     712
     713    /**
     714     * @ticket 39122
     715     */
    710716    public function test_get_item_meta_registered_for_different_taxonomy() {
    711717        $request  = new WP_REST_Request( 'GET', '/wp/v2/categories/1' );
     
    713719        $data     = $response->get_data();
    714720        $this->assertArrayHasKey( 'meta', $data );
    715         $this->assertArrayHasKey( 'meta', $data );
    716721
    717722        $meta = (array) $data['meta'];
    718         $this->assertEquals( false, isset( $meta['test_tag_meta'] ) );
     723        $this->assertFalse( isset( $meta['test_tag_meta'] ) );
    719724    }
    720725
  • trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php

    r43636 r44510  
    630630    }
    631631
     632    /**
     633     * @ticket 39122
     634     */
    632635    public function test_get_item_meta() {
    633636        $id       = $this->factory->tag->create();
     
    639642        $meta = (array) $data['meta'];
    640643        $this->assertArrayHasKey( 'test_single', $meta );
    641         $this->assertEquals( $meta['test_single'], '' );
     644        $this->assertSame( $meta['test_single'], '' );
    642645        $this->assertArrayHasKey( 'test_multi', $meta );
    643         $this->assertEquals( $meta['test_multi'], array() );
     646        $this->assertSame( $meta['test_multi'], array() );
    644647        $this->assertArrayHasKey( 'test_tag_single', $meta );
    645         $this->assertEquals( $meta['test_tag_single'], '' );
     648        $this->assertSame( $meta['test_tag_single'], '' );
    646649        $this->assertArrayHasKey( 'test_tag_multi', $meta );
    647         $this->assertEquals( $meta['test_tag_multi'], array() );
    648     }
    649 
     650        $this->assertSame( $meta['test_tag_multi'], array() );
     651    }
     652
     653    /**
     654     * @ticket 39122
     655     */
    650656    public function test_get_item_meta_registered_for_different_taxonomy() {
    651657        $id       = $this->factory->tag->create();
     
    656662
    657663        $meta = (array) $data['meta'];
    658         $this->assertEquals( false, isset( $meta['test_cat_meta'] ) );
     664        $this->assertFalse( isset( $meta['test_cat_meta'] ) );
    659665    }
    660666
Note: See TracChangeset for help on using the changeset viewer.