Code Duplication    Length = 11-14 lines in 2 locations

tests/phpunit/tests/rest-api/rest-tags-controller.php 1 location

@@ 658-671 (lines=14) @@
655
    /**
656
     * @ticket 38505
657
     */
658
    public function test_update_item_with_edit_term_cap_granted() 
659
    {
660
        wp_set_current_user(self::$subscriber);
661
        $term = $this->factory->tag->create_and_get();
662
        $request = new WP_REST_Request('POST', '/wp/v2/tags/' . $term->term_id);
663
        $request->set_param('name', 'New Name');
664
665
        add_filter('map_meta_cap', array( $this, 'grant_edit_term' ), 10, 2);
666
        $response = $this->server->dispatch($request);
667
        remove_filter('user_has_cap', array( $this, 'grant_edit_term' ), 10, 2);
668
669
        $this->assertEquals(200, $response->get_status());
670
        $data = $response->get_data();
671
        $this->assertEquals('New Name', $data['name']);
672
    }
673
674
    public function grant_edit_term( $caps, $cap ) 

tests/phpunit/tests/rest-api/rest-users-controller.php 1 location

@@ 544-554 (lines=11) @@
541
        $this->assertEquals($adam_id, $data[0]['id']);
542
    }
543
544
    public function test_get_items_slug_query() 
545
    {
546
        wp_set_current_user(self::$user);
547
        $this->factory->user->create(array( 'display_name' => 'foo', 'user_login' => 'bar' ));
548
        $id2 = $this->factory->user->create(array( 'display_name' => 'Moo', 'user_login' => 'foo' ));
549
        $request = new WP_REST_Request('GET', '/wp/v2/users');
550
        $request->set_param('slug', 'foo');
551
        $response = $this->server->dispatch($request);
552
        $data = $response->get_data();
553
        $this->assertEquals(1, count($data));
554
        $this->assertEquals($id2, $data[0]['id']);
555
    }
556
557
    // Note: Do not test using editor role as there is an editor role created in testing and it makes it hard to test this functionality.