2012-10-25 21:54:16 +03:00
|
|
|
|
Запуск функциональных тестов
|
|
|
|
|
============================
|
|
|
|
|
|
|
|
|
|
Для запуска тестов проекта нужно:
|
|
|
|
|
|
2012-10-25 21:59:38 +03:00
|
|
|
|
1) Переименовать файл config/config.test.php.dist в config/config.test.php и изменить настройки подключения к тестовой БД.
|
|
|
|
|
ВАЖНО! Информация в этой БД будет перезаписываться при каждом запуске теста.
|
2012-10-25 21:54:16 +03:00
|
|
|
|
|
2012-10-25 21:59:38 +03:00
|
|
|
|
2) В конфиге для Behat (tests/behat/behat.yml) сменить значение опции base_url на хост, под которым проект доступен локально.
|
|
|
|
|
|
2012-11-23 00:57:48 +02:00
|
|
|
|
3) Выполнить команду ```HTTP_APP_ENV=test php tests/behat/behat.phar -c tests/behat/behat.yml```. Примерный вывод результата работы команды:
|
2012-10-25 21:54:16 +03:00
|
|
|
|
|
2012-10-25 21:56:08 +03:00
|
|
|
|
```
|
2012-10-31 11:04:46 +02:00
|
|
|
|
DROP DATABASE social_test
|
|
|
|
|
CREATE DATABASE social_test
|
|
|
|
|
SELECTED DATABASE social_test
|
|
|
|
|
ExportSQL DATABASE social_test
|
|
|
|
|
ExportSQL DATABASE social_test -> geo_base
|
2012-10-25 21:59:38 +03:00
|
|
|
|
Feature: LiveStreet standart features
|
|
|
|
|
Test base functionality of LiveStreet
|
|
|
|
|
|
|
|
|
|
Scenario: See main page # features/base.feature:4
|
|
|
|
|
Given I am on homepage # FeatureContext::iAmOnHomepage()
|
|
|
|
|
When I press "Войти" # FeatureContext::pressButton()
|
|
|
|
|
Then the response status code should be 200 # FeatureContext::assertResponseStatus()
|
|
|
|
|
|
|
|
|
|
Scenario: See Colective Blog # features/base.feature:9
|
|
|
|
|
Given I am on "/blog/gadgets" # FeatureContext::visit()
|
|
|
|
|
Then I should see "Gadgets" # FeatureContext::assertPageContainsText()
|
|
|
|
|
Then I should see "Offers latest gadget reviews" # FeatureContext::assertPageContainsText()
|
|
|
|
|
|
|
|
|
|
Scenario: See list of blogs # features/base.feature:14
|
|
|
|
|
Given I am on "/blogs/" # FeatureContext::visit()
|
|
|
|
|
Then I should see "Gadgets" # FeatureContext::assertPageContainsText()
|
|
|
|
|
|
|
|
|
|
Scenario: See All Topic # features/base.feature:18
|
|
|
|
|
Given I am on "/index/newall/" # FeatureContext::visit()
|
|
|
|
|
Then I should see "iPad 3 rumored to come this March with quad-core chip and 4G LTE " # FeatureContext::assertPageContainsText()
|
|
|
|
|
Then I should see "Toshiba unveils 13.3-inch AT330 Android ICS 4.0 tablet" # FeatureContext::assertPageContainsText()
|
|
|
|
|
|
|
|
|
|
Scenario: See User Profile # features/base.feature:23
|
|
|
|
|
Given I am on "/profile/Golfer/" # FeatureContext::visit()
|
|
|
|
|
Then I should see "Sergey Doryba" # FeatureContext::assertPageContainsText()
|
|
|
|
|
Then I should see "... Sergey Doryba profile description" # FeatureContext::assertPageContainsText()
|
|
|
|
|
|
|
|
|
|
5 scenarios (5 passed)
|
|
|
|
|
14 steps (14 passed)
|
|
|
|
|
0m2.225s
|
2012-11-23 00:57:48 +02:00
|
|
|
|
```
|
2012-11-30 14:37:39 +02:00
|
|
|
|
|
|
|
|
|
4) Для тестирования плагинов используется команда
|
|
|
|
|
HTTP_APP_ENV=test php behat.phar --config='../../plugins/(название плагина)/tests/behat/behat.yml'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5) При написании дополнительных тестов используются следующие правила:
|
|
|
|
|
а) Доступ из базового контекcта к контексту MINK должен производится через функцию getMinkContext()
|
|
|
|
|
Пример получения доступа к сессии: $this->getMinkContext()->getSession()
|
|
|
|
|
|
|
|
|
|
б) Получение доступа к базовому обьекту Engine производится посредством метода: $this->getEngine()
|
|
|
|
|
|
|
|
|
|
Прим: public function getEngine() {
|
|
|
|
|
return $this->getSubcontext('base')->getEngine();
|
|
|
|
|
}
|