user.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. <?php
  2. // test functions in wp-includes/user.php
  3. /**
  4. * @group user
  5. */
  6. class Tests_User extends WP_UnitTestCase {
  7. function test_get_users_of_blog() {
  8. // add one of each user role
  9. $nusers = array();
  10. foreach ( array('administrator', 'editor', 'author', 'contributor', 'subscriber' ) as $role ) {
  11. $id = $this->factory->user->create( array( 'role' => $role ) );
  12. $nusers[ $id ] = $id;
  13. }
  14. $user_list = get_users();
  15. // find the role of each user as returned by get_users_of_blog
  16. $found = array();
  17. foreach ( $user_list as $user ) {
  18. // only include the users we just created - there might be some others that existed previously
  19. if ( isset( $nusers[$user->ID] ) ) {
  20. $found[ $user->ID] = $user->ID;
  21. }
  22. }
  23. // make sure every user we created was returned
  24. $this->assertEquals($nusers, $found);
  25. }
  26. // simple get/set tests for user_option functions
  27. function test_user_option() {
  28. $key = rand_str();
  29. $val = rand_str();
  30. $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
  31. // get an option that doesn't exist
  32. $this->assertFalse(get_user_option($key, $user_id));
  33. // set and get
  34. update_user_option( $user_id, $key, $val );
  35. $this->assertEquals( $val, get_user_option($key, $user_id) );
  36. // change and get again
  37. $val2 = rand_str();
  38. update_user_option( $user_id, $key, $val2 );
  39. $this->assertEquals( $val2, get_user_option($key, $user_id) );
  40. }
  41. // simple tests for usermeta functions
  42. function test_usermeta() {
  43. $key = rand_str();
  44. $val = rand_str();
  45. $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
  46. // get a meta key that doesn't exist
  47. $this->assertEquals( '', get_user_meta($user_id, $key, true));
  48. // set and get
  49. update_user_meta( $user_id, $key, $val );
  50. $this->assertEquals( $val, get_user_meta($user_id, $key, true) );
  51. // change and get again
  52. $val2 = rand_str();
  53. update_user_meta( $user_id, $key, $val2 );
  54. $this->assertEquals( $val2, get_user_meta($user_id, $key, true) );
  55. // delete and get
  56. delete_user_meta( $user_id, $key );
  57. $this->assertEquals( '', get_user_meta($user_id, $key, true) );
  58. // delete by key AND value
  59. update_user_meta( $user_id, $key, $val );
  60. // incorrect key: key still exists
  61. delete_user_meta( $user_id, $key, rand_str() );
  62. $this->assertEquals( $val, get_user_meta($user_id, $key, true) );
  63. // correct key: deleted
  64. delete_user_meta( $user_id, $key, $val );
  65. $this->assertEquals( '', get_user_meta($user_id, $key, true) );
  66. }
  67. // test usermeta functions in array mode
  68. function test_usermeta_array() {
  69. // some values to set
  70. $vals = array(
  71. rand_str() => 'val-'.rand_str(),
  72. rand_str() => 'val-'.rand_str(),
  73. rand_str() => 'val-'.rand_str(),
  74. );
  75. $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
  76. // there is already some stuff in the array
  77. $this->assertTrue(is_array(get_user_meta($user_id)));
  78. foreach ($vals as $k=>$v)
  79. update_user_meta( $user_id, $k, $v );
  80. // get the complete usermeta array
  81. $out = get_user_meta($user_id);
  82. // for reasons unclear, the resulting array is indexed numerically; meta keys are not included anywhere.
  83. // so we'll just check to make sure our values are included somewhere.
  84. foreach ($vals as $k=>$v)
  85. $this->assertTrue(isset($out[$k]) && $out[$k][0] == $v);
  86. // delete one key and check again
  87. $keys = array_keys( $vals );
  88. $key_to_delete = array_pop( $keys );
  89. delete_user_meta($user_id, $key_to_delete);
  90. $out = get_user_meta($user_id);
  91. // make sure that key is excluded from the results
  92. foreach ($vals as $k=>$v) {
  93. if ($k == $key_to_delete)
  94. $this->assertFalse(isset($out[$k]));
  95. else
  96. $this->assertTrue(isset($out[$k]) && $out[$k][0] == $v);
  97. }
  98. }
  99. // Test property magic functions for property get/set/isset.
  100. function test_user_properties() {
  101. $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
  102. $user = new WP_User( $user_id );
  103. foreach ( $user->data as $key => $data ) {
  104. $this->assertEquals( $data, $user->$key );
  105. }
  106. $this->assertTrue( isset( $user->$key ) );
  107. $this->assertFalse( isset( $user->fooooooooo ) );
  108. $user->$key = 'foo';
  109. $this->assertEquals( 'foo', $user->$key );
  110. $this->assertEquals( 'foo', $user->data->$key ); // This will fail with WP < 3.3
  111. foreach ( (array) $user as $key => $value ) {
  112. $this->assertEquals( $value, $user->$key );
  113. }
  114. }
  115. /**
  116. * Test the magic __unset method
  117. *
  118. * @ticket 20043
  119. */
  120. public function test_user_unset() {
  121. // New user
  122. $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
  123. $user = new WP_User( $user_id );
  124. // Test custom fields
  125. $user->customField = 123;
  126. $this->assertEquals( $user->customField, 123 );
  127. unset( $user->customField );
  128. $this->assertFalse( isset( $user->customField ) );
  129. return $user;
  130. }
  131. /**
  132. * @depends test_user_unset
  133. * @expectedDeprecated WP_User->id
  134. * @ticket 20043
  135. */
  136. function test_user_unset_lowercase_id( $user ) {
  137. // Test 'id' (lowercase)
  138. unset( $user->id );
  139. return $user;
  140. }
  141. /**
  142. * @depends test_user_unset_lowercase_id
  143. * @ticket 20043
  144. */
  145. function test_user_unset_uppercase_id( $user ) {
  146. // Test 'ID'
  147. $this->assertNotEmpty( $user->ID );
  148. unset( $user->ID );
  149. $this->assertEmpty( $user->ID );
  150. }
  151. // Test meta property magic functions for property get/set/isset.
  152. function test_user_meta_properties() {
  153. global $wpdb;
  154. $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
  155. $user = new WP_User( $user_id );
  156. update_user_option( $user_id, 'foo', 'foo', true );
  157. $this->assertTrue( isset( $user->foo ) );
  158. $this->assertEquals( 'foo', $user->foo );
  159. }
  160. /**
  161. * @expectedDeprecated WP_User->id
  162. */
  163. function test_id_property_back_compat() {
  164. $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
  165. $user = new WP_User( $user_id );
  166. $this->assertTrue( isset( $user->id ) );
  167. $this->assertEquals( $user->ID, $user->id );
  168. $user->id = 1234;
  169. $this->assertEquals( $user->ID, $user->id );
  170. }
  171. /**
  172. * ticket 19265
  173. */
  174. function test_user_level_property_back_compat() {
  175. $roles = array(
  176. 'administrator' => 10,
  177. 'editor' => 7,
  178. 'author' => 2,
  179. 'contributor' => 1,
  180. 'subscriber' => 0,
  181. );
  182. foreach ( $roles as $role => $level ) {
  183. $user_id = $this->factory->user->create( array( 'role' => $role ) );
  184. $user = new WP_User( $user_id );
  185. $this->assertTrue( isset( $user->user_level ) );
  186. $this->assertEquals( $level, $user->user_level );
  187. }
  188. }
  189. function test_construction() {
  190. $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
  191. $user = new WP_User( $user_id );
  192. $this->assertInstanceOf( 'WP_User', $user );
  193. $this->assertEquals( $user_id, $user->ID );
  194. $user2 = new WP_User( 0, $user->user_login );
  195. $this->assertInstanceOf( 'WP_User', $user2 );
  196. $this->assertEquals( $user_id, $user2->ID );
  197. $this->assertEquals( $user->user_login, $user2->user_login );
  198. $user3 = new WP_User();
  199. $this->assertInstanceOf( 'WP_User', $user3 );
  200. $this->assertEquals( 0, $user3->ID );
  201. $this->assertFalse( isset( $user3->user_login ) );
  202. $user3->init( $user->data );
  203. $this->assertEquals( $user_id, $user3->ID );
  204. $user4 = new WP_User( $user->user_login );
  205. $this->assertInstanceOf( 'WP_User', $user4 );
  206. $this->assertEquals( $user_id, $user4->ID );
  207. $this->assertEquals( $user->user_login, $user4->user_login );
  208. $user5 = new WP_User( null, $user->user_login );
  209. $this->assertInstanceOf( 'WP_User', $user5 );
  210. $this->assertEquals( $user_id, $user5->ID );
  211. $this->assertEquals( $user->user_login, $user5->user_login );
  212. $user6 = new WP_User( $user );
  213. $this->assertInstanceOf( 'WP_User', $user6 );
  214. $this->assertEquals( $user_id, $user6->ID );
  215. $this->assertEquals( $user->user_login, $user6->user_login );
  216. $user7 = new WP_User( $user->data );
  217. $this->assertInstanceOf( 'WP_User', $user7 );
  218. $this->assertEquals( $user_id, $user7->ID );
  219. $this->assertEquals( $user->user_login, $user7->user_login );
  220. }
  221. function test_get() {
  222. $user_id = $this->factory->user->create( array(
  223. 'role' => 'author',
  224. 'user_login' => 'test_wp_user_get',
  225. 'user_pass' => 'password',
  226. 'user_email' => 'test@test.com',
  227. ) );
  228. $user = new WP_User( $user_id );
  229. $this->assertEquals( 'test_wp_user_get', $user->get( 'user_login' ) );
  230. $this->assertEquals( 'test@test.com', $user->get( 'user_email' ) );
  231. $this->assertEquals( 0, $user->get( 'use_ssl' ) );
  232. $this->assertEquals( '', $user->get( 'field_that_does_not_exist' ) );
  233. update_user_meta( $user_id, 'dashed-key', 'abcdefg' );
  234. $this->assertEquals( 'abcdefg', $user->get( 'dashed-key' ) );
  235. }
  236. function test_has_prop() {
  237. $user_id = $this->factory->user->create( array(
  238. 'role' => 'author',
  239. 'user_login' => 'test_wp_user_has_prop',
  240. 'user_pass' => 'password',
  241. 'user_email' => 'test2@test.com',
  242. ) );
  243. $user = new WP_User( $user_id );
  244. $this->assertTrue( $user->has_prop( 'user_email') );
  245. $this->assertTrue( $user->has_prop( 'use_ssl' ) );
  246. $this->assertFalse( $user->has_prop( 'field_that_does_not_exist' ) );
  247. update_user_meta( $user_id, 'dashed-key', 'abcdefg' );
  248. $this->assertTrue( $user->has_prop( 'dashed-key' ) );
  249. }
  250. function test_update_user() {
  251. $user_id = $this->factory->user->create( array(
  252. 'role' => 'author',
  253. 'user_login' => 'test_wp_update_user',
  254. 'user_pass' => 'password',
  255. 'user_email' => 'test3@test.com',
  256. ) );
  257. $user = new WP_User( $user_id );
  258. update_user_meta( $user_id, 'description', 'about me' );
  259. $this->assertEquals( 'about me', $user->get( 'description' ) );
  260. $user_data = array( 'ID' => $user_id, 'display_name' => 'test user' );
  261. wp_update_user( $user_data );
  262. $user = new WP_User( $user_id );
  263. $this->assertEquals( 'test user', $user->get( 'display_name' ) );
  264. // Make sure there is no collateral damage to fields not in $user_data
  265. $this->assertEquals( 'about me', $user->get( 'description' ) );
  266. // Pass as stdClass
  267. $user_data = array( 'ID' => $user_id, 'display_name' => 'a test user' );
  268. wp_update_user( (object) $user_data );
  269. $user = new WP_User( $user_id );
  270. $this->assertEquals( 'a test user', $user->get( 'display_name' ) );
  271. // Pass as WP_User
  272. $user = new WP_User( $user_id );
  273. $user->display_name = 'some test user';
  274. wp_update_user( $user );
  275. $user = new WP_User( $user_id );
  276. $this->assertEquals( 'some test user', $user->get( 'display_name' ) );
  277. // Test update of fields in _get_additional_user_keys()
  278. $user_data = array( 'ID' => $user_id, 'use_ssl' => 1, 'show_admin_bar_front' => 1,
  279. 'rich_editing' => 1, 'first_name' => 'first', 'last_name' => 'last',
  280. 'nickname' => 'nick', 'comment_shortcuts' => 1, 'admin_color' => 'classic',
  281. 'description' => 'describe' );
  282. wp_update_user( $user_data );
  283. $user = new WP_User( $user_id );
  284. foreach ( $user_data as $key => $value )
  285. $this->assertEquals( $value, $user->get( $key ), $key );
  286. }
  287. /**
  288. * Test that usermeta cache is cleared after user deletion.
  289. *
  290. * @ticket 19500
  291. */
  292. function test_get_blogs_of_user() {
  293. // Logged out users don't have blogs.
  294. $this->assertEquals( array(), get_blogs_of_user( 0 ) );
  295. $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) );
  296. $blogs = get_blogs_of_user( $user_id );
  297. $this->assertEquals( array( 1 ), array_keys( $blogs ) );
  298. // Non-existent users don't have blogs.
  299. if ( is_multisite() )
  300. wpmu_delete_user( $user_id );
  301. else
  302. wp_delete_user( $user_id );
  303. $this->assertEquals( array(), get_blogs_of_user( $user_id ) );
  304. }
  305. /**
  306. * Test that usermeta cache is cleared after user deletion.
  307. *
  308. * @ticket 19500
  309. */
  310. function test_is_user_member_of_blog() {
  311. $old_current = get_current_user_id();
  312. $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) );
  313. wp_set_current_user( $user_id );
  314. $this->assertTrue( is_user_member_of_blog() );
  315. $this->assertTrue( is_user_member_of_blog( 0, 0 ) );
  316. $this->assertTrue( is_user_member_of_blog( 0, get_current_blog_id() ) );
  317. $this->assertTrue( is_user_member_of_blog( $user_id ) );
  318. $this->assertTrue( is_user_member_of_blog( $user_id, get_current_blog_id() ) );
  319. // Will only remove the user from the current site in multisite; this is desired
  320. // and will achieve the desired effect with is_user_member_of_blog().
  321. wp_delete_user( $user_id );
  322. $this->assertFalse( is_user_member_of_blog( $user_id ) );
  323. $this->assertFalse( is_user_member_of_blog( $user_id, get_current_blog_id() ) );
  324. wp_set_current_user( $old_current );
  325. }
  326. /**
  327. * ticket 19595
  328. */
  329. function test_global_userdata() {
  330. global $userdata, $wpdb;
  331. $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) );
  332. wp_set_current_user( $user_id );
  333. $this->assertNotEmpty( $userdata );
  334. $this->assertInstanceOf( 'WP_User', $userdata );
  335. $this->assertEquals( $userdata->ID, $user_id );
  336. $prefix = $wpdb->get_blog_prefix();
  337. $cap_key = $prefix . 'capabilities';
  338. $this->assertTrue( isset( $userdata->$cap_key ) );
  339. }
  340. /**
  341. * ticket 19769
  342. */
  343. function test_global_userdata_is_null_when_logged_out() {
  344. global $userdata;
  345. wp_set_current_user(0);
  346. $this->assertNull( $userdata );
  347. }
  348. function test_exists() {
  349. $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
  350. $user = new WP_User( $user_id );
  351. $this->assertTrue( $user->exists() );
  352. $user = new WP_User( 123456789 );
  353. $this->assertFalse( $user->exists() );
  354. $user = new WP_User( 0 );
  355. $this->assertFalse( $user->exists() );
  356. }
  357. function test_global_authordata() {
  358. global $authordata, $id;
  359. $old_post_id = $id;
  360. $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
  361. $user = new WP_User( $user_id );
  362. $post = array(
  363. 'post_author' => $user_id,
  364. 'post_status' => 'publish',
  365. 'post_content' => rand_str(),
  366. 'post_title' => rand_str(),
  367. 'post_type' => 'post'
  368. );
  369. // insert a post and make sure the ID is ok
  370. $post_id = wp_insert_post( $post );
  371. $this->assertTrue( is_numeric( $post_id ) );
  372. setup_postdata( get_post( $post_id ) );
  373. $this->assertNotEmpty( $authordata );
  374. $this->assertInstanceOf( 'WP_User', $authordata );
  375. $this->assertEquals( $authordata->ID, $user_id );
  376. if ( $old_post_id )
  377. setup_postdata( get_post( $old_post_id ) );
  378. }
  379. function test_delete_user() {
  380. $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
  381. $user = new WP_User( $user_id );
  382. $post = array(
  383. 'post_author' => $user_id,
  384. 'post_status' => 'publish',
  385. 'post_content' => rand_str(),
  386. 'post_title' => rand_str(),
  387. 'post_type' => 'post',
  388. );
  389. // insert a post and make sure the ID is ok
  390. $post_id = wp_insert_post($post);
  391. $this->assertTrue(is_numeric($post_id));
  392. $this->assertTrue($post_id > 0);
  393. $post = get_post( $post_id );
  394. $this->assertEquals( $post_id, $post->ID );
  395. $post = array(
  396. 'post_author' => $user_id,
  397. 'post_status' => 'publish',
  398. 'post_content' => rand_str(),
  399. 'post_title' => rand_str(),
  400. 'post_type' => 'nav_menu_item',
  401. );
  402. // insert a post and make sure the ID is ok
  403. $nav_id = wp_insert_post($post);
  404. $this->assertTrue(is_numeric($nav_id));
  405. $this->assertTrue($nav_id > 0);
  406. $post = get_post( $nav_id );
  407. $this->assertEquals( $nav_id, $post->ID );
  408. wp_delete_user( $user_id );
  409. $user = new WP_User( $user_id );
  410. if ( is_multisite() )
  411. $this->assertTrue( $user->exists() );
  412. else
  413. $this->assertFalse( $user->exists() );
  414. $this->assertNotNull( get_post( $post_id ) );
  415. $this->assertEquals( 'trash', get_post( $post_id )->post_status );
  416. // nav_menu_item is delete_with_user = false so the nav post should remain published.
  417. $this->assertNotNull( get_post( $nav_id ) );
  418. $this->assertEquals( 'publish', get_post( $nav_id )->post_status );
  419. wp_delete_post( $nav_id, true );
  420. $this->assertNull( get_post( $nav_id ) );
  421. wp_delete_post( $post_id, true );
  422. $this->assertNull( get_post( $post_id ) );
  423. }
  424. /**
  425. * @ticket 13317
  426. */
  427. function test_get_userdata() {
  428. $this->assertFalse( get_userdata( 0 ) );
  429. $this->assertFalse( get_userdata( '0' ) );
  430. $this->assertFalse( get_userdata( 'string' ) );
  431. $this->assertFalse( get_userdata( array( 'array' ) ) );
  432. }
  433. function test_user_get_data_by_id() {
  434. $user_id = $this->factory->user->create();
  435. $user = WP_User::get_data_by( 'id', $user_id );
  436. $this->assertInstanceOf( 'stdClass', $user );
  437. $this->assertEquals( $user_id, $user->ID );
  438. // @ticket 23480
  439. $user = WP_User::get_data_by( 'id', -1 );
  440. $this->assertEquals( false, $user );
  441. $user = WP_User::get_data_by( 'id', 0 );
  442. $this->assertEquals( false, $user );
  443. $user = WP_User::get_data_by( 'id', null );
  444. $this->assertEquals( false, $user );
  445. $user = WP_User::get_data_by( 'id', '' );
  446. $this->assertEquals( false, $user );
  447. $user = WP_User::get_data_by( 'id', false );
  448. $this->assertEquals( false, $user );
  449. $user = WP_User::get_data_by( 'id', @$user->user_nicename );
  450. $this->assertEquals( false, $user );
  451. $user = WP_User::get_data_by( 'id', 99999 );
  452. $this->assertEquals( false, $user );
  453. }
  454. /**
  455. * @ticket 20447
  456. */
  457. function test_wp_delete_user_reassignment_clears_post_caches() {
  458. $user_id = $this->factory->user->create();
  459. $reassign = $this->factory->user->create();
  460. $post_id = $this->factory->post->create( array( 'post_author' => $user_id ) );
  461. get_post( $post_id ); // Ensure this post is in the cache.
  462. wp_delete_user( $user_id, $reassign );
  463. $post = get_post( $post_id );
  464. $this->assertEquals( $reassign, $post->post_author );
  465. }
  466. /**
  467. * @ticket 21431
  468. */
  469. function test_count_many_users_posts() {
  470. $user_id_a = $this->factory->user->create( array( 'role' => 'author' ) );
  471. $user_id_b = $this->factory->user->create( array( 'role' => 'author' ) );
  472. $post_id_a = $this->factory->post->create( array( 'post_author' => $user_id_a ) );
  473. $post_id_b = $this->factory->post->create( array( 'post_author' => $user_id_b ) );
  474. $post_id_c = $this->factory->post->create( array( 'post_author' => $user_id_b, 'post_status' => 'private' ) );
  475. wp_set_current_user( $user_id_a );
  476. $counts = count_many_users_posts( array( $user_id_a, $user_id_b), 'post', false );
  477. $this->assertEquals( 1, $counts[$user_id_a] );
  478. $this->assertEquals( 1, $counts[$user_id_b] );
  479. $counts = count_many_users_posts( array( $user_id_a, $user_id_b), 'post', true );
  480. $this->assertEquals( 1, $counts[$user_id_a] );
  481. $this->assertEquals( 1, $counts[$user_id_b] );
  482. wp_set_current_user( $user_id_b );
  483. $counts = count_many_users_posts( array( $user_id_a, $user_id_b), 'post', false );
  484. $this->assertEquals( 1, $counts[$user_id_a] );
  485. $this->assertEquals( 2, $counts[$user_id_b] );
  486. $counts = count_many_users_posts( array( $user_id_a, $user_id_b), 'post', true );
  487. $this->assertEquals( 1, $counts[$user_id_a] );
  488. $this->assertEquals( 1, $counts[$user_id_b] );
  489. }
  490. /**
  491. * @ticket 22858
  492. */
  493. function test_wp_update_user_on_nonexistent_users() {
  494. $user_id = 1;
  495. // Find me a non-existent user ID.
  496. while ( get_userdata( $user_id ) )
  497. ++$user_id;
  498. // If this test fails, it will error out for calling the to_array() method on a non-object.
  499. $this->assertInstanceOf( 'WP_Error', wp_update_user( array( 'ID' => $user_id ) ) );
  500. }
  501. }