Skip to content

Commit

Permalink
Add feature test for updated i18n severity
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Dec 24, 2024
1 parent fc6dd66 commit 0c235e3
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/behat/features/plugin-check.feature
Original file line number Diff line number Diff line change
Expand Up @@ -750,3 +750,53 @@ Feature: Test that the WP-CLI command works.
"""
application_detected
"""

Scenario: Check for i18n severity
Given a WP install with the Plugin Check plugin
And a wp-content/plugins/foo-sample/foo-sample.php file:
"""
<?php
/**
* Plugin Name: Foo Sample
* Plugin URI: https://foo-sample.com
* Description: Custom plugin.
* Version: 0.1.0
* Author: WordPress Performance Team
* Author URI: https://make.wordpress.org/performance/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
esc_html_e( 'Hello world', "${foo}" );
esc_html_e( domain: 'foo-sample' );
esc_html_e( '%s', 'foo-sample' );
echo esc_html_x( 'Hello world', $var, 'foo-sample' );
esc_html_e( 'Hello world', $var );
esc_html_e( 'Hello world', 'foo-sample', 'too-many-args' );
"""

When I run the WP-CLI command `plugin check foo-sample --checks=i18n_usage --fields=line,type,code,severity --format=csv`
Then STDOUT should contain:
"""
13,ERROR,WordPress.WP.I18n.InterpolatedVariableDomain,7
"""
And STDOUT should contain:
"""
14,ERROR,WordPress.WP.I18n.MissingArgText,7
"""
And STDOUT should contain:
"""
15,ERROR,WordPress.WP.I18n.NoEmptyStrings,7
"""
And STDOUT should contain:
"""
16,ERROR,WordPress.WP.I18n.NonSingularStringLiteralContext,7
"""
And STDOUT should contain:
"""
17,ERROR,WordPress.WP.I18n.NonSingularStringLiteralDomain,7
"""
And STDOUT should contain:
"""
18,ERROR,WordPress.WP.I18n.TooManyFunctionArgs,7
"""

0 comments on commit 0c235e3

Please sign in to comment.