Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Make PHPUnit tests pass locally #131

Merged
merged 1 commit into from
Mar 30, 2023
Merged

Make PHPUnit tests pass locally #131

merged 1 commit into from
Mar 30, 2023

Conversation

kienstra
Copy link
Contributor

@kienstra kienstra commented Mar 28, 2023

Before, npm run test:phpunit failed locally with:

Time: 8.71 seconds, Memory: 44.50 MB

There was 1 failure:

1) PatternManager\PatternDataHandlers\PatternDataHandlersTest::test_tree_shake_theme_images
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
-Array &0 (
-    0 => '/var/www/html/wp-content/plugins/pattern-manager/wp-modules/pattern-data-handlers/tests/fixtures/patterns/images/used.jpg'
-)
+Array &0 ()

/var/www/html/wp-content/plugins/pattern-manager/wp-modules/pattern-data-handlers/tests/PatternDataHandlersTest.php:198

This is because preg_match() failed on the test pattern:

<!-- wp:image -->
<figure class="wp-block-image size-large"><img src="/wordpress-phpunit/includes/../data/themedir1/default/patterns/images/used.jpg" alt="Cup of tea"/></figure>
<!-- /wp:image -->

In that pattern, get_stylesheet_directory_uri() didn't have http:

/wordpress-phpunit/includes/../data/themedir1/default/

…so preg_match() failed.

This PR filters get_theme_directory_uri() so it starts with https://

How to test

Not needed. But if you want to:

  1. npm run test:phpunit
  2. Expected: it passes

@kienstra kienstra marked this pull request as ready for review March 28, 2023 19:45
@kienstra
Copy link
Contributor Author

kienstra commented Mar 28, 2023

Sorry for ignoring this failed test.

This should fix it.

@kienstra kienstra requested a review from mikemcalister March 29, 2023 21:14
@kienstra
Copy link
Contributor Author

Thanks so much, @dreamwhisper!

@kienstra kienstra merged commit 62a75c0 into main Mar 30, 2023
@kienstra kienstra deleted the fix/flaky-phpunit-test branch March 30, 2023 21:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants