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

For years, the test framework EcomDev_PHPUnit is quasi-standard for Magento unit tests. The current version is 0.3.7 and last state of official documentation is version 0.2.0 – since then, much has changed which you have to search yourself in code and GitHub issues. This series shall collect practical usage tips.

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”

The weeks on StackExchange #33-34 / 2016

Short and sweet: StackExchange posts of the last two weeks.

Magento 1

Magento 2

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

Magento 2

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?

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

Magento 1

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”