| 1 | Index: tests/option/blogOption.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- tests/option/blogOption.php (revision 935) |
|---|
| 4 | +++ tests/option/blogOption.php (working copy) |
|---|
| 5 | @@ -41,5 +41,97 @@ |
|---|
| 6 | $this->assertFalse( get_blog_option( 1, $key2 ) ); |
|---|
| 7 | $this->assertFalse( get_option( $key2 ) ); // check get_option() |
|---|
| 8 | } |
|---|
| 9 | + |
|---|
| 10 | + function test_from_same_site_with_null_blog_id() { |
|---|
| 11 | + $key = rand_str(); |
|---|
| 12 | + $key2 = rand_str(); |
|---|
| 13 | + $value = rand_str(); |
|---|
| 14 | + $value2 = rand_str(); |
|---|
| 15 | + |
|---|
| 16 | + $this->assertFalse( get_blog_option( null, 'doesnotexist' ) ); |
|---|
| 17 | + $this->assertFalse( get_option( 'doesnotexist' ) ); // check get_option() |
|---|
| 18 | + |
|---|
| 19 | + $this->assertTrue( add_blog_option( null, $key, $value ) ); |
|---|
| 20 | + // Assert all values of $blog_id that means the current or main blog (the same here). |
|---|
| 21 | + $this->assertEquals( $value, get_blog_option( null, $key ) ); |
|---|
| 22 | + $this->assertEquals( $value, get_blog_option( null, $key ) ); |
|---|
| 23 | + $this->assertEquals( $value, get_option( $key ) ); // check get_option() |
|---|
| 24 | + |
|---|
| 25 | + $this->assertFalse( add_blog_option( null, $key, $value ) ); // Already exists |
|---|
| 26 | + $this->assertFalse( update_blog_option( null, $key, $value ) ); // Value is the same |
|---|
| 27 | + $this->assertTrue( update_blog_option( null, $key, $value2 ) ); |
|---|
| 28 | + $this->assertEquals( $value2, get_blog_option( null, $key ) ); |
|---|
| 29 | + $this->assertEquals( $value2, get_option( $key ) ); // check get_option() |
|---|
| 30 | + $this->assertFalse( add_blog_option( null, $key, $value ) ); |
|---|
| 31 | + $this->assertEquals( $value2, get_blog_option( null, $key ) ); |
|---|
| 32 | + $this->assertEquals( $value2, get_option( $key ) ); // check get_option() |
|---|
| 33 | + |
|---|
| 34 | + $this->assertTrue( delete_blog_option( null, $key ) ); |
|---|
| 35 | + $this->assertFalse( get_blog_option( null, $key ) ); |
|---|
| 36 | + $this->assertFalse( get_option( $key ) ); // check get_option() |
|---|
| 37 | + $this->assertFalse( delete_blog_option( null, $key ) ); |
|---|
| 38 | + $this->assertTrue( update_blog_option( null, $key2, $value2 ) ); |
|---|
| 39 | + $this->assertEquals( $value2, get_blog_option( null, $key2 ) ); |
|---|
| 40 | + $this->assertEquals( $value2, get_option( $key2 ) ); // check get_option() |
|---|
| 41 | + $this->assertTrue( delete_blog_option( null, $key2 ) ); |
|---|
| 42 | + $this->assertFalse( get_blog_option( null, $key2 ) ); |
|---|
| 43 | + $this->assertFalse( get_option( $key2 ) ); // check get_option() |
|---|
| 44 | + } |
|---|
| 45 | + |
|---|
| 46 | + function test_with_another_site() { |
|---|
| 47 | + global $current_site, $base; |
|---|
| 48 | + |
|---|
| 49 | + $domain = 'blogoptiontest'; |
|---|
| 50 | + |
|---|
| 51 | + if ( is_subdomain_install() ) { |
|---|
| 52 | + $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain ); |
|---|
| 53 | + $path = $base; |
|---|
| 54 | + } else { |
|---|
| 55 | + $newdomain = $current_site->domain; |
|---|
| 56 | + $path = $base . $domain . '/'; |
|---|
| 57 | + } |
|---|
| 58 | + |
|---|
| 59 | + $email = 'foo@foo.foo'; |
|---|
| 60 | + $password = wp_generate_password( 12, false ); |
|---|
| 61 | + $user_id = wpmu_create_user( $domain, $password, $email ); |
|---|
| 62 | + $this->assertInternalType( 'integer', $user_id ); |
|---|
| 63 | + |
|---|
| 64 | + $blog_id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id ); |
|---|
| 65 | + $this->assertInternalType( 'integer', $blog_id ); |
|---|
| 66 | + |
|---|
| 67 | + $key = rand_str(); |
|---|
| 68 | + $key2 = rand_str(); |
|---|
| 69 | + $value = rand_str(); |
|---|
| 70 | + $value2 = rand_str(); |
|---|
| 71 | + |
|---|
| 72 | + $this->assertFalse( get_blog_option( $blog_id, 'doesnotexist' ) ); |
|---|
| 73 | + $this->assertFalse( get_option( 'doesnotexist' ) ); // check get_option() |
|---|
| 74 | + |
|---|
| 75 | + $this->assertTrue( add_blog_option( $blog_id, $key, $value ) ); |
|---|
| 76 | + // Assert all values of $blog_id that means the current or main blog (the same here). |
|---|
| 77 | + $this->assertEquals( $value, get_blog_option( $blog_id, $key ) ); |
|---|
| 78 | + $this->assertEquals( $value, get_blog_option( "$blog_id", $key ) ); |
|---|
| 79 | + //$this->assertEquals( $value, get_option( $key ) ); // check get_option() |
|---|
| 80 | + |
|---|
| 81 | + $this->assertFalse( add_blog_option( $blog_id, $key, $value ) ); // Already exists |
|---|
| 82 | + $this->assertFalse( update_blog_option( $blog_id, $key, $value ) ); // Value is the same |
|---|
| 83 | + $this->assertTrue( update_blog_option( $blog_id, $key, $value2 ) ); |
|---|
| 84 | + $this->assertEquals( $value2, get_blog_option( $blog_id, $key ) ); |
|---|
| 85 | + //$this->assertEquals( $value2, get_option( $key ) ); // check get_option() |
|---|
| 86 | + $this->assertFalse( add_blog_option( $blog_id, $key, $value ) ); |
|---|
| 87 | + $this->assertEquals( $value2, get_blog_option( $blog_id, $key ) ); |
|---|
| 88 | + //$this->assertEquals( $value2, get_option( $key ) ); // check get_option() |
|---|
| 89 | + |
|---|
| 90 | + $this->assertTrue( delete_blog_option( $blog_id, $key ) ); |
|---|
| 91 | + $this->assertFalse( get_blog_option( $blog_id, $key ) ); |
|---|
| 92 | + //$this->assertFalse( get_option( $key ) ); // check get_option() |
|---|
| 93 | + $this->assertFalse( delete_blog_option( $blog_id, $key ) ); |
|---|
| 94 | + $this->assertTrue( update_blog_option( $blog_id, $key2, $value2 ) ); |
|---|
| 95 | + $this->assertEquals( $value2, get_blog_option( $blog_id, $key2 ) ); |
|---|
| 96 | + //$this->assertEquals( $value2, get_option( $key2 ) ); // check get_option() |
|---|
| 97 | + $this->assertTrue( delete_blog_option( $blog_id, $key2 ) ); |
|---|
| 98 | + $this->assertFalse( get_blog_option( $blog_id, $key2 ) ); |
|---|
| 99 | + //$this->assertFalse( get_option( $key2 ) ); // check get_option() |
|---|
| 100 | + } |
|---|
| 101 | } |
|---|
| 102 | endif; |
|---|
| 103 | \ No newline at end of file |
|---|