WordPress.org

Make WordPress Core

Opened 8 months ago

Closed 8 months ago

#46043 closed enhancement (fixed)

Unit Tests for the __return functions in functions.php

Reported by: pbearne Owned by: pento
Milestone: 5.1 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

Just a unit test for some functions in the functions.php part of my ongoing effort to add missing tests

Attachments (3)

#46043__return.php.patch (1.0 KB) - added by pbearne 8 months ago.
Unittest
46043.patch (1.0 KB) - added by mukesh27 8 months ago.
Updated Patch as suggested by @johnbillion
#46043__return.php.2.patch (1.0 KB) - added by pbearne 8 months ago.
Updated the empty array test to use assertSame as well

Download all attachments as: .zip

Change History (7)

@pbearne
8 months ago

Unittest

#1 @pbearne
8 months ago

  • Summary changed from Units for the __return function in functions.php to Unit Tests for the __return functions in functions.php

#2 @johnbillion
8 months ago

  • Keywords dev-feedback removed
  • Version trunk deleted

test__return_zero() and test__return_empty_string() need to use assertSame() instead of assertEquals() otherwise they use loose type comparison, which makes the tests unreliable.

test__return_true() and test__return_false() shouldn't cast to boolean otherwise they too are unreliable.

@mukesh27
8 months ago

Updated Patch as suggested by @johnbillion

@pbearne
8 months ago

Updated the empty array test to use assertSame as well

#3 @pento
8 months ago

  • Milestone changed from Awaiting Review to 5.1
  • Owner set to pento
  • Status changed from new to accepted

#4 @pento
8 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 44658:

Tests: Add tests for the __return*() functions.

Props pbearne, mukesh27.
Fixes #46043.

Note: See TracTickets for help on using tickets.