The week on StackExchange #35/2016

I’m a bit late but I was quite active on the Magento StackExchange recently, so here are the best posts from last week!

Magento 1 answers

PHPUnit

New Magento 2 questions

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”

The week on StackExchange #23 / 2016

Shortly before the 5th MageStackDay, here are some questions and answers on magento.stackexchange.com from last week that might interest you:

Magento 2

  • Without answer yet, and probably there is no solution as of Magento 2.0: Localized frontend value for getCustomAttribute() (select or multiselect attributes) – but as I commented: I’m going to continue to ask these questions when I’m hitting walls, and if it’s just to highlight, where the API is incomplete, especially when it’s about the catalog
  • Marius asked a good question on Unit testing source models. Besides my answer on this concrete case, the elaboration by Vinai on “Should I test X?” or “How should I test X?” is a valuable advice for everybody.

Magento 1

The week on StackExchange #22 / 2016

I’m back with fresh Magento content (and hit 1000 answers on magento.stackexchange.com with this unspectacular FGITW answer)

Magento 2

Magento 1

Meta Discussion

For those interested, there’s an ongoing discussion on “off topic / on topic” and how to handle closing questions on Magento.SE:

The week weeks on StackExchange #16-21 / 2016

No, I did not give up this series, but there was Developers Paradise (read my review!), then vacation, and I stepped back a bit.

Now there is enough material that it’s time for a new post:

Magento 2

Magento 1