Changeset 35244
- Timestamp:
- 10/17/2015 07:24:20 PM (9 years ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/factory.php
r34855 r35244 402 402 403 403 class WP_UnitTest_Generator_Sequence { 404 var $next; 405 var $template_string; 406 407 function __construct( $template_string = '%s', $start = 1 ) { 408 $this->next = $start; 404 static $incr = -1; 405 public $next; 406 public $template_string; 407 408 function __construct( $template_string = '%s', $start = null ) { 409 if ( $start ) { 410 $this->next = $start; 411 } else { 412 self::$incr++; 413 $this->next = self::$incr; 414 } 409 415 $this->template_string = $template_string; 410 416 } -
trunk/tests/phpunit/includes/testcase-canonical.php
r35242 r35244 135 135 */ 136 136 public static function delete_shared_fixtures() { 137 if ( is_multisite() ) { 138 wpmu_delete_user( self::$author_id ); 139 } else { 140 wp_delete_user( self::$author_id ); 141 } 137 self::delete_user( self::$author_id ); 142 138 143 139 foreach ( self::$post_ids as $pid ) { -
trunk/tests/phpunit/tests/admin/includesPost.php
r35242 r35244 5 5 */ 6 6 class Tests_Admin_includesPost extends WP_UnitTestCase { 7 8 function tearDown() {9 wp_set_current_user( 0 );10 parent::tearDown();11 }12 7 13 8 function test__wp_translate_postdata_cap_checks_contributor() { -
trunk/tests/phpunit/tests/ajax/Autosave.php
r35242 r35244 39 39 $post_id = self::factory()->post->create( array( 'post_status' => 'draft' ) ); 40 40 $this->_post = get_post( $post_id ); 41 }42 43 /**44 * Tear down the test fixture.45 * Reset the current user46 */47 public function tearDown() {48 wp_set_current_user( 0 );49 parent::tearDown();50 41 } 51 42 -
trunk/tests/phpunit/tests/ajax/CustomizeMenus.php
r35242 r35244 27 27 $this->wp_customize = new WP_Customize_Manager(); 28 28 $wp_customize = $this->wp_customize; 29 }30 31 /**32 * Tear down the test fixture.33 */34 public function tearDown() {35 wp_set_current_user( 0 );36 parent::tearDown();37 29 } 38 30 -
trunk/tests/phpunit/tests/attachment/slashes.php
r35242 r35244 10 10 parent::setUp(); 11 11 $this->author_id = self::factory()->user->create( array( 'role' => 'editor' ) ); 12 $this->old_current_user = get_current_user_id();13 12 wp_set_current_user( $this->author_id ); 14 13 … … 22 21 $this->slash_6 = 'String with 6 slashes \\\\\\\\\\\\'; 23 22 $this->slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\'; 24 }25 26 function tearDown() {27 wp_set_current_user( $this->old_current_user );28 wp_delete_user( $this->author_id );29 parent::tearDown();30 23 } 31 24 -
trunk/tests/phpunit/tests/basic.php
r35172 r35244 6 6 */ 7 7 class Tests_Basic extends WP_UnitTestCase { 8 var $val;9 10 function setUp() {11 parent::setUp();12 $this->val = true;13 }14 15 function tearDown() {16 $this->val = false;17 parent::tearDown();18 }19 20 function test_true() {21 $this->assertTrue($this->val);22 }23 8 24 9 function test_license() { -
trunk/tests/phpunit/tests/cache.php
r35108 r35244 5 5 */ 6 6 class Tests_Cache extends WP_UnitTestCase { 7 var $cache = NULL;7 var $cache = null; 8 8 9 9 function setUp() { -
trunk/tests/phpunit/tests/comment-submission.php
r35242 r35244 11 11 } 12 12 13 function tearDown() {14 wp_set_current_user( 0 );15 parent::tearDown();16 }17 18 13 public function test_submitting_comment_to_invalid_post_returns_error() { 19 20 14 $error = 'comment_id_not_found'; 21 15 -
trunk/tests/phpunit/tests/comment.php
r35242 r35244 16 16 17 17 public static function wpTearDownAfterClass() { 18 wp_delete_post( self::$post_id );18 wp_delete_post( self::$post_id, true ); 19 19 20 20 self::delete_user( self::$user_id ); -
trunk/tests/phpunit/tests/comment/slashes.php
r35242 r35244 11 11 // we need an admin user to bypass comment flood protection 12 12 $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); 13 $this->old_current_user = get_current_user_id();14 13 wp_set_current_user( $this->author_id ); 15 14 … … 23 22 $this->slash_6 = 'String with 6 slashes \\\\\\\\\\\\'; 24 23 $this->slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\'; 25 }26 27 function tearDown() {28 wp_set_current_user( $this->old_current_user );29 parent::tearDown();30 24 } 31 25 -
trunk/tests/phpunit/tests/link.php
r35242 r35244 4 4 */ 5 5 class Tests_Link extends WP_UnitTestCase { 6 7 function tearDown() {8 global $wp_rewrite;9 $wp_rewrite->init();10 parent::tearDown();11 }12 6 13 7 function _get_pagenum_link_cb( $url ) { -
trunk/tests/phpunit/tests/meta/slashes.php
r35242 r35244 11 11 $this->author_id = self::factory()->user->create( array( 'role' => 'editor' ) ); 12 12 $this->post_id = self::factory()->post->create(); 13 $this->old_current_user = get_current_user_id(); 13 14 14 wp_set_current_user( $this->author_id ); 15 15 … … 21 21 $this->slash_6 = 'String with 6 slashes \\\\\\\\\\\\'; 22 22 $this->slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\'; 23 }24 25 function tearDown() {26 wp_set_current_user( $this->old_current_user );27 parent::tearDown();28 23 } 29 24 -
trunk/tests/phpunit/tests/multisite/getSpaceAllowed.php
r35016 r35244 19 19 self::$original_site_blog_upload_space = get_site_option( 'blog_upload_space' ); 20 20 self::$original_blog_upload_space = get_option( 'blog_upload_space' ); 21 22 21 } 23 22 -
trunk/tests/phpunit/tests/multisite/site.php
r35242 r35244 675 675 $this->assertEquals( 2, get_blog_details()->post_count ); 676 676 677 wp_delete_post( $post2 );677 wp_delete_post( $post2, true ); 678 678 $this->assertEquals( 1, get_blog_details()->post_count ); 679 679 } -
trunk/tests/phpunit/tests/option/userSettings.php
r35242 r35244 15 15 function tearDown() { 16 16 unset( $GLOBALS['_updated_user_settings'] ); 17 delete_user_option( $this->user_id, 'user-settings' );18 17 19 18 parent::tearDown(); -
trunk/tests/phpunit/tests/post/getPages.php
r35242 r35244 79 79 80 80 // This should bump last_changed. 81 wp_delete_post( $pages[0]->ID );81 wp_delete_post( $pages[0]->ID, true ); 82 82 $old_changed_float = $this->_microtime_to_float( $last_changed ); 83 83 $new_changed_float = $this->_microtime_to_float( wp_cache_get( 'last_changed', 'posts' ) ); -
trunk/tests/phpunit/tests/post/meta.php
r35242 r35244 31 31 // insert a post 32 32 $this->post_id_2 = wp_insert_post($post); 33 }34 35 function tearDown() {36 wp_delete_post($this->post_id);37 wp_delete_post($this->post_id_2);38 parent::tearDown();39 33 } 40 34 -
trunk/tests/phpunit/tests/post/slashes.php
r35242 r35244 10 10 parent::setUp(); 11 11 $this->author_id = self::factory()->user->create( array( 'role' => 'editor' ) ); 12 $this->old_current_user = get_current_user_id(); 12 13 13 wp_set_current_user( $this->author_id ); 14 14 … … 22 22 $this->slash_6 = 'String with 6 slashes \\\\\\\\\\\\'; 23 23 $this->slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\'; 24 }25 26 function tearDown() {27 wp_set_current_user( $this->old_current_user );28 parent::tearDown();29 24 } 30 25 -
trunk/tests/phpunit/tests/post/thumbnails.php
r35194 r35244 18 18 19 19 public static function wpTearDownAfterClass() { 20 wp_delete_post( self::$post->ID );21 wp_delete_attachment( self::$attachment_id );20 wp_delete_post( self::$post->ID, true ); 21 wp_delete_attachment( self::$attachment_id, true ); 22 22 } 23 23 -
trunk/tests/phpunit/tests/query/conditionals.php
r35242 r35244 26 26 27 27 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 28 }29 30 function tearDown() {31 global $wp_rewrite;32 $wp_rewrite->init();33 34 parent::tearDown();35 28 } 36 29 -
trunk/tests/phpunit/tests/query/setupPostdata.php
r35242 r35244 22 22 } 23 23 } 24 }25 26 public function tearDown() {27 parent::tearDown();28 return;29 30 foreach ( $this->global_keys as $global_key ) {31 if ( ! is_null( $this->global_data[ $global_key ] ) ) {32 $GLOBALS[ $global_key ] = $this->global_data[ $global_key ];33 } else {34 unset( $GLOBALS[ $global_key ] );35 }36 }37 38 $this->global_data = array();39 24 } 40 25 -
trunk/tests/phpunit/tests/shortcode.php
r34933 r35244 21 21 function tearDown() { 22 22 global $shortcode_tags; 23 foreach ( $this->shortcodes as $shortcode ) 23 foreach ( $this->shortcodes as $shortcode ) { 24 24 unset( $shortcode_tags[ $shortcode ] ); 25 } 25 26 parent::tearDown(); 26 27 } -
trunk/tests/phpunit/tests/term.php
r35242 r35244 13 13 14 14 public static function wpTearDownAfterClass() { 15 array_map( 'wp_delete_post', self::$post_ids ); 15 foreach ( self::$post_ids as $post_id ) { 16 wp_delete_post( $post_id, true ); 17 } 16 18 } 17 19 -
trunk/tests/phpunit/tests/term/slashes.php
r35242 r35244 10 10 parent::setUp(); 11 11 $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); 12 $this->old_current_user = get_current_user_id(); 12 13 13 wp_set_current_user( $this->author_id ); 14 14 … … 20 20 $this->slash_6 = 'String with 6 slashes \\\\\\\\\\\\'; 21 21 $this->slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\'; 22 }23 24 function tearDown() {25 wp_set_current_user( $this->old_current_user );26 parent::tearDown();27 22 } 28 23 -
trunk/tests/phpunit/tests/user.php
r35242 r35244 245 245 246 246 foreach ( $roles as $role => $level ) { 247 $user_id = self::factory()->user->create( array( 'role' => $role ) ); 247 $user_id = self::factory()->user->create( array( 248 'user_email' => 'user_19265_' . $role . '@burritos.com', 249 'user_login' => 'user_19265_' . $role, 250 'role' => $role 251 ) ); 248 252 $user = new WP_User( $user_id ); 249 253 … … 776 780 ) ); 777 781 782 $user1 = new WP_User( $u1 ); 783 784 $expected = str_repeat( 'a', 50 ); 785 $this->assertSame( $expected, $user1->user_nicename ); 786 778 787 $user_login = str_repeat( 'a', 55 ); 779 788 $u = wp_insert_user( array( … … 784 793 785 794 $this->assertNotEmpty( $u ); 786 $user = new WP_User( $u );795 $user2 = new WP_User( $u ); 787 796 $expected = str_repeat( 'a', 48 ) . '-2'; 788 $this->assertSame( $expected, $user ->user_nicename );797 $this->assertSame( $expected, $user2->user_nicename ); 789 798 } 790 799 … … 793 802 */ 794 803 public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename_when_suffix_has_more_than_one_character() { 795 $user s = self::factory()->user->create_many( 4, array(804 $user_ids = self::factory()->user->create_many( 4, array( 796 805 'user_nicename' => str_repeat( 'a', 50 ), 797 806 ) ); 807 808 foreach ( $user_ids as $i => $user_id ) { 809 $user = new WP_User( $user_id ); 810 if ( 0 === $i ) { 811 $expected = str_repeat( 'a', 50 ); 812 } else { 813 $expected = str_repeat( 'a', 48 ) . '-' . ( $i + 1 ); 814 } 815 $this->assertSame( $expected, $user->user_nicename ); 816 } 798 817 799 818 $user_login = str_repeat( 'a', 55 ); -
trunk/tests/phpunit/tests/user/countUserPosts.php
r35224 r35244 28 28 'post_type' => 'wptests_pt', 29 29 ) ) ); 30 self::$post_ids = array_merge( self::$post_ids, $factory->post->create_many( 1, array( 30 31 self::$post_ids[] = $factory->post->create( array( 31 32 'post_author' => 12345, 32 33 'post_type' => 'wptests_pt', 33 ) ) );34 ) ); 34 35 } 35 36 -
trunk/tests/phpunit/tests/user/listAuthors.php
r35242 r35244 5 5 */ 6 6 class Tests_User_ListAuthors extends WP_UnitTestCase { 7 static $user s = array();7 static $user_ids = array(); 8 8 static $fred_id; 9 9 static $posts = array(); … … 25 25 */ 26 26 public static function wpSetUpBeforeClass( $factory ) { 27 self::$user s[] = $factory->user->create( array( 'user_login' => 'zack', 'display_name' => 'zack', 'role' => 'author', 'first_name' => 'zack', 'last_name' => 'moon' ) );28 self::$user s[] = $factory->user->create( array( 'user_login' => 'bob', 'display_name' => 'bob', 'role' => 'author', 'first_name' => 'bob', 'last_name' => 'reno' ) );29 self::$user s[] = $factory->user->create( array( 'user_login' => 'paul', 'display_name' => 'paul', 'role' => 'author', 'first_name' => 'paul', 'last_name' => 'norris' ) );27 self::$user_ids[] = $factory->user->create( array( 'user_login' => 'zack', 'display_name' => 'zack', 'role' => 'author', 'first_name' => 'zack', 'last_name' => 'moon' ) ); 28 self::$user_ids[] = $factory->user->create( array( 'user_login' => 'bob', 'display_name' => 'bob', 'role' => 'author', 'first_name' => 'bob', 'last_name' => 'reno' ) ); 29 self::$user_ids[] = $factory->user->create( array( 'user_login' => 'paul', 'display_name' => 'paul', 'role' => 'author', 'first_name' => 'paul', 'last_name' => 'norris' ) ); 30 30 self::$fred_id = $factory->user->create( array( 'user_login' => 'fred', 'role' => 'author' ) ); 31 31 32 32 $count = 0; 33 foreach ( self::$user s as $userid ) {33 foreach ( self::$user_ids as $userid ) { 34 34 $count = $count + 1; 35 35 for ( $i = 0; $i < $count; $i++ ) { … … 42 42 43 43 public static function wpTearDownAfterClass() { 44 foreach ( array_merge( self::$users, array( self::$fred_id ) ) as $user_id ) { 44 self::$user_ids[] = self::$fred_id; 45 46 foreach ( self::$user_ids as $user_id ) { 45 47 self::delete_user( $user_id ); 46 48 } … … 97 99 98 100 function test_wp_list_authors_feed() { 99 $url0 = get_author_feed_link( self::$user s[0] );100 $url1 = get_author_feed_link( self::$user s[1] );101 $url2 = get_author_feed_link( self::$user s[2] );101 $url0 = get_author_feed_link( self::$user_ids[0] ); 102 $url1 = get_author_feed_link( self::$user_ids[1] ); 103 $url2 = get_author_feed_link( self::$user_ids[2] ); 102 104 $expected['feed'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> (<a href="' . $url1 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> (<a href="' . $url2 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> (<a href="' . $url0 . '">link to feed</a>)</li>'; 103 105 $this->AssertEquals( $expected['feed'], wp_list_authors( array( 'echo' => false, 'feed' => 'link to feed' ) ) ); … … 105 107 106 108 function test_wp_list_authors_feed_image() { 107 $url0 = get_author_feed_link( self::$user s[0] );108 $url1 = get_author_feed_link( self::$user s[1] );109 $url2 = get_author_feed_link( self::$user s[2] );109 $url0 = get_author_feed_link( self::$user_ids[0] ); 110 $url1 = get_author_feed_link( self::$user_ids[1] ); 111 $url2 = get_author_feed_link( self::$user_ids[2] ); 110 112 $expected['feed_image'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> <a href="' . $url1 . '"><img src="http://' . WP_TESTS_DOMAIN . '/path/to/a/graphic.png" style="border: none;" /></a></li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> <a href="' . $url2 . '"><img src="http://' . WP_TESTS_DOMAIN . '/path/to/a/graphic.png" style="border: none;" /></a></li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> <a href="' . $url0 . '"><img src="http://' . WP_TESTS_DOMAIN . '/path/to/a/graphic.png" style="border: none;" /></a></li>'; 111 113 $this->AssertEquals( $expected['feed_image'], wp_list_authors( array( 'echo' => false, 'feed_image' => WP_TESTS_DOMAIN . '/path/to/a/graphic.png' ) ) ); … … 116 118 */ 117 119 function test_wp_list_authors_feed_type() { 118 $url0 = get_author_feed_link( self::$user s[0], 'atom' );119 $url1 = get_author_feed_link( self::$user s[1], 'atom' );120 $url2 = get_author_feed_link( self::$user s[2], 'atom' );120 $url0 = get_author_feed_link( self::$user_ids[0], 'atom' ); 121 $url1 = get_author_feed_link( self::$user_ids[1], 'atom' ); 122 $url2 = get_author_feed_link( self::$user_ids[2], 'atom' ); 121 123 $expected['feed_type'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> (<a href="' . $url1 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> (<a href="' . $url2 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> (<a href="' . $url0 . '">link to feed</a>)</li>'; 122 124 $this->AssertEquals( $expected['feed_type'], wp_list_authors( array( 'echo' => false, 'feed' => 'link to feed', 'feed_type' => 'atom' ) ) ); -
trunk/tests/phpunit/tests/user/query.php
r35242 r35244 933 933 public function test_get_single_role_by_string_which_is_similar() { 934 934 $another_editor = self::factory()->user->create( array( 935 'user_email' => 'another_editor@another_editor.com', 936 'user_login' => 'another_editor', 935 937 'role' => 'another-editor', 936 938 ) ); -
trunk/tests/phpunit/tests/user/slashes.php
r35242 r35244 10 10 parent::setUp(); 11 11 $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); 12 $this->old_current_user = get_current_user_id(); 12 13 13 wp_set_current_user( $this->author_id ); 14 14 … … 24 24 } 25 25 26 function tearDown() {27 wp_set_current_user( $this->old_current_user );28 parent::tearDown();29 }30 31 26 /** 32 27 * Tests the controller function that expects slashed data -
trunk/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php
r35242 r35244 42 42 43 43 function test_no_editable_posts() { 44 wp_delete_post( $this->post_id );44 wp_delete_post( $this->post_id, true ); 45 45 46 46 $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'author', 'author' ) ); -
trunk/tests/phpunit/tests/xmlrpc/wp/getPage.php
r31622 r35244 22 22 ); 23 23 $this->post_id = wp_insert_post( $this->post_data ); 24 }25 26 function tearDown() {27 wp_delete_post( $this->post_id );28 parent::tearDown();29 24 } 30 25 -
trunk/tests/phpunit/tests/xmlrpc/wp/getUser.php
r25394 r35244 18 18 19 19 function tearDown() { 20 if ( is_multisite() ) 20 if ( is_multisite() ) { 21 21 revoke_super_admin( $this->administrator_id ); 22 22 } 23 23 parent::tearDown(); 24 24 }
Note: See TracChangeset
for help on using the changeset viewer.