本文整理汇总了PHP中TestController::handleRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP TestController::handleRequest方法的具体用法?PHP TestController::handleRequest怎么用?PHP TestController::handleRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestController
的用法示例。
在下文中一共展示了TestController::handleRequest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: form_appears_and_saves
/**
* @test
*/
public function form_appears_and_saves()
{
Config::inst()->update('Controller', 'extensions', array('QuickFeedbackExtension'));
$controller = new TestController();
$result = $controller->handleRequest(new SS_HTTPRequest('GET', 'form_appears_and_saves'), DataModel::inst());
$body = $result->getBody();
$this->assertContains('Form_QuickFeedbackForm', $body);
$this->assertContains('Form_QuickFeedbackForm_Rating', $body);
$this->assertContains('Form_QuickFeedbackForm_Comment', $body);
preg_match('/action="([^"]+)"/', $body, $action);
if (!count($action)) {
$this->fail('No form action');
}
preg_match('/name="SecurityID" value="([^"]+)"/', $body, $token);
if (!count($action)) {
$this->fail('No token');
}
$parts = explode('/', $action[1]);
$action = end($parts);
$time = time();
$data = ['SecurityID' => $token[1], 'Rating' => '0', 'Comment' => 'comment at ' . $time];
$controller->handleRequest(new SS_HTTPRequest('POST', $action, array(), $data), DataModel::inst());
$existing = Feedback::get()->filter('Comment', 'comment at ' . $time)->first();
if (!$existing) {
$this->fail('Record missing');
}
}
开发者ID:helpfulrobot,项目名称:mandrew-silverstripe-quickfeedback,代码行数:30,代码来源:QuickFeedbackExtensionTest.php