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

Prepares Command/Query API for migrating "Create order" page #13554

Merged
merged 45 commits into from
May 23, 2019

Conversation

sarjon
Copy link
Contributor

@sarjon sarjon commented Apr 24, 2019

Questions Answers
Branch? develop
Description? This PR prepares new Command/Query API for migrating "Create order" page.
Type? refacto
Category? CO
BC breaks? no
Deprecations? no
Fixed ticket? #10583
How to test? Hmmmmm. 🤔

This change is Reviewable

@prestonBot prestonBot added develop Branch Refactoring Type: Refactoring labels Apr 24, 2019
@sarjon
Copy link
Contributor Author

sarjon commented Apr 29, 2019

@matks could you review 5b71a88 ? It's still WIP, but I need early feedback. :)

// Some services uses static PrestaShop/Adapter/SymfonyContainer::getInstance()
// and it depends on global $kernel
global $kernel;
$kernel = self::$kernel;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@matks 😨 This global state and Context are making tests so much harder to maintain. :/

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes THAT is a broken window wide open.
Can you tell me what step required this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I remember it starts at PaymentModule::validateOrder(), then it goes to Tools::displayPrice() which then internally calls ToolsCore::getContextLocale() which then calls SymfonyContainer::getInstance() which uses global $kernel. 😓

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes you're right, it's set like this too here: https://github.com/PrestaShop/PrestaShop/blob/develop/tests/Integration/Behaviour/Features/Context/OrderFeatureContext.php#L56

Can we make this setup a function that can be called only once, to avoid duplicate kernel booting ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, but this is what I did, isn't it? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I was mistaken because we have 2 OrderFeatureContext, one in Domain and one outside. I looked at the wrong one

Copy link
Contributor

Choose a reason for hiding this comment

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

Erratum, can we check the global $kernel does not yet exists, and if it does, throw an Exception ?
Something like if (global $kernel !== null) { throw new \Exception('Cannot init SF Kernel twice'); }

A small firewall to avoid crazy bugs later 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I've tried to do it, but ended up modifying other tests as well, so I'd prefer to do it in separate PR when this one gets merged.

@sarjon sarjon changed the title [WIP] Prepares Command/Query API for migrating "Create order" page Prepares Command/Query API for migrating "Create order" page May 6, 2019
@prestonBot prestonBot added the Waiting for wording Status: action required, waiting for wording label May 6, 2019
@sarjon sarjon marked this pull request as ready for review May 6, 2019 10:38
@sarjon sarjon requested a review from a team as a code owner May 6, 2019 10:38
@LouiseBonnard
Copy link
Contributor

Hello, the wording is alright but it is hard for me to picture the whole scheme: are they like random strings before migrating the whole page in another pull request?

@sarjon
Copy link
Contributor Author

sarjon commented May 7, 2019

are they like random strings before migrating the whole page in another pull request?

Hi, not sure if I understand your question, but basically it's a backend without any visible changes to UI yet. So yes, UI will be migrated in another PR. :)

@sarjon
Copy link
Contributor Author

sarjon commented May 7, 2019

@matks could you review? :)

@LouiseBonnard LouiseBonnard removed the Waiting for wording Status: action required, waiting for wording label May 9, 2019
@sarjon
Copy link
Contributor Author

sarjon commented May 10, 2019

@matks would you mind to take a look at behat steps and scenario? I've updated to use references, I think it looks better now.

Not sure why tests are failing, any ideas? :/

@sarjon
Copy link
Contributor Author

sarjon commented May 23, 2019

@matks finally, it's green!

@matks
Copy link
Contributor

matks commented May 23, 2019

@matks finally, it's green!

Today is a nice day 😄

@matks matks added this to the 1.7.7.0 milestone May 23, 2019
@matks
Copy link
Contributor

matks commented May 23, 2019

Thank you @sarjon

@matks matks merged commit b32909e into PrestaShop:develop May 23, 2019
@sarjon sarjon deleted the m/orders/add branch May 23, 2019 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
develop Branch migration symfony migration project Refactoring Type: Refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants