| 44 | |
| 45 | function test_from_same_site_with_null_blog_id() { |
| 46 | $key = rand_str(); |
| 47 | $key2 = rand_str(); |
| 48 | $value = rand_str(); |
| 49 | $value2 = rand_str(); |
| 50 | |
| 51 | $this->assertFalse( get_blog_option( null, 'doesnotexist' ) ); |
| 52 | $this->assertFalse( get_option( 'doesnotexist' ) ); // check get_option() |
| 53 | |
| 54 | $this->assertTrue( add_blog_option( null, $key, $value ) ); |
| 55 | // Assert all values of $blog_id that means the current or main blog (the same here). |
| 56 | $this->assertEquals( $value, get_blog_option( null, $key ) ); |
| 57 | $this->assertEquals( $value, get_blog_option( null, $key ) ); |
| 58 | $this->assertEquals( $value, get_option( $key ) ); // check get_option() |
| 59 | |
| 60 | $this->assertFalse( add_blog_option( null, $key, $value ) ); // Already exists |
| 61 | $this->assertFalse( update_blog_option( null, $key, $value ) ); // Value is the same |
| 62 | $this->assertTrue( update_blog_option( null, $key, $value2 ) ); |
| 63 | $this->assertEquals( $value2, get_blog_option( null, $key ) ); |
| 64 | $this->assertEquals( $value2, get_option( $key ) ); // check get_option() |
| 65 | $this->assertFalse( add_blog_option( null, $key, $value ) ); |
| 66 | $this->assertEquals( $value2, get_blog_option( null, $key ) ); |
| 67 | $this->assertEquals( $value2, get_option( $key ) ); // check get_option() |
| 68 | |
| 69 | $this->assertTrue( delete_blog_option( null, $key ) ); |
| 70 | $this->assertFalse( get_blog_option( null, $key ) ); |
| 71 | $this->assertFalse( get_option( $key ) ); // check get_option() |
| 72 | $this->assertFalse( delete_blog_option( null, $key ) ); |
| 73 | $this->assertTrue( update_blog_option( null, $key2, $value2 ) ); |
| 74 | $this->assertEquals( $value2, get_blog_option( null, $key2 ) ); |
| 75 | $this->assertEquals( $value2, get_option( $key2 ) ); // check get_option() |
| 76 | $this->assertTrue( delete_blog_option( null, $key2 ) ); |
| 77 | $this->assertFalse( get_blog_option( null, $key2 ) ); |
| 78 | $this->assertFalse( get_option( $key2 ) ); // check get_option() |
| 79 | } |
| 80 | |
| 81 | function test_with_another_site() { |
| 82 | global $current_site, $base; |
| 83 | |
| 84 | $domain = 'blogoptiontest'; |
| 85 | |
| 86 | if ( is_subdomain_install() ) { |
| 87 | $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain ); |
| 88 | $path = $base; |
| 89 | } else { |
| 90 | $newdomain = $current_site->domain; |
| 91 | $path = $base . $domain . '/'; |
| 92 | } |
| 93 | |
| 94 | $email = 'foo@foo.foo'; |
| 95 | $password = wp_generate_password( 12, false ); |
| 96 | $user_id = wpmu_create_user( $domain, $password, $email ); |
| 97 | $this->assertInternalType( 'integer', $user_id ); |
| 98 | |
| 99 | $blog_id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id ); |
| 100 | $this->assertInternalType( 'integer', $blog_id ); |
| 101 | |
| 102 | $key = rand_str(); |
| 103 | $key2 = rand_str(); |
| 104 | $value = rand_str(); |
| 105 | $value2 = rand_str(); |
| 106 | |
| 107 | $this->assertFalse( get_blog_option( $blog_id, 'doesnotexist' ) ); |
| 108 | $this->assertFalse( get_option( 'doesnotexist' ) ); // check get_option() |
| 109 | |
| 110 | $this->assertTrue( add_blog_option( $blog_id, $key, $value ) ); |
| 111 | // Assert all values of $blog_id that means the current or main blog (the same here). |
| 112 | $this->assertEquals( $value, get_blog_option( $blog_id, $key ) ); |
| 113 | $this->assertEquals( $value, get_blog_option( "$blog_id", $key ) ); |
| 114 | //$this->assertEquals( $value, get_option( $key ) ); // check get_option() |
| 115 | |
| 116 | $this->assertFalse( add_blog_option( $blog_id, $key, $value ) ); // Already exists |
| 117 | $this->assertFalse( update_blog_option( $blog_id, $key, $value ) ); // Value is the same |
| 118 | $this->assertTrue( update_blog_option( $blog_id, $key, $value2 ) ); |
| 119 | $this->assertEquals( $value2, get_blog_option( $blog_id, $key ) ); |
| 120 | //$this->assertEquals( $value2, get_option( $key ) ); // check get_option() |
| 121 | $this->assertFalse( add_blog_option( $blog_id, $key, $value ) ); |
| 122 | $this->assertEquals( $value2, get_blog_option( $blog_id, $key ) ); |
| 123 | //$this->assertEquals( $value2, get_option( $key ) ); // check get_option() |
| 124 | |
| 125 | $this->assertTrue( delete_blog_option( $blog_id, $key ) ); |
| 126 | $this->assertFalse( get_blog_option( $blog_id, $key ) ); |
| 127 | //$this->assertFalse( get_option( $key ) ); // check get_option() |
| 128 | $this->assertFalse( delete_blog_option( $blog_id, $key ) ); |
| 129 | $this->assertTrue( update_blog_option( $blog_id, $key2, $value2 ) ); |
| 130 | $this->assertEquals( $value2, get_blog_option( $blog_id, $key2 ) ); |
| 131 | //$this->assertEquals( $value2, get_option( $key2 ) ); // check get_option() |
| 132 | $this->assertTrue( delete_blog_option( $blog_id, $key2 ) ); |
| 133 | $this->assertFalse( get_blog_option( $blog_id, $key2 ) ); |
| 134 | //$this->assertFalse( get_option( $key2 ) ); // check get_option() |
| 135 | } |