PHPackages                             webgriffe/functional-test-trait - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. webgriffe/functional-test-trait

ActiveLibrary[Testing &amp; Quality](/categories/testing)

webgriffe/functional-test-trait
===============================

Trait which enables functional testing in Magento with EcomDev\_PHPUnit and using a CgiHttpKernel.

3.0.0(8y ago)026.2kMITPHP

Since Feb 17Pushed 8y ago6 watchersCompare

[ Source](https://github.com/webgriffe/functional-test-trait)[ Packagist](https://packagist.org/packages/webgriffe/functional-test-trait)[ RSS](/packages/webgriffe-functional-test-trait/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (11)Used By (0)

Webgriffe Functional Test Trait
===============================

[](#webgriffe-functional-test-trait)

Trait which enables functional testing in Magento with [EcomDev\_PHPUnit](https://github.com/EcomDev/EcomDev_PHPUnit) and using a [CgiHttpKernel](https://github.com/webgriffe/CgiHttpKernel).

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

[](#installation)

Import it using Composer (note, it's a dev dependency):

```
$ composer require --dev webgriffe/functional-test-trait

```

Usage
-----

[](#usage)

The suggested usage of this trait is in combination with [EcomDev\_PHPUnit](https://github.com/EcomDev/EcomDev_PHPUnit) and the [Webgriffe's Magento Config Extension](https://github.com/webgriffe/config-extension). So, first of all, add these dependencies to your Magento project:

```
$ composer require --dev webgriffe/functional-test-trait ecomdev/ecomdev_phpunit
$ composer require webgriffe/config-extension

```

Another suggested dependency is `symfony/css-selector`, which allows to select DOM elements using CSS selectors in your functional tests:

```
$ composer require --dev symfony/css-selector

```

Then setup your test suite as usual with EcomDev\_PHPUnit.

Also you can add a `` node to your `phpunit.xml.dist` to group your functional tests in a dedicated test suite:

```

    tests

```

Also, to avoid session issues, you should make sure that the `base_url` is always the same during tests setup and tests run. You can do this by setting the `MAGE_ENVIRONMENT` server variable through your `phpunit.xml.dist`:

```

```

And then set the `base_url` with the override configuration file for that environment (`app/etc/config-override.test.xml.dist`), with the content:

```

                http://url-functional.test/

                http://url-functional.test/

```

Now you're ready to write your first Magento functional test. Put a test your `tests/` directory. For example, `HomepageTest.php`:

```
