Changeset 54757 for trunk/tests/phpunit/tests/multisite/site.php
- Timestamp:
- 11/06/2022 04:19:15 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/multisite/site.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/site.php
r54756 r54757 442 442 443 443 /** 444 * Updating a field returns the sme value that was passed.445 */446 public function test_update_blog_status() {447 $result = update_blog_status( 1, 'spam', 0 );448 $this->assertSame( 0, $result );449 }450 451 /**452 * Updating an invalid field returns the same value that was passed.453 */454 public function test_update_blog_status_invalid_status() {455 $result = update_blog_status( 1, 'doesnotexist', 'invalid' );456 $this->assertSame( 'invalid', $result );457 }458 459 public function test_update_blog_status_make_ham_blog_action() {460 $test_action_counter = new MockAction();461 462 $blog_id = self::factory()->blog->create();463 update_blog_details( $blog_id, array( 'spam' => 1 ) );464 465 add_action( 'make_ham_blog', array( $test_action_counter, 'action' ) );466 update_blog_status( $blog_id, 'spam', 0 );467 $blog = get_site( $blog_id );468 469 $this->assertSame( '0', $blog->spam );470 $this->assertSame( 1, $test_action_counter->get_call_count() );471 472 // The action should not fire if the status of 'spam' stays the same.473 update_blog_status( $blog_id, 'spam', 0 );474 $blog = get_site( $blog_id );475 476 $this->assertSame( '0', $blog->spam );477 $this->assertSame( 1, $test_action_counter->get_call_count() );478 }479 480 public function test_content_from_spam_blog_is_not_available() {481 $spam_blog_id = self::factory()->blog->create();482 switch_to_blog( $spam_blog_id );483 $post_data = array(484 'post_title' => 'Hello World!',485 'post_content' => 'Hello world content',486 );487 $post_id = self::factory()->post->create( $post_data );488 $post = get_post( $post_id );489 $spam_permalink = site_url() . '/?p=' . $post->ID;490 $spam_embed_url = get_post_embed_url( $post_id );491 492 restore_current_blog();493 $this->assertNotEmpty( $spam_permalink );494 $this->assertSame( $post_data['post_title'], $post->post_title );495 496 update_blog_status( $spam_blog_id, 'spam', 1 );497 498 $post_id = self::factory()->post->create(499 array(500 'post_content' => "\n $spam_permalink \n",501 )502 );503 $post = get_post( $post_id );504 $content = apply_filters( 'the_content', $post->post_content );505 506 $this->assertStringNotContainsString( $post_data['post_title'], $content );507 $this->assertStringNotContainsString( "src=\"{$spam_embed_url}#?", $content );508 }509 510 public function test_update_blog_status_make_spam_blog_action() {511 $test_action_counter = new MockAction();512 513 $blog_id = self::factory()->blog->create();514 515 add_action( 'make_spam_blog', array( $test_action_counter, 'action' ) );516 update_blog_status( $blog_id, 'spam', 1 );517 $blog = get_site( $blog_id );518 519 $this->assertSame( '1', $blog->spam );520 $this->assertSame( 1, $test_action_counter->get_call_count() );521 522 // The action should not fire if the status of 'spam' stays the same.523 update_blog_status( $blog_id, 'spam', 1 );524 $blog = get_site( $blog_id );525 526 $this->assertSame( '1', $blog->spam );527 $this->assertSame( 1, $test_action_counter->get_call_count() );528 }529 530 public function test_update_blog_status_archive_blog_action() {531 $test_action_counter = new MockAction();532 533 $blog_id = self::factory()->blog->create();534 535 add_action( 'archive_blog', array( $test_action_counter, 'action' ) );536 update_blog_status( $blog_id, 'archived', 1 );537 $blog = get_site( $blog_id );538 539 $this->assertSame( '1', $blog->archived );540 $this->assertSame( 1, $test_action_counter->get_call_count() );541 542 // The action should not fire if the status of 'archived' stays the same.543 update_blog_status( $blog_id, 'archived', 1 );544 $blog = get_site( $blog_id );545 546 $this->assertSame( '1', $blog->archived );547 $this->assertSame( 1, $test_action_counter->get_call_count() );548 }549 550 public function test_update_blog_status_unarchive_blog_action() {551 $test_action_counter = new MockAction();552 553 $blog_id = self::factory()->blog->create();554 update_blog_details( $blog_id, array( 'archived' => 1 ) );555 556 add_action( 'unarchive_blog', array( $test_action_counter, 'action' ) );557 update_blog_status( $blog_id, 'archived', 0 );558 $blog = get_site( $blog_id );559 560 $this->assertSame( '0', $blog->archived );561 $this->assertSame( 1, $test_action_counter->get_call_count() );562 563 // The action should not fire if the status of 'archived' stays the same.564 update_blog_status( $blog_id, 'archived', 0 );565 $blog = get_site( $blog_id );566 $this->assertSame( '0', $blog->archived );567 $this->assertSame( 1, $test_action_counter->get_call_count() );568 }569 570 public function test_update_blog_status_make_delete_blog_action() {571 $test_action_counter = new MockAction();572 573 $blog_id = self::factory()->blog->create();574 575 add_action( 'make_delete_blog', array( $test_action_counter, 'action' ) );576 update_blog_status( $blog_id, 'deleted', 1 );577 $blog = get_site( $blog_id );578 579 $this->assertSame( '1', $blog->deleted );580 $this->assertSame( 1, $test_action_counter->get_call_count() );581 582 // The action should not fire if the status of 'deleted' stays the same.583 update_blog_status( $blog_id, 'deleted', 1 );584 $blog = get_site( $blog_id );585 586 $this->assertSame( '1', $blog->deleted );587 $this->assertSame( 1, $test_action_counter->get_call_count() );588 }589 590 public function test_update_blog_status_make_undelete_blog_action() {591 $test_action_counter = new MockAction();592 593 $blog_id = self::factory()->blog->create();594 update_blog_details( $blog_id, array( 'deleted' => 1 ) );595 596 add_action( 'make_undelete_blog', array( $test_action_counter, 'action' ) );597 update_blog_status( $blog_id, 'deleted', 0 );598 $blog = get_site( $blog_id );599 600 $this->assertSame( '0', $blog->deleted );601 $this->assertSame( 1, $test_action_counter->get_call_count() );602 603 // The action should not fire if the status of 'deleted' stays the same.604 update_blog_status( $blog_id, 'deleted', 0 );605 $blog = get_site( $blog_id );606 607 $this->assertSame( '0', $blog->deleted );608 $this->assertSame( 1, $test_action_counter->get_call_count() );609 }610 611 public function test_update_blog_status_mature_blog_action() {612 $test_action_counter = new MockAction();613 614 $blog_id = self::factory()->blog->create();615 616 add_action( 'mature_blog', array( $test_action_counter, 'action' ) );617 update_blog_status( $blog_id, 'mature', 1 );618 $blog = get_site( $blog_id );619 620 $this->assertSame( '1', $blog->mature );621 $this->assertSame( 1, $test_action_counter->get_call_count() );622 623 // The action should not fire if the status of 'mature' stays the same.624 update_blog_status( $blog_id, 'mature', 1 );625 $blog = get_site( $blog_id );626 627 $this->assertSame( '1', $blog->mature );628 $this->assertSame( 1, $test_action_counter->get_call_count() );629 }630 631 public function test_update_blog_status_unmature_blog_action() {632 $test_action_counter = new MockAction();633 634 $blog_id = self::factory()->blog->create();635 update_blog_details( $blog_id, array( 'mature' => 1 ) );636 637 add_action( 'unmature_blog', array( $test_action_counter, 'action' ) );638 update_blog_status( $blog_id, 'mature', 0 );639 640 $blog = get_site( $blog_id );641 $this->assertSame( '0', $blog->mature );642 $this->assertSame( 1, $test_action_counter->get_call_count() );643 644 // The action should not fire if the status of 'mature' stays the same.645 update_blog_status( $blog_id, 'mature', 0 );646 $blog = get_site( $blog_id );647 648 $this->assertSame( '0', $blog->mature );649 $this->assertSame( 1, $test_action_counter->get_call_count() );650 }651 652 public function test_update_blog_status_update_blog_public_action() {653 $test_action_counter = new MockAction();654 655 $blog_id = self::factory()->blog->create();656 657 add_action( 'update_blog_public', array( $test_action_counter, 'action' ) );658 update_blog_status( $blog_id, 'public', 0 );659 660 $blog = get_site( $blog_id );661 $this->assertSame( '0', $blog->public );662 $this->assertSame( 1, $test_action_counter->get_call_count() );663 664 // The action should not fire if the status of 'mature' stays the same.665 update_blog_status( $blog_id, 'public', 0 );666 $blog = get_site( $blog_id );667 668 $this->assertSame( '0', $blog->public );669 $this->assertSame( 1, $test_action_counter->get_call_count() );670 }671 672 /**673 444 * @ticket 27952 674 445 */
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)