Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP : PHP8 #381

Merged
merged 25 commits into from
Nov 6, 2023
Merged

WIP : PHP8 #381

merged 25 commits into from
Nov 6, 2023

Conversation

iruzevic
Copy link
Member

@iruzevic iruzevic commented Oct 26, 2023

⚠️ PHP8 preparation branch

Description

  • updating composer packages
  • fixing stan and lint issues
  • updating composer command names
  • Denis fixes for standards
  • adding missing type hinting
  • Config changed definition of version and name
  • Blocks removing "old" version functions
  • new command to change version number
  • fixed broken db import command with the wrong setup.json path
  • adding better copy for checkAttr helper if key is missing.
  • Every enqueue script now has is<>Used method that is by default true.

Note

To install and test the latest version, use this command:

npx create-wp-project@latest --eightshiftLibsBranch="develop-php8" --eightshiftFrontendLibsBranch="develop-php8" --eightshiftBoilerplateBranch='develop-php8'

Connected PRs

infinum/eightshift-boilerplate#273
infinum/eightshift-frontend-libs#761
#381

dingo-d and others added 3 commits October 26, 2023 08:31
* Update composer dependencies

* Update phpcs config

* Remove unused ignored error

* Fix deprecation notice

Depth parameter shouldn't be set to 0.

* Fix the tests failures because of inability to check the list of items vs source items

* Remove extra space from init blocks command

* Update readme

* Fix phpcs violation

* Fix deprecations with using traits directly

Added anonymous classes instead.

* Add mocks for the failing tests

* Fix test deprecations

* Update the gh action workflow

* Workflow fix

* Workflow update

8.3 allow failure for non-released version of PHP.

* Minor formatting fix on helpers

* Replace assertions with expectations API

Should prevent failures on PHPUnit <9 where assertObjectHasProperty isn't defined.

* Prevent the dynamic properties deprecation notices in tests

This will still be an issue on composer installs with lowest dependencies where dynamic properties isn't allowed/fixed in mockery.

* Minor grammar typo fix in a test

* Update workflow to allow failures on lowest composer dependencies

* Update moveItem method

* Improve type description in moveItem method

* Improve the moveItems method

In real life cases, the sourceItem array will contain list of items in the folder, and the folder as a value, so we need to check that as well. This should probably come up in tests, unless the dataset is not correctly set to mimick how the real life projects are behaving. This needs investigation.
@iruzevic iruzevic marked this pull request as draft October 26, 2023 07:51
@iruzevic iruzevic self-assigned this Oct 26, 2023
@iruzevic iruzevic requested a review from a team October 26, 2023 07:51
Copy link
Collaborator

@dingo-d dingo-d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor comments.

The thing I'm more worried about is the change in the component rendering.
Several tests are failing (some of which are easy to fix), but for some, I'm not sure the behavior is correct, or at least this new feature has kinda complicated testing.

Because inside the tests you don't have WordPress, the test for the feature could be actually correct, but this new exception would make it seem like it's not correct.

For instance, the following test:

test('Asserts that rendering a component works', function () {
	$results = Components::render('button', []);

	expect($results)
		->not->toBeEmpty()
		->toContain('Hello!');
});

This should be correct (confirming that rendering actually works), but this will now throw an exception: You are not allowed to access paths outside of themes or plugins folder!

So I think that either this should be fixed in test setup, to somehow 'trick' the code to think that during tests we are inside WordPress theme/plugin, or at the code level with a flag 🤷🏼‍♂️

.github/workflows/integrate.yml Outdated Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
@iruzevic
Copy link
Member Author

Left some minor comments.

The thing I'm more worried about is the change in the component rendering. Several tests are failing (some of which are easy to fix), but for some, I'm not sure the behavior is correct, or at least this new feature has kinda complicated testing.

Because inside the tests you don't have WordPress, the test for the feature could be actually correct, but this new exception would make it seem like it's not correct.

For instance, the following test:

test('Asserts that rendering a component works', function () {
	$results = Components::render('button', []);

	expect($results)
		->not->toBeEmpty()
		->toContain('Hello!');
});

This should be correct (confirming that rendering actually works), but this will now throw an exception: You are not allowed to access paths outside of themes or plugins folder!

So I think that either this should be fixed in test setup, to somehow 'trick' the code to think that during tests we are inside WordPress theme/plugin, or at the code level with a flag 🤷🏼‍♂️

I have fixed all the tests

@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Merging #381 (5f976a7) into develop (cddf63a) will decrease coverage by 2.82%.
Report is 32 commits behind head on develop.
The diff coverage is 49.43%.

@@              Coverage Diff              @@
##             develop     #381      +/-   ##
=============================================
- Coverage      84.41%   81.60%   -2.82%     
- Complexity      1273     1357      +84     
=============================================
  Files            135      138       +3     
  Lines           6088     6359     +271     
=============================================
+ Hits            5139     5189      +50     
- Misses           949     1170     +221     
Flag Coverage Δ
unittests 81.60% <49.43%> (-2.82%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/AdminMenus/AdminReusableBlocksMenuCli.php 100.00% <100.00%> (ø)
src/AnalyticsGdpr/AnalyticsGdprExample.php 99.83% <ø> (ø)
src/Blocks/AbstractBlocks.php 97.04% <ø> (-0.33%) ⬇️
src/Blocks/BlocksExample.php 100.00% <100.00%> (+9.09%) ⬆️
src/Blocks/UseAssetsCli.php 100.00% <100.00%> (ø)
src/Blocks/UseBlockCli.php 100.00% <100.00%> (ø)
src/Blocks/UseComponentCli.php 100.00% <100.00%> (ø)
src/Blocks/UseGlobalAssetsCli.php 100.00% <100.00%> (ø)
src/Blocks/UseManifestCli.php 100.00% <100.00%> (ø)
src/Blocks/UseVariationCli.php 100.00% <100.00%> (ø)
... and 34 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@iruzevic
Copy link
Member Author

I can't any errors in the tests, linters or stan. Also There are no issues in the debug log. Npx is working as expected :D I thing this setup is ready for PHP8.2. WooCommerce is also working :D

@iruzevic iruzevic requested a review from dingo-d October 27, 2023 13:12
iobrado
iobrado previously approved these changes Oct 30, 2023
@iruzevic iruzevic requested a review from piqusy October 30, 2023 10:17
piqusy
piqusy previously approved these changes Oct 30, 2023
kancijan
kancijan previously approved these changes Oct 30, 2023
src/Db/DbImport.php Show resolved Hide resolved
tests/BaseTest.php Show resolved Hide resolved
tests/BaseTest.php Show resolved Hide resolved
tests/Unit/Helpers/AttributesTraitTest.php Outdated Show resolved Hide resolved
src/Cli/Cli.php Show resolved Hide resolved
@iruzevic iruzevic dismissed stale reviews from kancijan and piqusy via 5f976a7 October 31, 2023 07:08
@iruzevic iruzevic marked this pull request as ready for review October 31, 2023 07:09
@iruzevic iruzevic merged commit 6680acf into develop Nov 6, 2023
9 of 11 checks passed
@iruzevic iruzevic deleted the develop-php8 branch November 6, 2023 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants