WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#35294 closed enhancement (fixed)

Modification in phpdoc and unit tests for wp_dropdown_languages()

Reported by: realloc Owned by: ocean90
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.0
Component: I18N Keywords: has-unit-tests needs-patch
Focuses: Cc:

Description

I wrote a unit test for wp_dropdown_languages(). I added also a filter when this test is running so there will be no call to the API. I changed the php documentation too because this function returns always the generated output even when the param echo is set to true.

Attachments (2)

35294.patch (3.4 KB) - added by realloc 4 years ago.
PhpDoc and unit test for wp_dropdown_languages()
35294.2.patch (1.6 KB) - added by realloc 4 years ago.
Test the various pieces of the output only

Download all attachments as: .zip

Change History (10)

@realloc
4 years ago

PhpDoc and unit test for wp_dropdown_languages()

#1 @realloc
4 years ago

  • Keywords has-patch has-unit-tests added

#2 @johnbillion
4 years ago

In 36290:

I18N: Correct an argument description and return value for wp_dropdown_languages().

Props realloc
See #35294

#3 follow-up: @johnbillion
4 years ago

  • Milestone changed from Awaiting Review to 4.5
  • Version changed from trunk to 4.0

These assertions are good, but they are brittle because they test the output of the function in its entirety. I think it would be better to test various pieces of the output (using assertContains() or assertRegExp()) to ensure they are as expected.

For example, what is actually being tested here is that the correct languages are output in the correct optgroup, and the expected attributes are present.

@realloc Do you want to take another look at this?

#4 in reply to: ↑ 3 @realloc
4 years ago

Replying to johnbillion:

@realloc Do you want to take another look at this?

Thanks for your tips, John! I'll have a look at it very soon.

#5 @DrewAPicture
4 years ago

  • Keywords needs-patch added; has-patch removed

#6 follow-up: @chriscct7
4 years ago

@realloc Did you have an updated patch for this?

#7 in reply to: ↑ 6 @realloc
4 years ago

Replying to chriscct7:

@realloc Did you have an updated patch for this?

Not yet, but I will work on this on monday.

@realloc
4 years ago

Test the various pieces of the output only

#8 @ocean90
4 years ago

  • Owner set to ocean90
  • Resolution set to fixed
  • Status changed from new to closed

In 36631:

L10n: Add test for wp_dropdown_languages().

Props realloc.
Fixes #35294.

Note: See TracTickets for help on using tickets.