includesUser.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * @group admin
  4. * @group user
  5. */
  6. class Tests_Admin_IncludesUser extends WP_UnitTestCase {
  7. /**
  8. * @ticket 42790
  9. * @dataProvider data_is_authorize_application_password_request_valid
  10. * @param array $request The request data to validate.
  11. * @param string $error_code The expected error code, empty if no error.
  12. */
  13. public function test_is_authorize_application_password_request_valid( $request, $error_code ) {
  14. $error = wp_is_authorize_application_password_request_valid( $request, get_userdata( 1 ) );
  15. if ( $error_code ) {
  16. $this->assertWPError( $error );
  17. $this->assertEquals( $error_code, $error->get_error_code() );
  18. } else {
  19. $this->assertNotWPError( $error );
  20. }
  21. }
  22. public function data_is_authorize_application_password_request_valid() {
  23. return array(
  24. array(
  25. array(),
  26. '',
  27. ),
  28. array(
  29. array( 'success_url' => 'http://example.org' ),
  30. 'invalid_redirect_scheme',
  31. ),
  32. array(
  33. array( 'reject_url' => 'http://example.org' ),
  34. 'invalid_redirect_scheme',
  35. ),
  36. array(
  37. array( 'success_url' => 'https://example.org' ),
  38. '',
  39. ),
  40. array(
  41. array( 'reject_url' => 'https://example.org' ),
  42. '',
  43. ),
  44. array(
  45. array( 'success_url' => 'wordpress://example' ),
  46. '',
  47. ),
  48. array(
  49. array( 'reject_url' => 'wordpress://example' ),
  50. '',
  51. ),
  52. );
  53. }
  54. }