Download the PHP package ctasca/magefix without Composer
On this page you can find all versions of the php package ctasca/magefix. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package magefix
Magefix - Magento's Behat Fixtures Library
A library to facilitate the creation of Magento fixtures for BehatMage. The following fixture types are currently available:
- Category
- Customer
- Simple Product
- Configurable Product
- Bundle Product
- Grouped Product
- Sales Order type Guest
- Sales Order type Register
- Sales Order type Customer
- Api Role
- Api User
- Admin User
- OAuth Consumer
Please follow the below steps to get started, if you encounter any issues installing please check the Common Issues section first.
Installation
1) Add Magefix to your composer.json
Add the following to your composer.json:
2) Create the FixtureLocator
Create the FixtureLocator class in features/fixtures directory. This class has to provide a concrete implementation for
the getLocation()
method specified in Magefix\Parser\ResourceLocator
interface.
The getLocation method should return the path to the yml fixtures files. IMPORTANT: Make sure to end the path with a forward slash.
Here is an example of a ResourceLocator:
3) Autoload FixtureLocator and feature/fixtures
In your composer.json
add the following:
Run composer dump-autoload
or composer dumpautoload
to regenerate autoload file.
NOTE: More than one FixtureLocator could be created. This depends mainly on a project requirements. To use different fixture locators please refer to the Creating Fixtures and Using Many Locators sections.
Creating Fixtures
1) Create fixture yml
In the chosen fixture location, create a yml file containing the fixture definition. Examples of fixture's yml files can
be found in project's examples
directory.
Here is an example for a Magento simple product fixture:
2) Create Fixture's Data Provider
Most fixture nodes in fixtures's yml file can define dynamically generated values with the syntax {{DATA_PROVIDER_METHOD}}
.
This means the value for the node will be dynamically assigned via the given Data Provider when the fixture's yml is parsed.
Simply, Data Providers
are data-objects and should be added to the features/fixtures
directory and provide any method
specified in the fixture's yml being parsed. A ProviderMethodNotFound
exception is thrown if specified Data Provider
does not have one or more methods as part of their protocol.
It is possible to switch data provider in scope in a fixtures's yml definitions, thus allowing to re-use existing data providers. For example, when creating a Sales Order fixture, we may want to also create a product and customer fixture.
An example of a Data Provider:
3) Create Fixture in Behat's Feature class
To build the fixture during Behat run, edit the required Feature Context file and do the following:
1) Add use
statement and include Fixtures Registry
and Builder
2) Add use
statement for Fixtures Registry
trait
3) Invoke Builder::build
operation in Behat's Feature class
Available Builder's fixture type constants:
Builder::SIMPLE_PRODUCT_FIXTURE_TYPE
Builder::CUSTOMER_FIXTURE_TYPE
Builder::CATEGORY_FIXTURE_TYPE
Builder::CONFIGURABLE_PRODUCT_FIXTURE_TYPE
Builder::BUNDLE_PRODUCT_FIXTURE_TYPE
Builder::GROUPED_PRODUCT_FIXTURE_TYPE
Builder::SALES_ORDER_FIXTURE_TYPE
Builder::API_ROLE_FIXTURE_TYPE
Builder::API_USER_FIXTURE_TYPE
Builder::ADMIN_FIXTURE_TYPE
Builder::OAUTH_CONSUMER_FIXTURE_TYPE
Cleaning Fixtures
After building a fixture, to delete it via a Behat hook, simply provide the hook to Builder
's build
method.
Note: If a hook is not specified, the fixture created will not be added to Registry
for clean up, thus it won't be
deleted.
Available hooks
@BeforeSuite
@AfterSuite
@BeforeFeature
@AfterFeature
@BeforeScenario
@AfterScenario
@BeforeStep
@AfterStep
Plugins
Plugins comes in terms of Traits. The following traits are available:
AdminPanelSession
Provides operations to manage admin panel session keys.
- getCurrentUrlKey
- getSessionKeyForUrl(string)
DriverCurrentUrl
Retrieves driver's current url.
- getDriverCurrentUrl()
DriverSession
Provides functionality to refresh driver session.
- refreshSelenium2Session()
DriverSwitcher
Provides funtionality to switch driver scope between windows and i-frames.
- switchToIFrame(string|object) Accepts either a string or a SensioLabs\Behat\PageObjectExtension\PageObject\Element object
ElementObjectGetter
Provides functionality to create an Element object without providing an initial selector
- getElementObject(string)
Spinner
Provides "waiting" functionality to contexts.
-
spin(lamba, wait) where lamba is a function and wait a timeout in seconds for the operation.
-
spinUntilVisible(element, wait) Spin until element is visible. Default timeout is 60 seconds. Element can be either a string or a SensioLabs\Behat\PageObjectExtension\PageObject\Element object.
-
spinUntilInvisible(element, wait) Spin until element is not visible. Default timeout is 60 seconds. Element can be either a string or a SensioLabs\Behat\PageObjectExtension\PageObject\Element object.
-
spinAndClick(element, wait) Spin and click element. Default timeout is 60 seconds. Element can be either a string or a SensioLabs\Behat\PageObjectExtension\PageObject\Element object.
-
spinAndPress(element, wait) Spin and press element. Default timeout is 60 seconds. Element can be either a string or a SensioLabs\Behat\PageObjectExtension\PageObject\Element object.
- spinAndDo(element, action) Spin and carry out specified action on an element. Element can be either a string or a SensioLabs\Behat\PageObjectExtension\PageObject\Element object and action is a string (e.g. "press"). Also accept an optional condition and timeout. Default timeout is 60 seconds.
WindowResizer
Provides functionality to resize context windows
-
resizeToDesktopWindow(DriverInterface)
- resizeToMobileWindow(DriverInterface)
Using Many Locators
To use many locators, simply create them and make sure they are auto-loaded with composer. After being loaded, pass the
desired locator instance to Builder
's build
method.
Common Issues
As setup issues are encountered please detail with step by step fix instructions, and where possible update the project itself to provide a more permanent fix.
- There are currently no common issues reported
License
Copyright (C) 2015-2016
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 magefix with dependencies
symfony/yaml Version ~2.0
magetest/magento-behat-extension Version dev-feature/Behat3