summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/phpunit/tests/media.php47
-rw-r--r--tests/phpunit/tests/rest-api/rest-application-passwords-controller.php43
-rw-r--r--tests/qunit/fixtures/wp-api-generated.js26
3 files changed, 114 insertions, 2 deletions
diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php
index a1e70c2ff1..902c704b39 100644
--- a/tests/phpunit/tests/media.php
+++ b/tests/phpunit/tests/media.php
@@ -1583,6 +1583,53 @@ EOF;
$this->assertSame( $expected, $output );
}
+ /**
+ * @ticket 14110
+ */
+ public function test_wp_get_attachment_image_filter_with_height_width() {
+ $mock_action = new MockAction();
+ add_filter( 'wp_get_attachment_image_attributes', array( $mock_action, 'filter' ) );
+ wp_get_attachment_image( self::$large_id );
+ $args = $mock_action->get_args();
+ $this->assertArrayHasKey( '0', $args, 'First argument should be an array.' );
+ $this->assertArrayHasKey( '0', $args[0], 'First argument should be an array.' );
+ $this->assertArrayHasKey( 'width', $args[0][0], 'Width should be set.' );
+ $this->assertArrayHasKey( 'height', $args[0][0], 'Height should be set.' );
+ }
+
+ /**
+ * @ticket 14110
+ */
+ public function test_wp_get_attachment_image_filter_change_height_width() {
+ add_filter(
+ 'wp_get_attachment_image_attributes',
+ static function ( $args ) {
+ $args['height'] = '999';
+ $args['width'] = '999';
+ return $args;
+ }
+ );
+ $output = wp_get_attachment_image( self::$large_id );
+ $this->assertStringContainsString( 'width="999"', $output, 'Width should be changed.' );
+ $this->assertStringContainsString( 'height="999"', $output, 'Height should be changed.' );
+ }
+
+ /**
+ * @ticket 14110
+ */
+ public function test_wp_get_attachment_image_filter_unset_height_width() {
+ add_filter(
+ 'wp_get_attachment_image_attributes',
+ static function ( $args ) {
+ unset( $args['height'], $args['width'] );
+ return $args;
+ }
+ );
+ $output = wp_get_attachment_image( self::$large_id );
+ $this->assertStringContainsString( 'width="150"', $output, 'Width should not be changed.' );
+ $this->assertStringContainsString( 'height="150"', $output, 'Height should not be changed.' );
+ }
+
public function filter_wp_get_attachment_image() {
return 'Override wp_get_attachment_image';
}
diff --git a/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php b/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php
index 7a06bb006d..060a5c0912 100644
--- a/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php
@@ -848,6 +848,49 @@ class WP_Test_REST_Application_Passwords_Controller extends WP_Test_REST_Control
}
/**
+ * @ticket 53692
+ */
+ public function test_create_item_with_empty_app_id() {
+ wp_set_current_user( self::$admin );
+
+ $request = new WP_REST_Request( 'POST', '/wp/v2/users/me/application-passwords' );
+ $request->set_body_params(
+ array(
+ 'name' => 'Test',
+ 'app_id' => '',
+ )
+ );
+
+ $response = rest_get_server()->dispatch( $request );
+ $data = $response->get_data();
+
+ $this->assertSame( 201, $response->get_status() );
+ $this->assertSame( '', $data['app_id'] );
+ }
+
+ /**
+ * @ticket 53692
+ */
+ public function test_create_item_with_uuid_app_id() {
+ wp_set_current_user( self::$admin );
+
+ $uuid = wp_generate_uuid4();
+ $request = new WP_REST_Request( 'POST', '/wp/v2/users/me/application-passwords' );
+ $request->set_body_params(
+ array(
+ 'name' => 'Test',
+ 'app_id' => $uuid,
+ )
+ );
+
+ $response = rest_get_server()->dispatch( $request );
+ $data = $response->get_data();
+
+ $this->assertSame( 201, $response->get_status() );
+ $this->assertSame( $uuid, $data['app_id'] );
+ }
+
+ /**
* Checks the password response matches the expected format.
*
* @since 5.6.0
diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js
index 72c3c1dc8b..6626758a8a 100644
--- a/tests/qunit/fixtures/wp-api-generated.js
+++ b/tests/qunit/fixtures/wp-api-generated.js
@@ -10053,7 +10053,18 @@ mockedApiResponse.Schema = {
"app_id": {
"description": "A UUID provided by the application to uniquely identify it. It is recommended to use an UUID v5 with the URL or DNS namespace.",
"type": "string",
- "format": "uuid",
+ "oneOf": [
+ {
+ "type": "string",
+ "format": "uuid"
+ },
+ {
+ "type": "string",
+ "enum": [
+ ""
+ ]
+ }
+ ],
"required": false
},
"name": {
@@ -10137,7 +10148,18 @@ mockedApiResponse.Schema = {
"app_id": {
"description": "A UUID provided by the application to uniquely identify it. It is recommended to use an UUID v5 with the URL or DNS namespace.",
"type": "string",
- "format": "uuid",
+ "oneOf": [
+ {
+ "type": "string",
+ "format": "uuid"
+ },
+ {
+ "type": "string",
+ "enum": [
+ ""
+ ]
+ }
+ ],
"required": false
},
"name": {