Skip to content

Commit

Permalink
Update local documentation build
Browse files Browse the repository at this point in the history
  • Loading branch information
tkotosz committed Apr 22, 2020
1 parent 6714d4e commit e522fd5
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 65 deletions.
5 changes: 3 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))

import sphinx_rtd_theme

# -- Project information -----------------------------------------------------

Expand Down Expand Up @@ -49,7 +49,8 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Requirements
* Magento 2 2.2+

Using Composer
----------------
--------------

The recommended installation method is through `Composer <https://getcomposer.org>`_:

.. code-block:: bash
.. code-block:: bash
$ composer require --dev bex/behat-magento2-extension
$ composer require --dev bex/behat-magento2-extension
120 changes: 60 additions & 60 deletions docs/guide/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Install Behat

If you didn't install Behat already, then you can install it with composer in the following way:

.. code-block:: bash
.. code-block:: bash
$ composer require --dev behat/behat
$ composer require --dev behat/behat
For alternative installation options check the `Behat official documentation <https://docs.behat.org/en/latest/quick_start.html#installation>`_

Expand All @@ -17,9 +17,9 @@ Install the Extension

Similarly you can install the extension via composer:

.. code-block:: bash
.. code-block:: bash
$ composer require --dev bex/behat-magento2-extension
$ composer require --dev bex/behat-magento2-extension
For more information see the the :doc:`installation section of this documentation </guide/installation>`.

Expand All @@ -28,20 +28,20 @@ Setup the Behat configuration

You need to enable the extension in the Behat configuration and configure your Behat Suite to use the Magento 2 Service Container. Your ``behat.yml`` should look like this:

.. code-block:: yaml
.. code-block:: yaml
default:
extensions:
Bex\Behat\Magento2Extension: ~
default:
extensions:
Bex\Behat\Magento2Extension: ~
suites:
application:
autowire: true
suites:
application:
autowire: true
contexts:
- FeatureContext
contexts:
- FeatureContext
services: '@bex.magento2_extension.service_container'
services: '@bex.magento2_extension.service_container'
With the above configuration:
- The extension is enabled
Expand All @@ -55,69 +55,69 @@ Verify the configuration

In order to verify that the extension is configured correctly you will need a test feature. For example create a ``features/my_feature.feature`` file like this:

.. code-block:: gherkin
.. code-block:: gherkin
Feature: Magento and Behat DI connected
As a developer
In order to write Behat tests easily
I should be able to inject services from the Magento DI into Behat Contexts
Feature: Magento and Behat DI connected
As a developer
In order to write Behat tests easily
I should be able to inject services from the Magento DI into Behat Contexts
Scenario: Injecting service from Magento DI to Behat Context as argument for Behat Context constructor
Given A service has been successfully injected through the Context constructor
When I work with Behat
Then I am happy
Scenario: Injecting service from Magento DI to Behat Context as argument for Behat Context constructor
Given A service has been successfully injected through the Context constructor
When I work with Behat
Then I am happy
Also to implement the above feature you need to add the following step definitions to your ``features/bootstrap/FeatureContext.php`` Behat Context:

.. code-block:: php
.. code-block:: php
<?php
<?php
use Behat\Behat\Context\Context;
use Exception;
use Magento\Sales\Api\OrderRepositoryInterface;
use Behat\Behat\Context\Context;
use Exception;
use Magento\Sales\Api\OrderRepositoryInterface;
class FeatureContext implements Context
{
/** @var OrderRepositoryInterface */
private $orderRepository;
class FeatureContext implements Context
{
/** @var OrderRepositoryInterface */
private $orderRepository;
public function __construct(OrderRepositoryInterface $orderRepository)
{
$this->orderRepository = $orderRepository;
}
public function __construct(OrderRepositoryInterface $orderRepository)
{
$this->orderRepository = $orderRepository;
}
/**
* @Given A service has been successfully injected through the Context constructor
*/
public function aServiceHasBeenSuccessfullyInjectedThroughTheContextConstructor()
{
if (!$this->orderRepository instanceof OrderRepositoryInterface) {
throw new Exception('Something went wrong :(');
}
/**
* @Given A service has been successfully injected through the Context constructor
*/
public function aServiceHasBeenSuccessfullyInjectedThroughTheContextConstructor()
{
if (!$this->orderRepository instanceof OrderRepositoryInterface) {
throw new Exception('Something went wrong :(');
}
}
/**
* @When I work with Behat
*/
public function iWorkWithBehat()
{
// no-op
}
/**
* @When I work with Behat
*/
public function iWorkWithBehat()
{
// no-op
}
/**
* @Then I am happy
*/
public function iAmHappy()
{
// no-op :)
}
/**
* @Then I am happy
*/
public function iAmHappy()
{
// no-op :)
}
}
Note that here we inject the Order Repository Magento service through the Context constructor, but it is also possible to inject it through the Behat Step definition as well. For more information see the :doc:`usage section of this documentation </guide/usage>`.

Run Behat and you should see the test passing.

.. code-block:: bash
.. code-block:: bash
$ bin/behat features/my_feature.feature
$ bin/behat features/my_feature.feature

0 comments on commit e522fd5

Please sign in to comment.