- Timestamp:
- 09/02/2020 12:35:36 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-plugins-controller.php
r48627 r48937 108 108 $response = rest_get_server()->dispatch( $request ); 109 109 $data = $response->get_data(); 110 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );111 $this->assert Equals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );110 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 111 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 112 112 // Single. 113 113 $request = new WP_REST_Request( 'OPTIONS', self::BASE . '/' . self::PLUGIN ); 114 114 $response = rest_get_server()->dispatch( $request ); 115 115 $data = $response->get_data(); 116 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );117 $this->assert Equals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );116 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 117 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 118 118 } 119 119 … … 126 126 127 127 $response = rest_do_request( self::BASE ); 128 $this->assert Equals( 200, $response->get_status() );128 $this->assertSame( 200, $response->get_status() ); 129 129 130 130 $items = wp_list_filter( $response->get_data(), array( 'plugin' => self::PLUGIN ) ); … … 210 210 public function test_get_items_logged_out() { 211 211 $response = rest_do_request( self::BASE ); 212 $this->assert Equals( 401, $response->get_status() );212 $this->assertSame( 401, $response->get_status() ); 213 213 } 214 214 … … 246 246 247 247 $response = rest_do_request( self::BASE ); 248 $this->assert Equals( 200, $response->get_status() );248 $this->assertSame( 200, $response->get_status() ); 249 249 } 250 250 … … 259 259 260 260 $response = rest_do_request( self::BASE ); 261 $this->assert Equals( 200, $response->get_status() );261 $this->assertSame( 200, $response->get_status() ); 262 262 263 263 $items = wp_list_filter( $response->get_data(), array( 'plugin' => self::PLUGIN ) ); … … 274 274 275 275 $response = rest_do_request( self::BASE ); 276 $this->assert Equals( 200, $response->get_status() );276 $this->assertSame( 200, $response->get_status() ); 277 277 278 278 $items = wp_list_filter( $response->get_data(), array( 'plugin' => self::PLUGIN ) ); … … 291 291 292 292 $response = rest_do_request( self::BASE ); 293 $this->assert Equals( 200, $response->get_status() );293 $this->assertSame( 200, $response->get_status() ); 294 294 295 295 $items = wp_list_filter( $response->get_data(), array( 'plugin' => self::PLUGIN ) ); … … 306 306 307 307 $response = rest_do_request( self::BASE . '/' . self::PLUGIN ); 308 $this->assert Equals( 200, $response->get_status() );308 $this->assertSame( 200, $response->get_status() ); 309 309 $this->check_get_plugin_data( $response->get_data() ); 310 310 } … … 315 315 public function test_get_item_logged_out() { 316 316 $response = rest_do_request( self::BASE . '/' . self::PLUGIN ); 317 $this->assert Equals( 401, $response->get_status() );317 $this->assertSame( 401, $response->get_status() ); 318 318 } 319 319 … … 324 324 wp_set_current_user( self::$subscriber_id ); 325 325 $response = rest_do_request( self::BASE . '/' . self::PLUGIN ); 326 $this->assert Equals( 403, $response->get_status() );326 $this->assertSame( 403, $response->get_status() ); 327 327 } 328 328 … … 351 351 352 352 $response = rest_do_request( self::BASE . '/' . self::PLUGIN ); 353 $this->assert Equals( 200, $response->get_status() );353 $this->assertSame( 200, $response->get_status() ); 354 354 } 355 355 … … 360 360 wp_set_current_user( self::$super_admin ); 361 361 $response = rest_do_request( self::BASE . '/' . self::PLUGIN ); 362 $this->assert Equals( 404, $response->get_status() );362 $this->assertSame( 404, $response->get_status() ); 363 363 } 364 364 … … 379 379 $response = rest_do_request( $request ); 380 380 $this->assertNotWPError( $response->as_error() ); 381 $this->assert Equals( 201, $response->get_status() );382 $this->assert Equals( 'Link Manager', $response->get_data()['name'] );381 $this->assertSame( 201, $response->get_status() ); 382 $this->assertSame( 'Link Manager', $response->get_data()['name'] ); 383 383 } 384 384 … … 404 404 $response = rest_do_request( $request ); 405 405 $this->assertNotWPError( $response->as_error() ); 406 $this->assert Equals( 201, $response->get_status() );407 $this->assert Equals( 'Link Manager', $response->get_data()['name'] );406 $this->assertSame( 201, $response->get_status() ); 407 $this->assertSame( 'Link Manager', $response->get_data()['name'] ); 408 408 $this->assertTrue( is_plugin_active( 'link-manager/link-manager.php' ) ); 409 409 } … … 478 478 $response = rest_do_request( $request ); 479 479 $this->assertNotWPError( $response->as_error() ); 480 $this->assert Equals( 201, $response->get_status() );481 $this->assert Equals( 'Link Manager', $response->get_data()['name'] );480 $this->assertSame( 201, $response->get_status() ); 481 $this->assertSame( 'Link Manager', $response->get_data()['name'] ); 482 482 $this->assertTrue( is_plugin_active_for_network( 'link-manager/link-manager.php' ) ); 483 483 } … … 491 491 492 492 $response = rest_do_request( $request ); 493 $this->assert Equals( 401, $response->get_status() );493 $this->assertSame( 401, $response->get_status() ); 494 494 } 495 495 … … 503 503 504 504 $response = rest_do_request( $request ); 505 $this->assert Equals( 403, $response->get_status() );505 $this->assertSame( 403, $response->get_status() ); 506 506 } 507 507 … … 562 562 $response = rest_do_request( $request ); 563 563 564 $this->assert Equals( 200, $response->get_status() );564 $this->assertSame( 200, $response->get_status() ); 565 565 } 566 566 … … 572 572 $response = rest_do_request( $request ); 573 573 574 $this->assert Equals( 401, $response->get_status() );574 $this->assertSame( 401, $response->get_status() ); 575 575 } 576 576 … … 584 584 $response = rest_do_request( $request ); 585 585 586 $this->assert Equals( 403, $response->get_status() );586 $this->assertSame( 403, $response->get_status() ); 587 587 } 588 588 … … 612 612 $response = rest_do_request( $request ); 613 613 614 $this->assert Equals( 200, $response->get_status() );614 $this->assertSame( 200, $response->get_status() ); 615 615 $this->assertTrue( is_plugin_active( self::PLUGIN_FILE ) ); 616 616 } … … 658 658 $response = rest_do_request( $request ); 659 659 660 $this->assert Equals( 200, $response->get_status() );660 $this->assertSame( 200, $response->get_status() ); 661 661 $this->assertTrue( is_plugin_active_for_network( self::PLUGIN_FILE ) ); 662 662 } … … 675 675 $response = rest_do_request( $request ); 676 676 677 $this->assert Equals( 200, $response->get_status() );677 $this->assertSame( 200, $response->get_status() ); 678 678 $this->assertTrue( is_plugin_active_for_network( self::PLUGIN_FILE ) ); 679 679 } … … 706 706 $response = rest_do_request( $request ); 707 707 708 $this->assert Equals( 200, $response->get_status() );708 $this->assertSame( 200, $response->get_status() ); 709 709 $this->assertTrue( is_plugin_active_for_network( self::PLUGIN_FILE ) ); 710 710 } … … 722 722 $response = rest_do_request( $request ); 723 723 724 $this->assert Equals( 200, $response->get_status() );724 $this->assertSame( 200, $response->get_status() ); 725 725 $this->assertTrue( is_plugin_active( self::PLUGIN_FILE ) ); 726 726 } … … 740 740 741 741 $this->assertNotWPError( $response->as_error() ); 742 $this->assert Equals( 200, $response->get_status() );742 $this->assertSame( 200, $response->get_status() ); 743 743 $this->assertTrue( is_plugin_active( self::PLUGIN_FILE ) ); 744 744 } … … 772 772 $response = rest_do_request( $request ); 773 773 774 $this->assert Equals( 200, $response->get_status() );774 $this->assertSame( 200, $response->get_status() ); 775 775 $this->assertTrue( is_plugin_inactive( self::PLUGIN_FILE ) ); 776 776 } … … 805 805 $response = rest_do_request( $request ); 806 806 807 $this->assert Equals( 200, $response->get_status() );807 $this->assertSame( 200, $response->get_status() ); 808 808 $this->assertTrue( is_plugin_inactive( self::PLUGIN_FILE ) ); 809 809 } … … 837 837 838 838 $this->assertNotWPError( $response->as_error() ); 839 $this->assert Equals( 200, $response->get_status() );839 $this->assertSame( 200, $response->get_status() ); 840 840 $this->assertTrue( $response->get_data()['deleted'] ); 841 $this->assert Equals( self::PLUGIN, $response->get_data()['previous']['plugin'] );841 $this->assertSame( self::PLUGIN, $response->get_data()['previous']['plugin'] ); 842 842 $this->assertFileNotExists( WP_PLUGIN_DIR . '/' . self::PLUGIN_FILE ); 843 843 } … … 850 850 $response = rest_do_request( $request ); 851 851 852 $this->assert Equals( 401, $response->get_status() );852 $this->assertSame( 401, $response->get_status() ); 853 853 } 854 854 … … 862 862 $response = rest_do_request( $request ); 863 863 864 $this->assert Equals( 403, $response->get_status() );864 $this->assertSame( 403, $response->get_status() ); 865 865 } 866 866 … … 921 921 $links = $response->get_links(); 922 922 $this->assertArrayHasKey( 'self', $links ); 923 $this->assert Equals( rest_url( self::BASE . '/' . self::PLUGIN ), $links['self'][0]['href'] );923 $this->assertSame( rest_url( self::BASE . '/' . self::PLUGIN ), $links['self'][0]['href'] ); 924 924 } 925 925 … … 938 938 $response = $endpoint->prepare_item_for_response( $item, new WP_REST_Request( 'GET', self::BASE . '/' . self::PLUGIN ) ); 939 939 940 $this->assert Equals( 'network-active', $response->get_data()['status'] );940 $this->assertSame( 'network-active', $response->get_data()['status'] ); 941 941 } 942 942 … … 990 990 */ 991 991 protected function check_get_plugin_data( $data, $network_only = false ) { 992 $this->assert Equals( 'test-plugin/test-plugin', $data['plugin'] );993 $this->assert Equals( '1.5.4', $data['version'] );994 $this->assert Equals( 'inactive', $data['status'] );995 $this->assert Equals( 'Test Plugin', $data['name'] );996 $this->assert Equals( 'https://wordpress.org/plugins/test-plugin/', $data['plugin_uri'] );997 $this->assert Equals( 'WordPress.org', $data['author'] );998 $this->assert Equals( 'https://wordpress.org/', $data['author_uri'] );999 $this->assert Equals( "My 'Cool' Plugin", $data['description']['raw'] );1000 $this->assert Equals( 'My ‘Cool’ Plugin <cite>By <a href="https://wordpress.org/">WordPress.org</a>.</cite>', $data['description']['rendered'] );1001 $this->assert Equals( $network_only, $data['network_only'] );1002 $this->assert Equals( '5.6.0', $data['requires_php'] );1003 $this->assert Equals( '5.4.0', $data['requires_wp'] );1004 $this->assert Equals( 'test-plugin', $data['textdomain'] );992 $this->assertSame( 'test-plugin/test-plugin', $data['plugin'] ); 993 $this->assertSame( '1.5.4', $data['version'] ); 994 $this->assertSame( 'inactive', $data['status'] ); 995 $this->assertSame( 'Test Plugin', $data['name'] ); 996 $this->assertSame( 'https://wordpress.org/plugins/test-plugin/', $data['plugin_uri'] ); 997 $this->assertSame( 'WordPress.org', $data['author'] ); 998 $this->assertSame( 'https://wordpress.org/', $data['author_uri'] ); 999 $this->assertSame( "My 'Cool' Plugin", $data['description']['raw'] ); 1000 $this->assertSame( 'My ‘Cool’ Plugin <cite>By <a href="https://wordpress.org/">WordPress.org</a>.</cite>', $data['description']['rendered'] ); 1001 $this->assertSame( $network_only, $data['network_only'] ); 1002 $this->assertSame( '5.6.0', $data['requires_php'] ); 1003 $this->assertSame( '5.4.0', $data['requires_wp'] ); 1004 $this->assertSame( 'test-plugin', $data['textdomain'] ); 1005 1005 } 1006 1006
Note: See TracChangeset
for help on using the changeset viewer.