Changeset 1089 in tests
- Timestamp:
- 10/24/2012 01:49:01 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/ms.php
r1082 r1089 371 371 } 372 372 373 function _action_counter_cb( $blog_id ) { 374 global $test_action_counter; 375 $test_action_counter++; 376 } 377 373 378 function test_update_blog_details() { 374 global $current_site ;379 global $current_site, $test_action_counter; 375 380 376 381 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); … … 400 405 $this->assertEquals( '1', $blog->spam ); 401 406 402 global $test_action_counter;403 407 $test_action_counter = 0; 404 $callback = function( $blog_id ) { 405 global $test_action_counter; 406 $test_action_counter++; 407 }; 408 409 add_action( 'make_ham_blog', $callback, 10, 1 ); 408 409 add_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 410 410 $result = update_blog_details( $blog_id, array( 'spam' => 0 ) ); 411 411 $this->assertTrue( $result ); … … 420 420 $this->assertEquals( '0', $blog->spam ); 421 421 $this->assertEquals( 1, $test_action_counter ); 422 remove_action( 'make_ham_blog', $callback, 10, 1 );422 remove_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 423 423 424 add_action( 'make_spam_blog', $callback, 10, 1 );424 add_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 425 425 $result = update_blog_details( $blog_id, array( 'spam' => 1 ) ); 426 426 $this->assertTrue( $result ); … … 435 435 $this->assertEquals( '1', $blog->spam ); 436 436 $this->assertEquals( 2, $test_action_counter ); 437 remove_action( 'make_spam_blog', $callback, 10, 1 );438 439 add_action( 'archive_blog', $callback, 10, 1 );437 remove_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 438 439 add_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 440 440 $result = update_blog_details( $blog_id, array( 'archived' => 1 ) ); 441 441 $this->assertTrue( $result ); … … 450 450 $this->assertEquals( '1', $blog->archived ); 451 451 $this->assertEquals( 3, $test_action_counter ); 452 remove_action( 'archive_blog', $callback, 10, 1 );453 454 add_action( 'unarchive_blog', $callback, 10, 1 );452 remove_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 453 454 add_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 455 455 $result = update_blog_details( $blog_id, array( 'archived' => 0 ) ); 456 456 $this->assertTrue( $result ); … … 465 465 $this->assertEquals( '0', $blog->archived ); 466 466 $this->assertEquals( 4, $test_action_counter ); 467 remove_action( 'unarchive_blog', $callback, 10, 1 );468 469 add_action( 'make_delete_blog', $callback, 10, 1 );467 remove_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 468 469 add_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 470 470 $result = update_blog_details( $blog_id, array( 'deleted' => 1 ) ); 471 471 $this->assertTrue( $result ); … … 480 480 $this->assertEquals( '1', $blog->deleted ); 481 481 $this->assertEquals( 5, $test_action_counter ); 482 remove_action( 'make_delete_blog', $callback, 10, 1 );483 484 add_action( 'make_undelete_blog', $callback, 10, 1 );482 remove_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 483 484 add_action( 'make_undelete_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 485 485 $result = update_blog_details( $blog_id, array( 'deleted' => 0 ) ); 486 486 $this->assertTrue( $result ); … … 495 495 $this->assertEquals( '0', $blog->deleted ); 496 496 $this->assertEquals( 6, $test_action_counter ); 497 remove_action( 'make_undelete_blog', $callback, 10, 1 );498 499 add_action( 'mature_blog', $callback, 10, 1 );497 remove_action( 'make_undelete_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 498 499 add_action( 'mature_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 500 500 $result = update_blog_details( $blog_id, array( 'mature' => 1 ) ); 501 501 $this->assertTrue( $result ); … … 510 510 $this->assertEquals( '1', $blog->mature ); 511 511 $this->assertEquals( 7, $test_action_counter ); 512 remove_action( 'mature_blog', $callback, 10, 1 );513 514 add_action( 'unmature_blog', $callback, 10, 1 );512 remove_action( 'mature_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 513 514 add_action( 'unmature_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 515 515 $result = update_blog_details( $blog_id, array( 'mature' => 0 ) ); 516 516 $this->assertTrue( $result ); … … 525 525 $this->assertEquals( '0', $blog->mature ); 526 526 $this->assertEquals( 8, $test_action_counter ); 527 remove_action( 'unmature_blog', $callback, 10, 1 );527 remove_action( 'unmature_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 528 528 } 529 529 530 530 function test_update_blog_status() { 531 global $test_action_counter; 532 531 533 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); 532 534 $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogpath', 'title' => 'Test Title' ) ); 533 535 $this->assertInternalType( 'int', $blog_id ); 534 536 535 global $test_action_counter;536 537 $test_action_counter = 0; 537 $callback = function( $blog_id ) { 538 global $test_action_counter; 539 $test_action_counter++; 540 }; 541 542 add_action( 'make_ham_blog', $callback, 10, 1 ); 538 539 add_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 543 540 $result = update_blog_status( $blog_id, 'spam', 0 ); 544 541 $this->assertEquals( 0, $result ); … … 553 550 $this->assertEquals( '0', $blog->spam ); 554 551 $this->assertEquals( 2, $test_action_counter ); 555 remove_action( 'make_ham_blog', $callback, 10, 1 );552 remove_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 556 553 557 add_action( 'make_spam_blog', $callback, 10, 1 );554 add_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 558 555 $result = update_blog_status( $blog_id, 'spam', 1 ); 559 556 $this->assertEquals( 1, $result ); … … 568 565 $this->assertEquals( '1', $blog->spam ); 569 566 $this->assertEquals( 4, $test_action_counter ); 570 remove_action( 'make_spam_blog', $callback, 10, 1 );571 572 add_action( 'archive_blog', $callback, 10, 1 );567 remove_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 568 569 add_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 573 570 $result = update_blog_status( $blog_id, 'archived', 1 ); 574 571 $this->assertEquals( 1, $result ); … … 583 580 $this->assertEquals( '1', $blog->archived ); 584 581 $this->assertEquals( 6, $test_action_counter ); 585 remove_action( 'archive_blog', $callback, 10, 1 );586 587 add_action( 'unarchive_blog', $callback, 10, 1 );582 remove_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 583 584 add_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 588 585 $result = update_blog_status( $blog_id, 'archived', 0 ); 589 586 $this->assertEquals( 0, $result ); … … 598 595 $this->assertEquals( '0', $blog->archived ); 599 596 $this->assertEquals( 8, $test_action_counter ); 600 remove_action( 'unarchive_blog', $callback, 10, 1 );601 602 add_action( 'make_delete_blog', $callback, 10, 1 );597 remove_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 598 599 add_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 603 600 $result = update_blog_status( $blog_id, 'deleted', 1 ); 604 601 $this->assertEquals( 1, $result ); … … 613 610 $this->assertEquals( '1', $blog->deleted ); 614 611 $this->assertEquals( 10, $test_action_counter ); 615 remove_action( 'make_delete_blog', $callback, 10, 1 );616 617 add_action( 'make_undelete_blog', $callback, 10, 1 );612 remove_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 613 614 add_action( 'make_undelete_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 618 615 $result = update_blog_status( $blog_id, 'deleted', 0 ); 619 616 $this->assertEquals( 0, $result ); … … 628 625 $this->assertEquals( '0', $blog->deleted ); 629 626 $this->assertEquals( 12, $test_action_counter ); 630 remove_action( 'make_undelete_blog', $callback, 10, 1 );631 632 add_action( 'mature_blog', $callback, 10, 1 );627 remove_action( 'make_undelete_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 628 629 add_action( 'mature_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 633 630 $result = update_blog_status( $blog_id, 'mature', 1 ); 634 631 $this->assertEquals( 1, $result ); … … 643 640 $this->assertEquals( '1', $blog->mature ); 644 641 $this->assertEquals( 14, $test_action_counter ); 645 remove_action( 'mature_blog', $callback, 10, 1 );646 647 add_action( 'unmature_blog', $callback, 10, 1 );642 remove_action( 'mature_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 643 644 add_action( 'unmature_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 648 645 $result = update_blog_status( $blog_id, 'mature', 0 ); 649 646 $this->assertEquals( 0, $result ); … … 658 655 $this->assertEquals( '0', $blog->mature ); 659 656 $this->assertEquals( 16, $test_action_counter ); 660 remove_action( 'unmature_blog', $callback, 10, 1 );657 remove_action( 'unmature_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 661 658 662 659 // Updating a dummy field returns the value passed. Go fig.
Note: See TracChangeset
for help on using the changeset viewer.