public function testCreateSession() { //Пусть сразу вошли на /#/game и пытаемся отправить ответ //(для простоты тестирования есть тестовая форма /answer) U::get('/answer', $client, $crawler, $html, $json); $form = $crawler->selectButton('Send')->form(array('answer_id' => 4, 'quest_id' => 5)); $client->submit($form); $response = $client->getResponse(); $jsonResponseData = json_decode($response->getContent()); $this->assertTrue($jsonResponseData->info == 'Lost session'); //А теперь сначала создадим пользователя ATL::createUser($userJson, $repository, $username, $em, $client); //Пробуем ответить на вопрос U::get('/answer', $client, $crawler, $html, $json); $form = $crawler->selectButton('Send')->form(array('answer_id' => 4, 'quest_id' => 5)); $client->submit($form); $response = $client->getResponse(); $jsonResponseData = json_decode($response->getContent()); $this->assertTrue(@$jsonResponseData->info != 'Lost session'); $this->assertTrue(@$jsonResponseData->info == 'Answer #4 not found!'); ATL::deleteUser($em, $userJson->id); }
/** * Отвечаем на существующий вопрос несуществующим ответом. */ public function testNoExistsAnswer() { ATL::createUser($userJson, $r, $name, $em, $client); $questions = $this->_getExistsQuestions(); $this->assertTrue(count($questions) > 1); $question = $questions[0]; $json = $this->_sendAnswer(1, $question->getId(), $client, $status); $this->assertTrue($status == 404); $this->assertTrue($json->info == 'Answer #1 not found!'); ATL::deleteUser($em, $userJson->id); }