2014-05-31 4 views
0

Я просто пытался следовать за http://docs.behat.org/cookbook/behat_and_mink.html Аркадама+ Behat Норка: отсутствует сеанс

Я установил норка + Behat с помощью следующей composer.json:

"require": { 
     "behat/behat": "2.4.*@stable", 
     "behat/mink": "1.4.*@stable", 
     "behat/mink-extension": "*", 
     "behat/mink-goutte-driver": "*", 
     "behat/mink-selenium2-driver": "*" 
    }, 
    "minimum-stability": "dev", 
    "config": { 
     "bin-dir": "bin/" 
    } 
} 

Я сделал инициализацию, который создал каталог функций ,

bin/behat --init 

Я создал search.features в каталоге функций:

Feature: Search 
    In order to see a word definition 
    As a website user 
    I need to be able to search for a word 

    Scenario: Searching for a page that does exist 
    Given I am on "/wiki/Main_Page" 
    When I fill in "search" with "Behavior Driven Development" 
    And I press "searchButton" 
    Then I should see "agile software development" 

    Scenario: Searching for a page that does NOT exist 
    Given I am on "/wiki/Main_Page" 
    When I fill in "search" with "Glory Driven Development" 
    And I press "searchButton" 
    Then I should see "Search results" 

Я обновил функции/начальной загрузки/FeatureContext.php продлить MinkContext.

Если я запустить бен/behat -dl я вижу следующие определения нагрузить:

Given /^(?:|I)am on (?:|the)homepage$/ 
When /^(?:|I)go to (?:|the)homepage$/ 
Given /^(?:|I)am on "(?P<page>[^"]+)"$/ 
When /^(?:|I)go to "(?P<page>[^"]+)"$/ 
When /^(?:|I)reload the page$/ 
When /^(?:|I)move backward one page$/ 
When /^(?:|I)move forward one page$/ 
When /^(?:|I)press "(?P<button>(?:[^"]|\\")*)"$/ 
When /^(?:|I)follow "(?P<link>(?:[^"]|\\")*)"$/ 
When /^(?:|I)fill in "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/ 
When /^(?:|I)fill in "(?P<field>(?:[^"]|\\")*)" with:$/ 
When /^(?:|I)fill in "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)"$/ 
When /^(?:|I)fill in the following:$/ 
When /^(?:|I)select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/ 
When /^(?:|I)additionally select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/ 
When /^(?:|I)check "(?P<option>(?:[^"]|\\")*)"$/ 
When /^(?:|I)uncheck "(?P<option>(?:[^"]|\\")*)"$/ 
When /^(?:|I)attach the file "(?P[^"]*)" to "(?P<field>(?:[^"]|\\")*)"$/ 
Then /^(?:|I)should be on "(?P<page>[^"]+)"$/ 
Then /^(?:|I)should be on (?:|the)homepage$/ 
Then /^the (?i)url(?-i) should match (?P<pattern>"([^"]|\\")*")$/ 
Then /^the response status code should be (?P<code>\d+)$/ 
Then /^the response status code should not be (?P<code>\d+)$/ 
Then /^(?:|I)should see "(?P<text>(?:[^"]|\\")*)"$/ 
Then /^(?:|I)should not see "(?P<text>(?:[^"]|\\")*)"$/ 
Then /^(?:|I)should see text matching (?P<pattern>"(?:[^"]|\\")*")$/ 
Then /^(?:|I)should not see text matching (?P<pattern>"(?:[^"]|\\")*")$/ 
Then /^the response should contain "(?P<text>(?:[^"]|\\")*)"$/ 
Then /^the response should not contain "(?P<text>(?:[^"]|\\")*)"$/ 
Then /^(?:|I)should see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/ 
Then /^(?:|I)should not see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/ 
Then /^the "(?P<element>[^"]*)" element should contain "(?P<value>(?:[^"]|\\")*)"$/ 
Then /^the "(?P<element>[^"]*)" element should not contain "(?P<value>(?:[^"]|\\")*)"$/ 
Then /^(?:|I)should see an? "(?P<element>[^"]*)" element$/ 
Then /^(?:|I)should not see an? "(?P<element>[^"]*)" element$/ 
Then /^the "(?P<field>(?:[^"]|\\")*)" field should contain "(?P<value>(?:[^"]|\\")*)"$/ 
Then /^the "(?P<field>(?:[^"]|\\")*)" field should not contain "(?P<value>(?:[^"]|\\")*)"$/ 
Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should be checked$/ 
Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" (?:is|should be) checked$/ 
Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should not be checked$/ 
Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" should (?:be unchecked|not be checked)$/ 
Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" is (?:unchecked|not checked)$/ 
Then /^(?:|I)should see (?P<num>\d+) "(?P<element>[^"]*)" elements?$/ 
Then /^print current URL$/ 
Then /^print last response$/ 
Then /^show last response$/ 

Но я стараюсь на самом деле проверить search.features, я получаю сообщение об ошибке:

PHP Fatal error: Call to a member function getSession() on a non-object in /home/nishant/behat/vendor/behat/mink-extension/src/Behat/MinkExtension/Context/RawMinkContext.php on line 103 

I сделал Google, что может быть ошибкой, но не нашел ничего более полезного, говорящего, чтобы поставить behat.yml в нужное место.

My bin/behat -> ../vendor/behat/behat/bin/behat - это символическая ссылка, и я попытался поставить behat.yml в vendor/behat/behat/behat.yml. content on behat.yml

default: 
    extensions: 
     Behat\MinkExtension\Extension: 
      base_url: http://en.wikipedia.org 
      goutte: ~ 
      selenium2: ~ 

Любая помощь будет очень признательна !!

Если я иду к поставщику/behat/behat и создать search.feature и запустить бен/behat я получаю ошибку:

[ReflectionException] 
    Class Guzzle\Http\Client does not exist 
+2

Пожалуйста, дайте Ваш вопрос подходящее название. И нет, «Behat норка - новичок» ** не подходит. Теги должны быть удалены из заголовка, а оставшееся слово «новичок» должно быть заменено чем-то, описывающим вашу фактическую проблему. – JensG

ответ

4

Ok .. мне удалось исправить мою проблему!

Добавлены эти строки в моем методе __construct() в особенности/начальной загрузки/FeatureContext.php

$clientOptions = array(); 
$client = new \Behat\Mink\Driver\Goutte\Client(); 
$client->setClient(new \Guzzle\Http\Client('', $clientOptions)); 
$driver = new \Behat\Mink\Driver\GoutteDriver($client); 

Также обновлен мой composer.json к

{ 
    "require": { 
     "behat/behat": "2.4.*@stable", 
     "behat/mink": "1.4.*@stable", 
     "behat/mink-extension": "*", 
     "behat/mink-goutte-driver": "1.0.*", 
     "behat/mink-selenium2-driver": "*", 
     "guzzle/http": "*" 
    }, 
    "minimum-stability": "dev", 
    "config": { 
     "bin-dir": "bin/" 
    } 
} 
+0

Мне не нужны эти строки в моем методе __construct(), однако у меня это было в файле behat.yml: 'default_session: goutte'. Возможно, они делают то же самое. – zkent

Смежные вопросы