[wp-trac] [WordPress Trac] #42044: _test_list_hierarchical_page() - improve clean-up
WordPress Trac
noreply at wordpress.org
Sun Oct 1 09:31:49 UTC 2017
#42044: _test_list_hierarchical_page() - improve clean-up
------------------------------+------------------
Reporter: birgire | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.9
Component: Build/Test Tools | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
------------------------------+------------------
Comment (by birgire):
We have {{{backupGlobals="false"}}} by default.
I played with the
[https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.backupGlobals
@backupGlobals] annotation on the test class:
{{{
/**
* @group admin
* @backupGlobals enabled
*/
class Tests_Admin_includesListTable extends WP_UnitTestCase {
protected $backupGlobalsBlacklist = ['wpdb'];
}}}
where we blacklist the {{{$wpdb}}} object, as it seems it can't survive
the serialization.
I ran the
{{{
tests/phpunit/tests/admin/includesListTable.php
}}}
three times, without the annotation:
{{{
Time: 1.43 seconds, Memory: 34.00MB
OK (14 tests, 32 assertions)
Time: 1.51 seconds, Memory: 34.00MB
OK (14 tests, 32 assertions)
Time: 1.39 seconds, Memory: 34.00MB
OK (14 tests, 32 assertions)
}}}
using the [attachment:42044.2.patch] ] and three times, only with the
@backupGlobals:
{{{
Time: 1.63 seconds, Memory: 38.00MB
OK (14 tests, 32 assertions)
Time: 1.59 seconds, Memory: 38.00MB
OK (14 tests, 32 assertions)
Time: 1.56 seconds, Memory: 38.00MB
OK (14 tests, 32 assertions)
}}}
So there's some overhead involved with it.
It didn't seem to have any effect to only enabled it on the problematic
method:
{{{
/**
* Helper function to test the output of a page which uses
`WP_Posts_List_Table`.
*
* @backupGlobals enabled
* @param array $args Query args for the list of pages.
* @param array $expected_ids Expected IDs of pages returned.
*/
protected function _test_list_hierarchical_page( array $args, array
$expected_ids ) {
}}}
with
{{{
FAILURES!
Tests: 14, Assertions: 31, Failures: 2.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42044#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list