PHPackages                             ecomdev/phpspec-magento-di-adapter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ecomdev/phpspec-magento-di-adapter

ActiveLibrary

ecomdev/phpspec-magento-di-adapter
==================================

An adapter for DI features of Magento\\Framework to write easier your examples with PHPSpec. Does not use ObjectManager, only emulates some of its features

1.0.0(9y ago)6202OSL-3.0PHPPHP ~5.6|~7.0

Since May 24Pushed 9y agoCompare

[ Source](https://github.com/EcomDev/phpspec-magento-di-adapter)[ Packagist](https://packagist.org/packages/ecomdev/phpspec-magento-di-adapter)[ RSS](/packages/ecomdev-phpspec-magento-di-adapter/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (11)Versions (4)Used By (0)

PHPSpec Magento 2.0 DI Adapter [![Build Status](https://camo.githubusercontent.com/f7979e8a23a1bcbfef5438d6b4a883e57033c040bbb38869d7f3496726b1b733/68747470733a2f2f7472617669732d63692e6f72672f45636f6d4465762f706870737065632d6d6167656e746f2d64692d616461707465722e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/EcomDev/phpspec-magento-di-adapter?branch=develop) [![Coverage Status](https://camo.githubusercontent.com/56333c7ca7ead94124cd6c703b95808031603c5831f1bda03c24134f9cce6181/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f45636f6d4465762f706870737065632d6d6167656e746f2d64692d616461707465722f62616467652e7376673f6272616e63683d646576656c6f70)](https://coveralls.io/github/EcomDev/phpspec-magento-di-adapter?branch=develop)
=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#phpspec-magento-20-di-adapter---)

This small PHPSpec extension allows you to test Magento 2.0 modules much more easier by utilizing generators of `Magento\Framework\ObjectManager`.

Why?
----

[](#why)

Reasons why not to use `ObjectManager` in PHPSpec examples:

1. It is heavy and requires stubbing full file system in order to run a simple spec example.
2. Depending on ObjectManager is a bad idea, as you don't want to test some-else DI overrides.
3. Simple modules that do not require database do not need fully functional object manager
4. Adapting your business logic to another framework will require from you only to materialize generated classes, instead of depending on the whole ObjectManager library.

Supported Generators
--------------------

[](#supported-generators)

- Factory
- Repository
- Converter
- Persistor
- Mapper
- SearchResults

Installation
------------

[](#installation)

1. Install via composer

    ```
    composer require --dev ecomdev/phpspec-magento-di-adapter
    ```
2. Add to your phpspec.yml

    ```
    extensions:
       - EcomDev\PHPSpec\MagentoDiAdapter\Extension
    ```

Usage
-----

[](#usage)

Make sure that when you write examples to specify fully qualified class name for auto-generated class.

```
