Drupal Testing: PHP: 10 - PHP Behat BDD

 

Behat

C:\xampp\htdocs
λ php composer.phar require --dev behat/behat

 

C:\xampp\htdocs
λ php composer.phar require --dev behat/behat
Using version ^3.5 for behat/behat
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 15 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-ctype (v1.9.0): Downloading (100%)
  - Installing symfony/yaml (v4.1.5): Downloading (100%)
  - Installing symfony/polyfill-mbstring (v1.9.0): Downloading (100%)
  - Installing symfony/translation (v4.1.5): Downloading (100%)
  - Installing symfony/event-dispatcher (v4.1.5): Downloading (100%)
  - Installing psr/container (1.0.0): Downloading (100%)
  - Installing symfony/dependency-injection (v4.1.5): Downloading (100%)
  - Installing symfony/console (v4.1.5): Downloading (100%)
  - Installing symfony/filesystem (v4.1.5): Downloading (100%)
  - Installing symfony/config (v4.1.5): Downloading (100%)
  - Installing symfony/class-loader (v3.4.16): Downloading (100%)
  - Installing container-interop/container-interop (1.2.0): Downloading (100%)
  - Installing behat/transliterator (v1.2.0): Downloading (100%)
  - Installing behat/gherkin (v4.5.1): Downloading (100%)
  - Installing behat/behat (v3.5.0): Downloading (100%)
symfony/translation suggests installing psr/log-implementation (To use logging capability in translator)
symfony/event-dispatcher suggests installing symfony/http-kernel
symfony/dependency-injection suggests installing symfony/expression-language (For using expressions in service container configuration)
symfony/dependency-injection suggests installing symfony/finder (For using double-star glob patterns or when GLOB_BRACE portability is required)
symfony/dependency-injection suggests installing symfony/proxy-manager-bridge (Generate service proxies to lazy load them)
symfony/console suggests installing psr/log-implementation (For using the console logger)
symfony/console suggests installing symfony/lock
symfony/console suggests installing symfony/process
symfony/class-loader suggests installing symfony/polyfill-apcu (For using ApcClassLoader on HHVM)
Writing lock file
Generating autoload files

 

composer.json

{
    "require": {
        "monolog/monolog": "1.0.*"
    },
    "autoload": {
        "classmap": [
            "src/"
        ]
    },
    "require-dev": {
        "phpunit/phpunit": "^7",
        "behat/behat": "^3.5"
    }
}

 

webdriver

C:\xampp\htdocs
λ php composer.phar require facebook/webdriver
Using version ^1.6 for facebook/webdriver
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing symfony/process (v4.1.5): Downloading (100%)
  - Installing facebook/webdriver (1.6.0): Downloading (100%)
facebook/webdriver suggests installing ext-SimpleXML (For Firefox profile creation)
Writing lock file
Generating autoload files

 

rmccue

C:\xampp\htdocs
λ php composer.phar require rmccue/requests
Using version ^1.7 for rmccue/requests
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing rmccue/requests (v1.7.0): Downloading (100%)
Writing lock file
Generating autoload files

 

composer.json

{
    "require": {
        "monolog/monolog": "1.0.*",
        "facebook/webdriver": "^1.6",
        "rmccue/requests": "^1.7"
    },
    "autoload": {
        "classmap": [
            "src/"
        ]
    },
    "require-dev": {
        "phpunit/phpunit": "^7",
        "behat/behat": "^3.5"
    }
}

 

php composer.phar info

