|
@@ 1127-1142 (lines=16) @@
|
| 1124 |
|
* |
| 1125 |
|
* @since 9.8.0 |
| 1126 |
|
*/ |
| 1127 |
|
public function test_get_purchase_token() { |
| 1128 |
|
$purchase_token = '1ApurchaseToken1'; |
| 1129 |
|
Jetpack_Options::update_option( 'id', 1234 ); |
| 1130 |
|
Jetpack_Options::update_option( 'purchase_token', $purchase_token ); |
| 1131 |
|
|
| 1132 |
|
// Create a user and set it up as current. |
| 1133 |
|
$user = $this->create_and_get_user( 'administrator' ); |
| 1134 |
|
wp_set_current_user( $user->ID ); |
| 1135 |
|
|
| 1136 |
|
// Fetch purchase token. |
| 1137 |
|
$response = $this->create_and_get_request( 'purchase-token', array(), 'GET' ); |
| 1138 |
|
|
| 1139 |
|
// Confirm purchase token exists. |
| 1140 |
|
$this->assertResponseStatus( 200, $response ); |
| 1141 |
|
$this->assertEquals( $purchase_token, $response->get_data() ); |
| 1142 |
|
} |
| 1143 |
|
|
| 1144 |
|
/** |
| 1145 |
|
* Test fetching a site's purchase token when no site is registered. |
|
@@ 1149-1163 (lines=15) @@
|
| 1146 |
|
* |
| 1147 |
|
* @since 9.8.0 |
| 1148 |
|
*/ |
| 1149 |
|
public function test_get_purchase_token_no_site_registered() { |
| 1150 |
|
$purchase_token = '1ApurchaseToken1'; |
| 1151 |
|
Jetpack_Options::update_option( 'purchase_token', $purchase_token ); |
| 1152 |
|
|
| 1153 |
|
// Create a user and set it up as current. |
| 1154 |
|
$user = $this->create_and_get_user( 'administrator' ); |
| 1155 |
|
wp_set_current_user( $user->ID ); |
| 1156 |
|
|
| 1157 |
|
// Fetch purchase token. |
| 1158 |
|
$response = $this->create_and_get_request( 'purchase-token', array(), 'GET' ); |
| 1159 |
|
|
| 1160 |
|
// Confirm that the request failed. |
| 1161 |
|
$this->assertResponseStatus( 500, $response ); |
| 1162 |
|
$this->assertResponseData( array( 'code' => 'site_not_registered' ), $response ); |
| 1163 |
|
} |
| 1164 |
|
|
| 1165 |
|
/** |
| 1166 |
|
* Test deleting a site's purchase token. |
|
@@ 1205-1219 (lines=15) @@
|
| 1202 |
|
* |
| 1203 |
|
* @since 9.8.0 |
| 1204 |
|
*/ |
| 1205 |
|
public function test_delete_purchase_token_no_site_registered() { |
| 1206 |
|
$purchase_token = '1ApurchaseToken1'; |
| 1207 |
|
Jetpack_Options::update_option( 'purchase_token', $purchase_token ); |
| 1208 |
|
|
| 1209 |
|
// Create a user and set it up as current. |
| 1210 |
|
$user = $this->create_and_get_user( 'administrator' ); |
| 1211 |
|
wp_set_current_user( $user->ID ); |
| 1212 |
|
|
| 1213 |
|
// Fetch purchase token. |
| 1214 |
|
$response = $this->create_and_get_request( 'purchase-token', array(), 'DELETE' ); |
| 1215 |
|
|
| 1216 |
|
// Confirm that the request failed. |
| 1217 |
|
$this->assertResponseStatus( 500, $response ); |
| 1218 |
|
$this->assertResponseData( array( 'code' => 'site_not_registered' ), $response ); |
| 1219 |
|
} |
| 1220 |
|
} // class end |
| 1221 |
|
|