It’s time again for a learning coffee break, today on software testing! This time, 5 minutes are just enough for a short overview. Take yourself some more time to read all linked articles.
Magento 2 Integration Tests: @magentoConfigFixture
I did not find a good documentation on how to use the @magentoConfigFixture
annotation for configuration fixtures in Magento 2 integration tests, so here is my summary after inspecting the core code (Magento 2.1.0, Magento\TestFramework\Annotation\ConfigFixture
)
How to use @magentoConfigFixture
Set default value 42 for configuration path x/y/z
:
/** * @magentoConfigFixture default/x/y/z 42 */
Set store specific value 42 for configuration path x/y/z
in store with code store1
/** * @magentoConfigFixture store1_store x/y/z 42 */
Set store specific value 42 for configuration path x/y/z
in current store (i.e. default store)
/** * @magentoConfigFixture current_store x/y/z 42 */
These are all possible formats. The first parameter must end with _store
or be ommitted. And if it is omitted, the path must start with default/
, otherwise it is ignored.
Implications
- You cannot set configuration values on website level
- Do not use “current” as a real store code, otherwise you cannot use config fixtures for that store
EcomDev PHPUnit Tip #14
Tip #14: Registry Fixtures
As already explained in Tip #1, helpers, singletons and registry values can be reset per test. Finding the problematic singletons etc. often was the most difficult part of writing integration tests with EcomDev, so I started to collect them centralized in one fixtures/registry.yaml
file for all tests 1. Better reset one too many than one to little.
The file is structured like this:
Continue reading “EcomDev PHPUnit Tip #14”
Notes:
- See also: YAML Directory Fallback ↩
The weeks on StackExchange #33-34 / 2016
Short and sweet: StackExchange posts of the last two weeks.
Magento 1
- How it is possible to filter by final price: addAttributeToFilter not working with final_price
- Does it make sense to load a single item using collections? Difference in performance between load and using collections
- Not directly my answer but it deserves some more attention: Store code in URL for every store view except for default (the KISS way)
- What should you do if SQL queries start appearing in the search suggestions: Spam bots & SQL Injections – How do I stop this?
- Good question: What does the “persistent shopping cart” actually do? I’m not so sure anymore: Does Persistent Shopping Cart work for guest (unlogged) visitors?
- I had some trouble triggering the EE URL indexer, not happy with the solution yet: Force URL indexation in Magento 1 Enterprise
- The attempt for a canonical question: How do I override/rewrite a block class in Magento 1? The answers so far already cover a good deal
Magento 2
- Interesting idea: let proxy decide at runtime which concrete class to instantiate: Magento 2 Dependency Injection: Lazy Load with Resolution of Concrete Class-Name
The weeks on StackExchange #30-32 / 2016
I was active on Magento StackExchange again, here are a few interesting questions and answers from the last three weeks:
Magento 1
- (Why) do we need these ugly ___store and ___from_store URL parameters? M1: Remove “?___store=default” from the URL. And isn’t it at least possible to make them look nicer (“SEO friendly”)? Optimise URL when changing Store and language switcher to maintain SEO standards
- One question, three completely different approaches: how to add default products to related products list
- Sounds easy, but isn’t quite straightforward: Exclude Category when showing product collection
Magento 2
- A dirty hack, but very useful for development: Add same plugin to all public methods of a type
- Since Magento 2.1, creating own category attributes gets remarkably more complex: Add category attribute to custom attribute group. And this is how it looks with a source model: Create multiselect with source model in UI component
- I’m unsatisfied with the catalog service contracts again… “Call to a member function getIsInStock() on null” with getExtensionAttributes()->getStockItem() (or: How do I get products with stock info from the repository?)
Magento Architecture
Good question for understanding “MVC” in Magento: Why does Magento need blocks?. There was a similar question once here: Where’s The V in Magento’s MVC? And is there better name?
5 Minute Tips: MySQL Commands
Welcome to your learning coffee break, today on MySQL commands! I like working on the MySQL console. It’s available everywhere, and keyboard trumps mouse as soon as you know the right commands and shortcuts. But there’s more to it than just entering queries. So, today I’ll share a few tips to improve your productivity with the MySQL console:
The week weeks on StackExchange #24-29 / 2016
The weekly format did not last long, but a few posts on Magento StackExchange assembled in the last 5 weeks that might be worth some attention (and a new t-shirt):
Magento 2
- Retrieving a product image URL in a custom block seems to be non-trivial and can be done “wrong” in many ways: Getting full image URL of product in template
- How to define a custom search engine: Magento 2: what is the search_engine.xml? How to declare a new search engine? I plan a separate blog post on this topic soon.
- Interesting find: Setting the area to
adminhtml
does not automatically set theadmin
store: Magento 2 integration test in admin context - And an open question: Right way to implement getExtensionAttributes()
Magento 1
- In How to correctly select the first item from a filtered collection? I realize that you should not use
$collection->getData()
(and there’s the obligatory warning for a typical performance trap) - A short overview over all CMS and email template directives, or a try of it: Why do we have to use “store” for links in CMS like <a href=“{{store url=’home’}}”>home</a>
- A reminder, to prefer
theme.xml
overlocal.xml
: Is it possible to include a parent local.xml?
- What is the unit of the weigh attribute? What Is The Default Magento Weight Unit And How Can Change It
5 Minute Tips: Git
Here’s one for Monday morning. A few Git commands that you might want to add to your toolbox as well:
5 Minute Tips: Magento Performance Tweaks
My “Week On StackExchange” Series takes a break at the moment because I don’t have not too much blog-worthy.
Instead, I’m starting something new again: Tips on a specific topic which you can read in 5 minutes maximum during coffee break. Mostly not by me, just found by me 🙂
I don’t try to make it a regular thing but I have a loose collection of useful stuff so why not use the blog to bring order into it and hopefully it’s also useful for others.
Let’s start with Magento Performance Tweaks, all with little effort and can be used without hesitation:
Continue reading “5 Minute Tips: Magento Performance Tweaks”
MageStackDay #5 and the moderation discussion
17.-18.6. was the 5th (+/-1) MageStackDay, an online hackathon dedicated to the Magento StackExchange site. It was originally initiated by the community to get the answer rate up and finally get out of beta status (which had hard requirements originally, like an 80% answer rate).
To achieve that goal, we focused on “unanswered” questions with one of these actions, whatever is applicable:
- answer
- close
- upvoted existing answers with 0-votes, because questions count as answered if they have either an accepted or an upvoted answer.
But since we “gradudated” out of beta recently, just working towards some numbers doesn’t seem right anymore. After all, the primary goal should be to increase quality.
Continue reading “MageStackDay #5 and the moderation discussion”