C:\xampp\htdocs                                                                                                     
λ php composer.phar info                                                                                            
behat/behat                         v3.5.0  Scenario-oriented BDD framework for PHP 5.3                             
behat/gherkin                       v4.5.1  Gherkin DSL parser for PHP 5.3                                          
behat/transliterator                v1.2.0  String transliterator                                                   
container-interop/container-interop 1.2.0   Promoting the interoperability of container objects (DIC, SL, etc.)     
doctrine/instantiator               1.1.0   A small, lightweight utility to instantiate objects in PHP without...   
facebook/webdriver                  1.6.0   A PHP client for Selenium WebDriver                                     
monolog/monolog                     1.0.2   Logging for PHP 5.3                                                     
myclabs/deep-copy                   1.8.1   Create deep copies (clones) of your objects                             
phar-io/manifest                    1.0.3   Component for reading phar.io manifest information from a PHP Arch...   
phar-io/version                     2.0.1   Library for handling version information and constraints                
phpdocumentor/reflection-common     1.0.1   Common reflection classes used by phpdocumentor to reflect the cod...   
phpdocumentor/reflection-docblock   4.3.0   With this component, a library can provide support for annotations...   
phpdocumentor/type-resolver         0.4.0                                                                           
phpspec/prophecy                    1.8.0   Highly opinionated mocking framework for PHP 5.3+                       
phpunit/php-code-coverage           6.0.7   Library that provides collection, processing, and rendering functi...   
phpunit/php-file-iterator           2.0.2   FilterIterator implementation that filters files based on a list o...   
phpunit/php-text-template           1.2.1   Simple template engine.                                                 
phpunit/php-timer                   2.0.0   Utility class for timing                                                
phpunit/php-token-stream            3.0.0   Wrapper around PHP's tokenizer extension.                               
phpunit/phpunit                     7.3.5   The PHP Unit Testing framework.                                         
psr/container                       1.0.0   Common Container Interface (PHP FIG PSR-11)                             
rmccue/requests                     v1.7.0  A HTTP library written in PHP, for human beings.                        
sebastian/code-unit-reverse-lookup  1.0.1   Looks up which function or method a line of code belongs to             
sebastian/comparator                3.0.2   Provides the functionality to compare PHP values for equality           
sebastian/diff                      3.0.1   Diff implementation                                                     
sebastian/environment               3.1.0   Provides functionality to handle HHVM/PHP environments                  
sebastian/exporter                  3.1.0   Provides the functionality to export PHP variables for visualization    
sebastian/global-state              2.0.0   Snapshotting of global state                                            
sebastian/object-enumerator         3.0.3   Traverses array structures and object graphs to enumerate all refe...   
sebastian/object-reflector          1.1.1   Allows reflection of object attributes, including inherited and no...   
sebastian/recursion-context         3.0.0   Provides functionality to recursively process PHP variables             
sebastian/resource-operations       1.0.0   Provides a list of PHP built-in functions that operate on resources     
sebastian/version                   2.0.1   Library that helps with managing the version number of Git-hosted ...   
symfony/class-loader                v3.4.16 Symfony ClassLoader Component                                           
symfony/config                      v4.1.5  Symfony Config Component                                                
symfony/console                     v4.1.5  Symfony Console Component                                               
symfony/dependency-injection        v4.1.5  Symfony DependencyInjection Component                                   
symfony/event-dispatcher            v4.1.5  Symfony EventDispatcher Component                                       
symfony/filesystem                  v4.1.5  Symfony Filesystem Component                                            
symfony/polyfill-ctype              v1.9.0  Symfony polyfill for ctype functions                                    
symfony/polyfill-mbstring           v1.9.0  Symfony polyfill for the Mbstring extension                             
symfony/process                     v4.1.5  Symfony Process Component                                               
symfony/translation                 v4.1.5  Symfony Translation Component                                           
symfony/yaml                        v4.1.5  Symfony Yaml Component                                                  
theseer/tokenizer                   1.1.0   A small library for converting tokenized PHP source code into XML ...   
webmozart/assert                    1.3.0   Assertions to validate method input/output with nice error messages.   

 

 

 

 

Behat Runner 1st Time

T:\git\drupal85x\drupal (8.5.x -> origin)
λ vendor\bin\behat
@tag
Feature: basket
  In order to purchase products
  As a customer
  I must add proudcts to my basket

  Scenario: I add a product to my basket # features\basket.feature:25
    When I add 1 product to my basket
    Then I have 1 product in my basket

  Scenario: I add 2 products to my basket # features\basket.feature:29
    When I add 1 product to my basket
    And I add 1 more product to my basket
    Then I have 2 products in my basket

2 scenarios (2 undefined)
5 steps (5 undefined)
0m0.41s (6.99Mb)

 >> default suite has undefined steps. Please choose the context to generate snippets:

  [0] None
  [1] FeatureContext
 > 1
1

--- FeatureContext has missing steps. Define them with these snippets:

    /**
     * @When I add :arg1 product to my basket
     */
    public function iAddProductToMyBasket($arg1)
    {
        throw new PendingException();
    }

    /**
     * @Then I have :arg1 product in my basket
     */
    public function iHaveProductInMyBasket($arg1)
    {
        throw new PendingException();
    }

    /**
     * @When I add :arg1 more product to my basket
     */
    public function iAddMoreProductToMyBasket($arg1)
    {
        throw new PendingException();
    }

    /**
     * @Then I have :arg1 products in my basket
     */
    public function iHaveProductsInMyBasket($arg1)
    {
        throw new PendingException();
    }

 

 

 

 

 

 

 

 

 

 

 

Tags