本文整理汇总了PHP中TestController类的典型用法代码示例。如果您正苦于以下问题:PHP TestController类的具体用法?PHP TestController怎么用?PHP TestController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onReceive
public function onReceive($server, $fd, $fromId, $data)
{
//echo "receive \n";
$tttt = new Schedule();
$test = new TestController($server, $fd, $fromId, array());
$tttt->add($test->test());
}
示例2: testOutput
public function testOutput()
{
$obj = new TestController('id', Yii::$app);
$this->assertEquals(0, $obj->outputInfo('info'));
$this->assertEquals(0, $obj->outputSuccess('success'));
$this->assertEquals(1, $obj->outputError('error'));
}
示例3: 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
示例4: runIndex
public function runIndex($searchValue, $formInput, $returnValue, $returnValue2 = null, $returnValue3 = null)
{
Input::replace($formInput);
$controller = new TestController();
$view = $controller->index();
$tests = $view->getData()['testSet'];
if (isset($returnValue3)) {
$field3 = $returnValue3;
$field2 = $returnValue2;
} elseif (isset($returnValue2)) {
$field2 = $returnValue2;
}
$field = $returnValue;
if (is_numeric($searchValue) && $field == 'specimen_id' | $field == 'visit_id') {
if ($searchValue == '0') {
$this->assertEquals($searchValue, count($tests));
} else {
$this->assertGreaterThanOrEqual(1, count($tests));
}
} else {
foreach ($tests as $key => $test) {
if (isset($field3)) {
$this->assertEquals($searchValue, $test->{$field}->{$field2}->{$field3});
} elseif (isset($field2)) {
$this->assertEquals($searchValue, $test->{$field}->{$field2});
} else {
$this->assertEquals($searchValue, $test->{$field});
}
}
}
}
示例5: onReceive
public function onReceive($server, $fd, $fromId, $data)
{
$tttt = new Schedule();
$test = new TestController($server, $fd, array());
$tttt->add($test->test());
$tttt->run();
$this->server->send($fd, $data);
}
示例6: testCacheKeyNoRequestParams
/**
* Test cache key, no params
* @TODO Possibly load the resulting markup as a DOM object and test various children in it; this would enforce valid markup
*/
function testCacheKeyNoRequestParams()
{
$config = Config::getInstance();
$config->setValue('cache_pages', true);
$controller = new TestController(true);
$results = $controller->go();
$this->assertEqual($controller->getCacheKeyString(), '');
}
示例7: testDispatch
public function testDispatch()
{
$_SERVER['REQUEST_METHOD'] = 'GET';
$ctr = new TestController();
$ctr->theme = $this->getMock('Theme', ['render']);
$ctr->theme->expects($this->once())->method('render');
$ctr->dispatch('test1');
$this->assertEquals(1, $ctr->test1);
}
示例8: testHeader
function testHeader()
{
ob_start();
$test = new TestController();
$test->update();
$output = ob_get_contents();
ob_end_clean();
$this->assertTrue(in_array("Location: http://google.com", $test->header));
}
示例9: testResponse
/**
* Test that the Controller response object is working properly for get/set/unset of a controller property
*/
public function testResponse()
{
$controller = new TestController();
$response = new WikiaResponse('html');
// setResponse and getResponse
$controller->setResponse($response);
$this->assertEquals($response, $controller->getResponse());
// setVal and getVal
$controller->foo = 'foo';
$this->assertFalse(empty($controller->foo));
$this->assertEquals($controller->foo, 'foo');
// unset
unset($controller->foo);
$this->assertTrue(empty($controller->foo));
}
示例10: testRunAction
public function testRunAction()
{
$app = new TestApplication();
$c = new TestController('test');
$this->assertEquals($c->internal, 0);
$this->assertEquals($c->external, 0);
$this->assertEquals($c->internalFilter1, 0);
$this->assertEquals($c->internalFilter2, 0);
$this->assertEquals($c->internalFilter3, 0);
$this->assertEquals($c->externalFilter, 0);
$c->run('');
$this->assertEquals($c->internal, 0);
$this->assertEquals($c->external, 1);
$this->assertEquals($c->internalFilter1, 1);
$this->assertEquals($c->internalFilter2, 0);
$this->assertEquals($c->internalFilter3, 1);
$this->assertEquals($c->externalFilter, 1);
$c->run('internal');
$this->assertEquals($c->internal, 1);
$this->assertEquals($c->external, 1);
$this->assertEquals($c->internalFilter1, 2);
$this->assertEquals($c->internalFilter2, 1);
$this->assertEquals($c->internalFilter3, 1);
$this->assertEquals($c->externalFilter, 2);
$c->run('external');
$this->assertEquals($c->internal, 1);
$this->assertEquals($c->external, 1);
$this->assertEquals($c->internalFilter1, 3);
$this->assertEquals($c->internalFilter2, 1);
$this->assertEquals($c->internalFilter3, 1);
$this->assertEquals($c->externalFilter, 2);
$this->setExpectedException('CException');
$c->run('unknown');
}
示例11: testActionClassDiffNameAndParams
public function testActionClassDiffNameAndParams()
{
global $testquery, $testpost;
$testquery = array();
$testpost = array();
$testpost['userid'] = 'johnsmith';
$testpost['user_Name'] = 'john';
$testpost['user_Age'] = '22';
$testpost['user_Hcp'] = '10,7';
$tc = new TestController();
$tc->init();
$tc->executeAction('paramsClassAndParam2');
$this->assertInstanceOf('Person', $tc->person);
$this->assertEquals('john', $tc->person->Name);
$this->assertEquals('johnsmith', $tc->userid);
}
示例12: test_post_reauthenticate_returns_redirect
public function test_post_reauthenticate_returns_redirect()
{
$user = new TestUser();
$user->password = bcrypt('test');
Auth::shouldReceive('user')->once()->andReturn($user);
Session::set('url.intended', 'http://reauthenticate.app/auth/reauthenticate');
$request = \Illuminate\Http\Request::create('http://reauthenticate.app/auth/reauthenticate', 'POST', ['password' => 'test']);
$request->setSession(app('session.store'));
$controller = new TestController();
/** @var Illuminate\Http\RedirectResponse $response */
$response = $controller->postReauthenticate($request);
$this->assertInstanceOf(Illuminate\Http\RedirectResponse::class, $response);
$this->assertEquals('http://reauthenticate.app/auth/reauthenticate', $response->getTargetUrl());
$this->assertTrue(Session::has('reauthenticate.life'));
$this->assertTrue(Session::has('reauthenticate.authenticated'));
$this->assertTrue(Session::get('reauthenticate.authenticated'));
}
示例13: addRoutes
static function addRoutes($app, $authenticateForRole)
{
//* /test/ routes - publicly accessable test route
$app->group('/api-test', $authenticateForRole('public'), function () use($app) {
$app->map("/get/status/", function () use($app) {
TestController::getApiStatus($app);
})->via('GET', 'POST');
});
}
示例14: testARBGetSubscriptionList
public function testARBGetSubscriptionList()
{
$this->markTestSkipped('Ignoring for Travis. Will fix after release.');
//TODO
$name = defined('AUTHORIZENET_API_LOGIN_ID') && '' != AUTHORIZENET_API_LOGIN_ID ? AUTHORIZENET_API_LOGIN_ID : getenv("api_login_id");
$transactionKey = defined('AUTHORIZENET_TRANSACTION_KEY') && '' != AUTHORIZENET_TRANSACTION_KEY ? AUTHORIZENET_TRANSACTION_KEY : getenv("transaction_key");
$merchantAuthentication = new net\authorize\api\contract\v1\MerchantAuthenticationType();
$merchantAuthentication->setName($name);
$merchantAuthentication->setTransactionKey($transactionKey);
//$merchantAuthentication->setMobileDeviceId()
$refId = 'ref' . time();
$sorting = new net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType();
$sorting->setOrderBy('firstName');
$sorting->setOrderDescending(false);
$paging = new net\authorize\api\contract\v1\PagingType();
$paging->setLimit(10);
$paging->setOffset(1);
$request = new net\authorize\api\contract\v1\ARBGetSubscriptionListRequest();
$request->setSearchType('subscriptionActive');
$request->setRefId($refId);
$request->setSorting($sorting);
$request->setPaging($paging);
$request->setMerchantAuthentication($merchantAuthentication);
//$controller = new ApiOperationBase($request, 'net\authorize\api\contract\v1\ARBGetSubscriptionListResponse');
$controller = new TestController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
// Handle the response.
$this->assertNotNull($response, "null response");
$this->assertNotNull($response->getMessages());
$this->assertEquals("Ok", $response->getMessages()->getResultCode());
$this->assertEquals($response->getRefId(), $refId);
$this->assertTrue(0 < count($response->getMessages()));
foreach ($response->getMessages() as $message) {
$this->assertEquals("I00001", $message->getCode());
$this->assertEquals("Successful.", $response->getText());
}
}
示例15: initController
public static function initController()
{
TestController::$control = new TestController();
}