[wp-trac] [WordPress Trac] #56807: Delete existing attachment subsizes after WP_Customize_Manager tests

WordPress Trac noreply at wordpress.org
Wed Oct 12 00:47:28 UTC 2022


#56807: Delete existing attachment subsizes after WP_Customize_Manager tests
------------------------------+------------------------------
 Reporter:  ironprogrammer    |       Owner:  (none)
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Build/Test Tools  |     Version:  trunk
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:
------------------------------+------------------------------
Description changed by SergeyBiryukov:

Old description:

> After running the PHPUnit test for `test_import_theme_starter_content()`
> (in `tests/customize/manager.php`), the following files are generated and
> left in place, resulting in a dirty working copy of the project:
>
> {{{
> tests/phpunit/data/images/canola-150x150.jpg
> tests/phpunit/data/images/canola-300x225.jpg
> }}}
>
> == Background
> In the test, `canola.jpg` is mocked as an **existing attachment**. When
> the test invokes `WP_Customize_Manager::import_theme_starter_content()`,
> existing attachments are passed directly to
> `wp_generate_attachment_metadata()`, which does not make a copy of the
> file, and `wp_create_image_subsizes()` creates the above referenced files
> in the original image's location.
>
> By contrast, `waffles.jpg`, also used in the test, is **not** set as an
> existing attachment, and in  `import_theme_starter_content()` is passed
> to `media_handle_sideload()`, which makes a **copy** of the file in `wp-
> content/uploads/`, and then calls `wp_create_image_subsizes()` against
> the new file. The resulting subsizes are generated in that location, and
> are cleaned up during `tear_down()`.
>
> The test's `tear_down()` uses `remove_added_uploads()`, but the function
> only clears items created in `wp-content/uploads/` (i.e. `waffles*.jpg`),
> and not files in the `DIR_TESTDATA` directory (`canola-*.jpg`).
>
> == Testing Instructions
>
> === Steps to Reproduce
> 1. Run `phpunit --filter test_import_theme_starter_content`.
> 2. 🐞 Observe the newly created `canola-*.jpg` files in
> `tests/phpunit/data/images/`.
>
> === Expected Results
> - ❌ There should not be any added files to the `DIR_TESTDATA` directory
> after running the test.
>
> Related: #54424.
>
>   **Test Report Icons:**
>   🐞 <= Indicates where issue ("bug") occurs.
>   ✅ <= Behavior is ''expected''.
>   ❌ <= Behavior is ''NOT expected''.

New description:

 After running the PHPUnit test for `test_import_theme_starter_content()`
 (in `tests/customize/manager.php`), the following files are generated and
 left in place, resulting in a dirty working copy of the project:

 {{{
 tests/phpunit/data/images/canola-150x150.jpg
 tests/phpunit/data/images/canola-300x225.jpg
 }}}

 == Background
 In the test, `canola.jpg` is mocked as an **existing attachment**. When
 the test invokes `WP_Customize_Manager::import_theme_starter_content()`,
 existing attachments are passed directly to
 `wp_generate_attachment_metadata()`, which does not make a copy of the
 file, and `wp_create_image_subsizes()` creates the above referenced files
 in the original image's location.

 By contrast, `waffles.jpg`, also used in the test, is **not** set as an
 existing attachment, and in  `import_theme_starter_content()` is passed to
 `media_handle_sideload()`, which makes a **copy** of the file in `wp-
 content/uploads/`, and then calls `wp_create_image_subsizes()` against the
 new file. The resulting subsizes are generated in that location, and are
 cleaned up during `tear_down()`.

 The test's `tear_down()` uses `remove_added_uploads()`, but the function
 only clears items created in `wp-content/uploads/` (i.e. `waffles*.jpg`),
 and not files in the `DIR_TESTDATA` directory (`canola-*.jpg`).

 == Testing Instructions

 === Steps to Reproduce
 1. Run `phpunit --filter test_import_theme_starter_content`.
 2. 🐞 Observe the newly created `canola-*.jpg` files in
 `tests/phpunit/data/images/`.

 === Expected Results
 - ❌ There should not be any added files to the `DIR_TESTDATA` directory
 after running the test.

 Related: [54424].

   **Test Report Icons:**
   🐞 <= Indicates where issue ("bug") occurs.
   ✅ <= Behavior is ''expected''.
   ❌ <= Behavior is ''NOT expected''.

--

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


More information about the wp-trac mailing list