Created
May 30, 2012 14:56
-
-
Save DavertMik/2836843 to your computer and use it in GitHub Desktop.
Codeception SOAP Suite RFC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use \Codeception\Utils\Soap; | |
$I = new ApiGuy($scenario); | |
$I->wantTo('get all unpassed surveys'); | |
$I->haveSoapHeader('AuthHeader', array(), 'ns'); | |
$I->haveSoapHeader('SessionHeader', array(), 'ns'); | |
$I->sendSoapRequest('GetRespondentConsentForm', Soap::request() | |
->survey | |
->set('id', $survey_id) | |
->questions->item | |
->set('id', $question_id); | |
->answers->item | |
->set('id', $answer_id) | |
->attributes->item | |
->set('id', 1) | |
->set('value', 123); | |
->parent('answers') // back to answers element | |
->item | |
->set('id', 2) | |
->parent(); | |
); | |
$I->seeSoapResponseEquals(Soap::response()->result->is(1)); | |
$I->seeSoapResponseMatches(Soap::response() | |
->result->Aliases->Alias | |
->attr('Id', 1) | |
->Name | |
->is('alias1') | |
); | |
$I->dontSeeSoapResponsMatches('fail'); | |
$I->seeInRepository('Survey', array('name' => 'New Survey!')); | |
$I->seeEmailIsSent(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Endpoint задается в конфигурации модуля (1 раз на все тесты) | |
Soap::request() - строит XML да и только | |
Soap::response() - строит XML, просто небольшие отличия в синтаксисе. | |
То есть, если конструкции окажутся громоздкие, можно тупо копировать XML'ки из SoapUI и вбивать их в тест. | |
sendSoapRequest - отправляет реквест. Параметр - строка или xml. | |
seeSoapResponseEquals - принимает XML в виде параметра и проверяет полноев совпадение тела ответа | |
seeSoapResponseMatches - принимает любую строку в виде параметра и проверяет, что она есть в теле ответа | |
по идее можно в респонсе каждый элемент проверять отдельным ассертом. Может так и будет... | |
seeInRepository - проверяет наличие записи в репозитории | |
seeEmailSent - проверяет отправку имейла | |
это стандартные плюшки кодсепшна ;) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment