Skip to content

Inheriting from a class that doesn't exist#33334 #33449

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

Conversation

monteshot
Copy link
Contributor

Description (*)

The class that responsible for getting price value uses not valid constant.
I was remove incorrect constant and add the constant from this class that can be correctly overrided.

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Inheriting from a class that doesn't exist #33334

Manual testing scenarios (*)

  1. On any properly created bundle product will be executed \Magento\Catalog\Pricing\Render\ConfiguredPriceBox because the
    \Magento\Catalog\Pricing\Price\ConfiguredPriceInterface::CONFIGURED_PRICE_CODE is in Magento\Bundle\Pricing\Price\Pool
  2. The render mechanism will found the template app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml that will get the class \Magento\Bundle\Pricing\Price\ConfiguredRegularPrice that inherits from \Magento\Bundle\Pricing\Price\ConfiguredPrice with the problem get value method
  3. On line 18 of app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml will be invoked code from \Magento\Bundle\Pricing\Price\ConfiguredPrice::getValue
  4. If item was previously set using setItem the getValue code will throw exception
  5. I change to self::PRICE_CODE and code no longer crash

Questions or comments

Comments:
The class that inherits this class already have the Unit test
\Magento\Catalog\Test\Unit\Pricing\Price\ConfiguredPriceTest but it.
Also i wrote unit for getValue method

Normally on frontend the code with error not invokes. It seems to be fallback.
This code may crash when unit tests executing

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

monteshot added 2 commits July 9, 2021 11:39
- Changed PRICE_CODE constant from non-exist class to $this class
- calculateDiscount method must be point as FinalPrice to its class but in ConfiguredPrice.php this method not exist. Also in FinalPrice invokes the \Magento\Bundle\Pricing\Price\DiscountCalculator::calculateDiscount
- added unit test for method getValue
@m2-assistant
Copy link

m2-assistant bot commented Jul 9, 2021

Hi @monteshot. Thank you for your contribution
Here are some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-community-project m2-community-project bot added Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: pending review labels Jul 9, 2021
@monteshot
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

- Removed unnecessary nesting in if statements according to the interface
…sn't_exist#33334' into Inheriting_from_a_class_that_doesn't_exist#33334
@monteshot
Copy link
Contributor Author

Hello.
What should i do with this semantic error @bgorski
image

Thanks.

@monteshot
Copy link
Contributor Author

Neither module.xml nor composer.json i cannot change version because its absent in both files

- Removed unnecessary properties from test class
@monteshot
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

- Update the unit test for getter in case non-existing the item
@monteshot
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

- Made changes backwards compatible.
@monteshot
Copy link
Contributor Author

@magento run all tests

@magento-engcom-team
Copy link
Contributor

Hi @bgorski, thank you for the review.
ENGCOM-9161 has been created to process this Pull Request

@Den4ik Den4ik self-assigned this Jul 27, 2021
@magento-engcom-team
Copy link
Contributor

Hi @Den4ik, thank you for the review.
ENGCOM-9161 has been created to process this Pull Request

@engcom-Hotel
Copy link
Contributor

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@monteshot
Copy link
Contributor Author

image
Another flaky test failed
@engcom-Hotel I will restart tests

@monteshot
Copy link
Contributor Author

@magento run Functional Tests EE

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Hotel
Copy link
Contributor

✔️ QA Passed

Hello @monteshot,

I have tested this fix by setting items previously using the setItem method. Below is the before and after fix screenshot:

Before ✖️

Screenshot 2021-09-06 at 1 04 10 PM

After ✔️

Screenshot 2021-09-06 at 1 06 09 PM

Verified that the below fatal error should not come:

Error : Class 'Magento\Bundle\Pricing\Price\BundleDiscountPrice' not found

Tested all the manual scenarios, no impact on regression testing.

Thanks

@m2-assistant
Copy link

m2-assistant bot commented Sep 23, 2021

Hi @monteshot, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix Component: Bundle Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: accept Release Line: 2.4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inheriting from a class that doesn't exist
8 participants