How to use the real object manager for your custom PHPUnit test?

This code allows to to avoid the «ObjectManager isn’t initialized» issue while running your custom PHPUnit tests.

Please note that I use in this example (and for my Magento 2 extensions) the latest PHPUnit distributive (5.x) instead of the legacy 4.1.0 version used by the Magento 2 core.

You can also use a mock object manager for your custom PHPUnit tests.

See also: