Skip to content

Commit

Permalink
Issue #864: Address Travis errors, including PHPCS issue.
Browse files Browse the repository at this point in the history
There was an error from the textdomain not being included.
But it's copied from the WordPress widget,
So it should use the default textdomain.
Use @codingStandardsIgnoreLine in those cases.
Also, call wp_maybe_load_widgets() in the test setUp().
This ensures that the core widgets are loaded.
  • Loading branch information
Ryan Kienstra committed Jan 19, 2018
1 parent fb9b451 commit cbdbd4a
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 3 deletions.
6 changes: 4 additions & 2 deletions includes/widgets/class-amp-widget-categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public function modify_select( $dropdown ) {
*/
public function widget( $args, $instance ) {
static $first_dropdown = true;
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Categories' ); // phpcs:ignore.
// @codingStandardsIgnoreLine
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Categories' );
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
$c = ! empty( $instance['count'] ) ? '1' : '0';
Expand All @@ -59,7 +60,8 @@ public function widget( $args, $instance ) {
$dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}";
$first_dropdown = false;
echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . esc_html( $title ) . '</label>';
$cat_args['show_option_none'] = __( 'Select Category' ); // phpcs:ignore.
// @codingStandardsIgnoreLine
$cat_args['show_option_none'] = __( 'Select Category' );
$cat_args['id'] = $dropdown_id;
/**
* Filters the arguments for the Categories widget drop-down.
Expand Down
1 change: 1 addition & 0 deletions tests/test-class-amp-widget-archives.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Test_AMP_Widget_Archives extends WP_UnitTestCase {
*/
public function setUp() {
parent::setUp();
wp_maybe_load_widgets();
AMP_Theme_Support::init();
$amp_widgets = new AMP_Widgets();
$amp_widgets->register_widgets();
Expand Down
1 change: 1 addition & 0 deletions tests/test-class-amp-widget-categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Test_AMP_Widget_Categories extends WP_UnitTestCase {
*/
public function setUp() {
parent::setUp();
wp_maybe_load_widgets();
AMP_Theme_Support::init();
$amp_widgets = new AMP_Widgets();
$amp_widgets->register_widgets();
Expand Down
1 change: 1 addition & 0 deletions tests/test-class-amp-widget-media-audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Test_AMP_Widget_Media_Audio extends WP_UnitTestCase {
*/
public function setUp() {
parent::setUp();
wp_maybe_load_widgets();
AMP_Theme_Support::init();
$amp_widgets = new AMP_Widgets();
$amp_widgets->register_widgets();
Expand Down
1 change: 1 addition & 0 deletions tests/test-class-amp-widget-media-gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Test_AMP_Widget_Media_Gallery extends WP_UnitTestCase {
*/
public function setUp() {
parent::setUp();
wp_maybe_load_widgets();
AMP_Theme_Support::init();
$amp_widgets = new AMP_Widgets();
$amp_widgets->register_widgets();
Expand Down
1 change: 1 addition & 0 deletions tests/test-class-amp-widget-media-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Test_AMP_Widget_Media_Image extends WP_UnitTestCase {
*/
public function setUp() {
parent::setUp();
wp_maybe_load_widgets();
AMP_Theme_Support::init();
$amp_widgets = new AMP_Widgets();
$amp_widgets->register_widgets();
Expand Down
1 change: 1 addition & 0 deletions tests/test-class-amp-widget-media-video.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Test_AMP_Widget_Media_Video extends WP_UnitTestCase {
*/
public function setUp() {
parent::setUp();
wp_maybe_load_widgets();
AMP_Theme_Support::init();
$amp_widgets = new AMP_Widgets();
$amp_widgets->register_widgets();
Expand Down
1 change: 1 addition & 0 deletions tests/test-class-amp-widget-recent-comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Test_AMP_Widget_Recent_Comments extends WP_UnitTestCase {
*/
public function setUp() {
parent::setUp();
wp_maybe_load_widgets();
AMP_Theme_Support::init();
$amp_widgets = new AMP_Widgets();
$amp_widgets->register_widgets();
Expand Down
1 change: 1 addition & 0 deletions tests/test-class-amp-widget-rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Test_AMP_Widget_RSS extends WP_UnitTestCase {
*/
public function setUp() {
parent::setUp();
wp_maybe_load_widgets();
AMP_Theme_Support::init();
$amp_widgets = new AMP_Widgets();
$amp_widgets->register_widgets();
Expand Down
2 changes: 1 addition & 1 deletion tests/test-class-amp-widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Test_AMP_Widgets extends WP_UnitTestCase {
*/
public function setUp() {
parent::setUp();
wp_maybe_load_widgets();
$this->instance = new AMP_Widgets();
}

Expand All @@ -34,7 +35,6 @@ public function setUp() {
public function test_init() {
$this->instance->init();
$this->assertEquals( 10, has_filter( 'widgets_init', array( $this->instance, 'register_widgets' ) ) );
$this->assertEquals( 10, has_filter( 'show_recent_comments_widget_style', '__return_false' ) );
}

/**
Expand Down

0 comments on commit cbdbd4a

Please sign in to comment.