Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add feature test for updated media image size
  • Loading branch information
ernilambar committed Feb 22, 2024
commit 2a59fca0d3a422f831ab8339dce345efdb1f537d
47 changes: 47 additions & 0 deletions features/media-image-size.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,53 @@ Feature: List image sizes
| thumbnail | 150 | 150 | hard | 1:1 |
And STDERR should be empty

@require-wp-5.3
Scenario: Basic usage with plugin which registers custom image size
Given a WP install
# Differing themes can have differing default image sizes. Let's stick to one.
And I try `wp theme install twentynineteen --activate`
And a wp-content/plugins/foo-bar.php file:
"""
<?php
/**
* Plugin Name: Foo Bar
* Plugin URI: https://example.com
* Description: Custom plugin.
* Version: 0.1.0
* Author: John Doe
* Author URI: https://johndoe.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/

add_action(
'after_setup_theme',
function () {
add_image_size( 'foo-bar-thumb', 50, 50, true );
}
);
"""
And I try `wp plugin activate foo-bar.php`

When I run `wp media image-size`
Then STDOUT should be a table containing rows:
| name | width | height | crop | ratio |
| full | | | N/A | N/A |
| 2048x2048 | 2048 | 2048 | soft | N/A |
| post-thumbnail | 1568 | 9999 | soft | N/A |
| large | 1024 | 1024 | soft | N/A |
| medium_large | 768 | 0 | soft | N/A |
| medium | 300 | 300 | soft | N/A |
| thumbnail | 150 | 150 | hard | 1:1 |
| foo-bar-thumb | 50 | 50 | hard | 1:1 |
And STDERR should be empty

When I run `wp media image-size --format=csv`
Then STDOUT should not contain:
"""
,0,0,
"""

# Behavior changed with WordPress 5.3+, so we're adding separate tests for previous versions.
# Change that impacts this:
# https://core.trac.wordpress.org/ticket/43524
Expand Down