Changeset 48937 for trunk/tests/phpunit/tests/ajax/CustomizeManager.php
- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/ajax/CustomizeManager.php
r48858 r48937 116 116 $this->make_ajax_call( 'customize_save' ); 117 117 $this->assertFalse( $this->_last_response_parsed['success'] ); 118 $this->assert Equals( 'unauthenticated', $this->_last_response_parsed['data'] );118 $this->assertSame( 'unauthenticated', $this->_last_response_parsed['data'] ); 119 119 120 120 // Unauthorized. … … 142 142 $this->make_ajax_call( 'customize_save' ); 143 143 $this->assertFalse( $this->_last_response_parsed['success'] ); 144 $this->assert Equals( 'not_preview', $this->_last_response_parsed['data'] );144 $this->assertSame( 'not_preview', $this->_last_response_parsed['data'] ); 145 145 146 146 // Bad nonce. … … 151 151 $this->make_ajax_call( 'customize_save' ); 152 152 $this->assertFalse( $this->_last_response_parsed['success'] ); 153 $this->assert Equals( 'invalid_nonce', $this->_last_response_parsed['data'] );153 $this->assertSame( 'invalid_nonce', $this->_last_response_parsed['data'] ); 154 154 155 155 // User cannot create. … … 162 162 $this->make_ajax_call( 'customize_save' ); 163 163 $this->assertFalse( $this->_last_response_parsed['success'] ); 164 $this->assert Equals( 'cannot_create_changeset_post', $this->_last_response_parsed['data'] );164 $this->assertSame( 'cannot_create_changeset_post', $this->_last_response_parsed['data'] ); 165 165 $this->overridden_caps[ $post_type_obj->cap->create_posts ] = true; 166 166 $this->make_ajax_call( 'customize_save' ); … … 173 173 $this->make_ajax_call( 'customize_save' ); 174 174 $this->assertFalse( $this->_last_response_parsed['success'] ); 175 $this->assert Equals( 'changeset_already_published', $this->_last_response_parsed['data']['code'] );175 $this->assertSame( 'changeset_already_published', $this->_last_response_parsed['data']['code'] ); 176 176 wp_update_post( 177 177 array( … … 186 186 $this->make_ajax_call( 'customize_save' ); 187 187 $this->assertFalse( $this->_last_response_parsed['success'] ); 188 $this->assert Equals( 'cannot_edit_changeset_post', $this->_last_response_parsed['data'] );188 $this->assertSame( 'cannot_edit_changeset_post', $this->_last_response_parsed['data'] ); 189 189 $this->overridden_caps[ $post_type_obj->cap->edit_post ] = true; 190 190 $this->make_ajax_call( 'customize_save' ); … … 196 196 $this->make_ajax_call( 'customize_save' ); 197 197 $this->assertFalse( $this->_last_response_parsed['success'] ); 198 $this->assert Equals( 'invalid_customize_changeset_data', $this->_last_response_parsed['data'] );198 $this->assertSame( 'invalid_customize_changeset_data', $this->_last_response_parsed['data'] ); 199 199 200 200 // Bad customize_changeset_status. … … 203 203 $this->make_ajax_call( 'customize_save' ); 204 204 $this->assertFalse( $this->_last_response_parsed['success'] ); 205 $this->assert Equals( 'bad_customize_changeset_status', $this->_last_response_parsed['data'] );205 $this->assertSame( 'bad_customize_changeset_status', $this->_last_response_parsed['data'] ); 206 206 207 207 // Disallowed publish posts if not allowed. … … 211 211 $this->make_ajax_call( 'customize_save' ); 212 212 $this->assertFalse( $this->_last_response_parsed['success'] ); 213 $this->assert Equals( 'changeset_publish_unauthorized', $this->_last_response_parsed['data'] );213 $this->assertSame( 'changeset_publish_unauthorized', $this->_last_response_parsed['data'] ); 214 214 $_POST['customize_changeset_status'] = 'future'; 215 215 $this->make_ajax_call( 'customize_save' ); 216 216 $this->assertFalse( $this->_last_response_parsed['success'] ); 217 $this->assert Equals( 'changeset_publish_unauthorized', $this->_last_response_parsed['data'] );217 $this->assertSame( 'changeset_publish_unauthorized', $this->_last_response_parsed['data'] ); 218 218 $post_type_obj->cap->publish_posts = 'customize'; // Restore. 219 219 … … 223 223 $this->make_ajax_call( 'customize_save' ); 224 224 $this->assertFalse( $this->_last_response_parsed['success'] ); 225 $this->assert Equals( 'bad_customize_changeset_date', $this->_last_response_parsed['data'] );225 $this->assertSame( 'bad_customize_changeset_date', $this->_last_response_parsed['data'] ); 226 226 $_POST['customize_changeset_date'] = '2010-01-01 00:00:00'; 227 227 $this->make_ajax_call( 'customize_save' ); 228 228 $this->assertFalse( $this->_last_response_parsed['success'] ); 229 $this->assert Equals( 'not_future_date', $this->_last_response_parsed['data']['code'] );229 $this->assertSame( 'not_future_date', $this->_last_response_parsed['data']['code'] ); 230 230 $_POST['customize_changeset_date'] = ( gmdate( 'Y' ) + 1 ) . '-01-01 00:00:00'; 231 231 $this->make_ajax_call( 'customize_save' ); … … 235 235 $this->make_ajax_call( 'customize_save' ); 236 236 $this->assertTrue( $this->_last_response_parsed['success'] ); 237 $this->assert Equals( 'future', get_post_status( $wp_customize->changeset_post_id() ) );237 $this->assertSame( 'future', get_post_status( $wp_customize->changeset_post_id() ) ); 238 238 wp_update_post( 239 239 array( … … 289 289 $this->assertInternalType( 'array', $this->_last_response_parsed['data'] ); 290 290 291 $this->assert Equals( 'publish', $this->_last_response_parsed['data']['changeset_status'] );291 $this->assertSame( 'publish', $this->_last_response_parsed['data']['changeset_status'] ); 292 292 $this->assertArrayHasKey( 'next_changeset_uuid', $this->_last_response_parsed['data'] ); 293 293 $this->assertTrue( wp_is_uuid( $this->_last_response_parsed['data']['next_changeset_uuid'], 4 ) ); 294 $this->assert Equals( 'Success Changeset', get_post( $wp_customize->changeset_post_id() )->post_title );295 $this->assert Equals( 'Successful Site Title', get_option( 'blogname' ) );294 $this->assertSame( 'Success Changeset', get_post( $wp_customize->changeset_post_id() )->post_title ); 295 $this->assertSame( 'Successful Site Title', get_option( 'blogname' ) ); 296 296 } 297 297 … … 328 328 $this->assertInternalType( 'array', $this->_last_response_parsed['data'] ); 329 329 330 $this->assert Equals( 'publish', $this->_last_response_parsed['data']['changeset_status'] );330 $this->assertSame( 'publish', $this->_last_response_parsed['data']['changeset_status'] ); 331 331 $this->assertArrayHasKey( 'next_changeset_uuid', $this->_last_response_parsed['data'] ); 332 332 $this->assertTrue( wp_is_uuid( $this->_last_response_parsed['data']['next_changeset_uuid'], 4 ) ); 333 $this->assert Equals( 'New Site Title', get_option( 'blogname' ) );334 $this->assert Equals( 'Published', get_post( $post_id )->post_title );333 $this->assertSame( 'New Site Title', get_option( 'blogname' ) ); 334 $this->assertSame( 'Published', get_post( $post_id )->post_title ); 335 335 } 336 336 … … 369 369 $this->assertArrayHasKey( 'changeset_date', $this->_last_response_parsed['data'] ); 370 370 $changeset_post_schedule = get_post( $post_id ); 371 $this->assert Equals( $future_date, $changeset_post_schedule->post_date );371 $this->assertSame( $future_date, $changeset_post_schedule->post_date ); 372 372 373 373 // Success future changeset change to draft keeping existing date. … … 378 378 $this->assertArrayNotHasKey( 'changeset_date', $this->_last_response_parsed['data'] ); 379 379 $changeset_post_draft = get_post( $post_id ); 380 $this->assert Equals( $future_date, $changeset_post_draft->post_date );380 $this->assertSame( $future_date, $changeset_post_draft->post_date ); 381 381 382 382 // Success if date is not passed with schedule changeset and stored changeset have future date. … … 386 386 $this->assertArrayHasKey( 'changeset_date', $this->_last_response_parsed['data'] ); 387 387 $changeset_post_schedule = get_post( $post_id ); 388 $this->assert Equals( $future_date, $changeset_post_schedule->post_date );388 $this->assertSame( $future_date, $changeset_post_schedule->post_date ); 389 389 // Success if draft with past date. 390 390 $now = current_time( 'mysql' ); … … 403 403 $this->make_ajax_call( 'customize_save' ); 404 404 $this->assertFalse( $this->_last_response_parsed['success'] ); 405 $this->assert Equals( 'not_future_date', $this->_last_response_parsed['data']['code'] );405 $this->assertSame( 'not_future_date', $this->_last_response_parsed['data']['code'] ); 406 406 407 407 // Success publish changeset reset date to current. … … 424 424 425 425 // Check response when trying to update an already-published post. 426 $this->assert Equals( 'trash', get_post_status( $post_id ) );426 $this->assertSame( 'trash', get_post_status( $post_id ) ); 427 427 $_POST['customize_changeset_status'] = 'publish'; 428 428 $this->make_ajax_call( 'customize_save' ); 429 429 $this->assertFalse( $this->_last_response_parsed['success'] ); 430 $this->assert Equals( 'changeset_already_published', $this->_last_response_parsed['data']['code'] );430 $this->assertSame( 'changeset_already_published', $this->_last_response_parsed['data']['code'] ); 431 431 $this->assertArrayHasKey( 'next_changeset_uuid', $this->_last_response_parsed['data'] ); 432 432 $this->assertTrue( wp_is_uuid( $this->_last_response_parsed['data']['next_changeset_uuid'], 4 ) ); … … 471 471 $this->make_ajax_call( 'customize_save' ); 472 472 $this->assertTrue( $this->_last_response_parsed['success'] ); 473 $this->assert Equals( 'draft', $this->_last_response_parsed['data']['changeset_status'] );473 $this->assertSame( 'draft', $this->_last_response_parsed['data']['changeset_status'] ); 474 474 $autosave_revision = wp_get_post_autosave( $post_id ); 475 475 $this->assertInstanceOf( 'WP_Post', $autosave_revision ); … … 491 491 $this->make_ajax_call( 'customize_trash' ); 492 492 $this->assertFalse( $this->_last_response_parsed['success'] ); 493 $this->assert Equals( 'invalid_nonce', $this->_last_response_parsed['data']['code'] );493 $this->assertSame( 'invalid_nonce', $this->_last_response_parsed['data']['code'] ); 494 494 495 495 $nonce = wp_create_nonce( 'trash_customize_changeset' ); … … 499 499 $this->make_ajax_call( 'customize_trash' ); 500 500 $this->assertFalse( $this->_last_response_parsed['success'] ); 501 $this->assert Equals( 'non_existent_changeset', $this->_last_response_parsed['data']['code'] );501 $this->assertSame( 'non_existent_changeset', $this->_last_response_parsed['data']['code'] ); 502 502 503 503 $wp_customize->register_controls(); // And settings too. … … 512 512 $this->make_ajax_call( 'customize_trash' ); 513 513 $this->assertFalse( $this->_last_response_parsed['success'] ); 514 $this->assert Equals( 'changeset_trash_unauthorized', $this->_last_response_parsed['data']['code'] );514 $this->assertSame( 'changeset_trash_unauthorized', $this->_last_response_parsed['data']['code'] ); 515 515 remove_filter( 'map_meta_cap', array( $this, 'return_do_not_allow' ) ); 516 516 … … 522 522 $this->make_ajax_call( 'customize_trash' ); 523 523 $this->assertFalse( $this->_last_response_parsed['success'] ); 524 $this->assert Equals( 'changeset_locked', $this->_last_response_parsed['data']['code'] );524 $this->assertSame( 'changeset_locked', $this->_last_response_parsed['data']['code'] ); 525 525 delete_post_meta( $wp_customize->changeset_post_id(), '_edit_lock' ); 526 526 … … 533 533 $this->make_ajax_call( 'customize_trash' ); 534 534 $this->assertFalse( $this->_last_response_parsed['success'] ); 535 $this->assert Equals( 'changeset_already_trashed', $this->_last_response_parsed['data']['code'] );535 $this->assertSame( 'changeset_already_trashed', $this->_last_response_parsed['data']['code'] ); 536 536 537 537 wp_update_post( … … 546 546 $this->make_ajax_call( 'customize_trash' ); 547 547 $this->assertFalse( $this->_last_response_parsed['success'] ); 548 $this->assert Equals( 'changeset_trash_failure', $this->_last_response_parsed['data']['code'] );548 $this->assertSame( 'changeset_trash_failure', $this->_last_response_parsed['data']['code'] ); 549 549 remove_filter( 'pre_trash_post', '__return_false' ); 550 $this->assert Equals( $wp_trash_post_count, did_action( 'wp_trash_post' ) );550 $this->assertSame( $wp_trash_post_count, did_action( 'wp_trash_post' ) ); 551 551 552 552 $wp_trash_post_count = did_action( 'wp_trash_post' ); 553 $this->assert Equals( 'draft', get_post_status( $wp_customize->changeset_post_id() ) );553 $this->assertSame( 'draft', get_post_status( $wp_customize->changeset_post_id() ) ); 554 554 $this->make_ajax_call( 'customize_trash' ); 555 555 $this->assertTrue( $this->_last_response_parsed['success'] ); 556 $this->assert Equals( 'trash', get_post_status( $wp_customize->changeset_post_id() ) );557 $this->assert Equals( $wp_trash_post_count + 1, did_action( 'wp_trash_post' ) );556 $this->assertSame( 'trash', get_post_status( $wp_customize->changeset_post_id() ) ); 557 $this->assertSame( $wp_trash_post_count + 1, did_action( 'wp_trash_post' ) ); 558 558 } 559 559 … … 583 583 $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); 584 584 $this->assertFalse( $this->_last_response_parsed['success'] ); 585 $this->assert Equals( 'unauthenticated', $this->_last_response_parsed['data'] );585 $this->assertSame( 'unauthenticated', $this->_last_response_parsed['data'] ); 586 586 wp_set_current_user( $valid_user_id ); 587 587 588 588 $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); 589 589 $this->assertFalse( $this->_last_response_parsed['success'] ); 590 $this->assert Equals( 'invalid_nonce', $this->_last_response_parsed['data'] );590 $this->assertSame( 'invalid_nonce', $this->_last_response_parsed['data'] ); 591 591 592 592 $nonce = wp_create_nonce( 'customize_dismiss_autosave_or_lock' ); … … 600 600 $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); 601 601 $this->assertFalse( $this->_last_response_parsed['success'] ); 602 $this->assert Equals( 'no_changeset_to_dismiss_lock', $this->_last_response_parsed['data'] );602 $this->assertSame( 'no_changeset_to_dismiss_lock', $this->_last_response_parsed['data'] ); 603 603 604 604 $_POST['dismiss_autosave'] = true; … … 607 607 $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); 608 608 $this->assertFalse( $this->_last_response_parsed['success'] ); 609 $this->assert Equals( 'no_auto_draft_to_delete', $this->_last_response_parsed['data'] );609 $this->assertSame( 'no_auto_draft_to_delete', $this->_last_response_parsed['data'] ); 610 610 611 611 $other_user_id = $this->factory()->user->create(); … … 641 641 $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); 642 642 $this->assertTrue( $this->_last_response_parsed['success'] ); 643 $this->assert Equals( 'auto_draft_dismissed', $this->_last_response_parsed['data'] );643 $this->assertSame( 'auto_draft_dismissed', $this->_last_response_parsed['data'] ); 644 644 foreach ( $user_auto_draft_ids as $post_id ) { 645 $this->assert Equals( 'auto-draft', get_post_status( $post_id ) );645 $this->assertSame( 'auto-draft', get_post_status( $post_id ) ); 646 646 $this->assertTrue( (bool) get_post_meta( $post_id, '_customize_restore_dismissed', true ) ); 647 647 } 648 648 foreach ( $other_user_auto_draft_ids as $post_id ) { 649 $this->assert Equals( 'auto-draft', get_post_status( $post_id ) );649 $this->assertSame( 'auto-draft', get_post_status( $post_id ) ); 650 650 $this->assertFalse( (bool) get_post_meta( $post_id, '_customize_restore_dismissed', true ) ); 651 651 } … … 654 654 $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); 655 655 $this->assertFalse( $this->_last_response_parsed['success'] ); 656 $this->assert Equals( 'no_auto_draft_to_delete', $this->_last_response_parsed['data'] );656 $this->assertSame( 'no_auto_draft_to_delete', $this->_last_response_parsed['data'] ); 657 657 658 658 // Save a changeset as a draft. … … 673 673 $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); 674 674 $this->assertTrue( $this->_last_response_parsed['success'] ); 675 $this->assert Equals( 'changeset_lock_dismissed', $this->_last_response_parsed['data'] );675 $this->assertSame( 'changeset_lock_dismissed', $this->_last_response_parsed['data'] ); 676 676 677 677 $_POST['dismiss_autosave'] = true; … … 685 685 $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); 686 686 $this->assertFalse( $this->_last_response_parsed['success'] ); 687 $this->assert Equals( 'no_autosave_revision_to_delete', $this->_last_response_parsed['data'] );687 $this->assertSame( 'no_autosave_revision_to_delete', $this->_last_response_parsed['data'] ); 688 688 689 689 // Add the autosave revision. … … 707 707 $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); 708 708 $this->assertTrue( $this->_last_response_parsed['success'] ); 709 $this->assert Equals( 'autosave_revision_deleted', $this->_last_response_parsed['data'] );709 $this->assertSame( 'autosave_revision_deleted', $this->_last_response_parsed['data'] ); 710 710 $this->assertFalse( wp_get_post_autosave( $wp_customize->changeset_post_id() ) ); 711 711 … … 713 713 $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); 714 714 $this->assertFalse( $this->_last_response_parsed['success'] ); 715 $this->assert Equals( 'no_autosave_revision_to_delete', $this->_last_response_parsed['data'] );715 $this->assertSame( 'no_autosave_revision_to_delete', $this->_last_response_parsed['data'] ); 716 716 } 717 717 }
Note: See TracChangeset
for help on using the changeset viewer.