Download the PHP package magetest/magento-behat-extension without Composer

On this page you can find all versions of the php package magetest/magento-behat-extension. 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 magento-behat-extension

BehatMage

Build Status Scrutinizer Code Quality

Behat extension for Magento, providing Behat context with specific Magento requirements allowing you to quickly define Magento scenarios and steps to enable BDD within Magento projects.

Target

How?

Installation

Prerequisites

BehatMage requires PHP 5.3.x or greater.

Install using composer

For this document we assume the directory layout is as follows.

We are assuming you will be keeping your behat features declarations and will be calling the behat script from your project directory (one step above your Magento base dir). Of course, any other layout is possible, too. Just be aware of the following adjustments you will have to make:

First, add BehatMage to the list of dependencies inside your composer.json and be sure to register few paths for autoloading:

Then simply install it with composer:

You can read more about Composer on its official webpage.

Basic usage

Change directory to your project one and setup behat inside the directory:

The behat --init will create a features/ directory with some basic things to get your started. The output on the screen should be similar to:

Define your feature

Everything in Behat always starts with a feature that you want to describe and then implement. In this example, the feature will be give an admin user the ability to manage review visibility, so we can start by creating a features/admin_user_manages_review_visibility.feature file:

Every feature starts with this same format: a line naming the feature, followed by three lines that describe the benefit, the role and the feature itself. And while this section is required, its contents aren’t actually important to Behat or your eventual test. This section is important, however, so that each feature is described consistently and is readable by other people.

Define a scenario

Next, add the following scenario to the end of the features/admin_user_manages_review_visibility.feature file:

Each feature is defined by one or more “scenarios”, which explain how that feature should act under different conditions. This is the part that will be transformed into a test. Each scenario always follows the same basic format:

Each part of the scenario - the context, the event, and the outcome - can be extended by adding the And or But keyword:

There’s no actual difference between, Then, And But or any of the other words that start each line. These keywords are all made available so that your scenarios are natural and readable.

Executing Behat

You’ve now defined the feature and one scenario for that feature. You’re ready to see Behat in action! Try executing Behat from inside your project directory:

If everything worked correctly, you should see something like this:

Writing your step definition

Behat automatically finds the feature/admin_user_manages_review_visibility.feature file and tries to execute its Scenario as a test. However, we haven’t told Behat what to do with statements like Given the following products exist, which causes an error. Behat works by matching each statement of a Scenario to a list of regular expression “steps” that you define. In other words, it’s your job to tell Behat what to do when it sees Given the following products exist. Fortunately, Behat helps you out by printing the regular expression that you probably need in order to create that step definition:

Behat, however, is not aware yet of the Magento domain and it's requiring us to add step definitions that we likely want to skip because of their repetitive nature. We then have to make Behat be Magento aware using its configuration file behat.yml adding the following lines:

where we tell Behat which extension to load and what store we want to test.

Well done so far, we now have to tell Behat that we want to use, just for clarity, a specific sub context for every actor that we have, in our example admin user. In order to do so we have to update the features/bootstrap/FeatureContext.php file as following:

and create such a sub context as php class extending the MagentoContext provided by the BehatMage extension as following:

If we run Behat again, now that the framework is aware of the Magento domain, our output should be different and look something this:

As you can see the recommendation to add the following snippet disappeared

this because BehatMage provides already the implementation of all those common steps generally needed and required to test Magento behaviours. So now let’s use Behat’s advice and add the following to the features/bootstrap/AdminUserContext.php file:

or let Behat do it for us using the following commandline option:

Great! Now that you’ve defined all of your steps and told Behat what context to use, run Behat again:

If everything worked correctly, you should see something like this:

As you can see Behat is providing to the developer, thanks to the BehatMage extension, meaningful and useful information about the next step to take in order to implement the required behaviour. So let's add the needed code to make the first requirement of our step pass. Create the following files based on the suggested code:

Once the files have been created clear the Magento cache in order to run the setup script and add the required attribute. It's now time to run Behat again:

If everything is successful your output should now be something like this:

As you can see now that our product definition has the required attribute Behat moved onto the next step of our scenario. As you can imagine now it's only a matter of implementing, step by step, all the required tests and code to adhere to the previously defined scenario.

More about Features

More about Steps

The Context Class: MagentoContext

The BehatMage Command Line Tool

What’s Next?

Issue Submission

Make sure you've read the issue submission guidelines before you open a new issue.

Contribute

See the contributing docs

License and Authors

Authors: https://github.com/MageTest/BehatMage/contributors

Copyright (C) 2012-2013

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


All versions of magento-behat-extension with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
behat/behat Version 2.4.4
behat/mink-extension Version *
behat/mink-browserkit-driver Version *
behat/mink-goutte-driver Version *
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 magetest/magento-behat-extension contains the following files

Loading the files please wait ....