[wp-trac] [WordPress Trac] #38266: Tests: Use assertSame() when the type of the value in the assertion is important

WordPress Trac noreply at wordpress.org
Sun Sep 6 03:25:32 UTC 2020


#38266: Tests: Use assertSame() when the type of the value in the assertion is
important
-----------------------------------+-----------------------------
 Reporter:  johnbillion            |       Owner:  SergeyBiryukov
     Type:  defect (bug)           |      Status:  accepted
 Priority:  normal                 |   Milestone:  5.6
Component:  Build/Test Tools       |     Version:
 Severity:  normal                 |  Resolution:
 Keywords:  needs-unit-tests php8  |     Focuses:
-----------------------------------+-----------------------------

Comment (by SergeyBiryukov):

 * `Tests_Cache::test_miss()` was added in [1/tests]. Object caching was
 introduced in [3011]. As far as I can tell, `WP_Object_Cache::get()`
 always returned `false`, not `null` for cache misses, so the test was
 never correct.
 * `Tests_Cache::test_add_get_null()` was added in [280/tests] and adjusted
 in [327/tests]. At the time, `null` was indeed converted to an empty
 string due to this piece in `WP_Object_Cache::set()`, added in [3021] and
 adjusted in [6247]:
 {{{
 if (NULL === $data)
         $data = '';
 }}}
  This was later removed in [20089], but the test was never updated.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/38266#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list