Download the PHP package webgriffe/functional-test-trait without Composer

On this page you can find all versions of the php package webgriffe/functional-test-trait. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package functional-test-trait

Webgriffe Functional Test Trait

Trait which enables functional testing in Magento with EcomDev_PHPUnit and using a CgiHttpKernel.

Installation

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

Usage

The suggested usage of this trait is in combination with EcomDev_PHPUnit and the Webgriffe's Magento Config Extension. So, first of all, add these dependencies to your Magento project:

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

Then setup your test suite as usual with EcomDev_PHPUnit.

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

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:

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

It's important that your test extends the EcomDev_PHPUnit_Test_Case_Controller class to correctly load Magento's frontend area configuration.

As you may notice there is the @loadFixture annotation which loads data from category.yaml file located at tests/HomepageTest/fixtures/category.yaml which content could be:

Multiple website supported

If you want you can create a client for different websites:

This will use the secondary website base URL and sets the MAGE_RUN_TYPE and MAGE_RUN_CODE environment variables.

Test debug with xDebug

Sometimes you need to debug your application during functional test execution. To do so you create an xDebug enabled client by passing true to the createClient() method:

Don't forget to configure the XDEBUG_SESSION cookie value in your app/etc/local.xml file according your IDE settings. For example for PHPStorm on MAC this value should be PHPSTORM:

Open response in browser

Sometimes is useful to open last response returned by Magento in your browser for further analysis. To do so you can use the openResponseInBrowser() method, for example:

This will dump the last response's content in a temporary file and opens it with a system command. Don't forget to configure the open file in browser command for your system in the app/etc/local.xml (the %s placeholder will be replaced with the temporary file path). For example on MAC you can use open %s:

Different front controller

It's also possible to specify an alternative front controller instead of index.php. This is extremely useful when you have to serve static file through the front controller get.php provided by Magento:

License

This library is under the MIT license. See the complete license in the LICENSE file.

Credits

Developed by Webgriffe®. Please, report to us any bug or suggestion by GitHub issues.


All versions of functional-test-trait with dependencies

PHP Build Version
Package Version
Requires webgriffe/cgi-http-kernel Version ^1.1
symfony/browser-kit Version ^3.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package webgriffe/functional-test-trait contains the following files

Loading the files please wait ....