我是PHP新手。我试图在laravel 5中创建登录表单。
我有此控制器方法。它正常工作。
public function choosePassword(ChoosePasswordRequest $req,Client $client)
{
$fn = $req->input('username');
$pass= $req->input('password');
$req = $client->createRequest('POST', 'http://localhost:8080/app/users/create');
$postBody = $req->getBody();
$postBody->setField('user_name', $fn);
$postBody->setField('password', $pass);
echo json_encode($postBody->getFields());
echo $response = $client->send($req);
}
我正在用phpunit test对此进行测试。该类在下面给出。
class choosePasswordFormTest extends TestCase{
public function testStoreSuccess()
{
$input = array(
'password' => 'password',
'user_name' => 'Abbas',
);
Request::replace($input);
Auth::shouldReceive('attempt')
->with(
array(
'password' => 'password',
'user_name' => 'Abbas',
))
->once()
->andReturn(true);
$response = $this->action('POST', 'GitController@choosePasswords');
$content = $response->getContent();
$data = json_decode($response->getContent());
}}
它显示以下错误。我不知道该怎么办。请帮忙。
PHP Fatal error: Call to undefined method choosePasswordFormTest::getInputSource() in /home/webapp/vendor/laravel/framework/src/Illuminate/Http/Request.php on line 520 PHP Stack trace: PHP 1. {main}() /tmp/ide-phpunit.php:0 PHP 2. IDE_Base_PHPUnit_TextUI_Command::main() /tmp/ide-phpunit.php:500 PHP 3. PHPUnit_TextUI_Command->run() /tmp/ide-phpunit.php:243 PHP 4. PHPUnit_TextUI_TestRunner->doRun() phar:///home/webapp/phpunit.phar/phpunit/TextUI/Command.php:186 PHP 5. PHPUnit_Framework_TestSuite->run() /home/webapp/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:425 PHP 6. PHPUnit_Framework_TestCase->run() /home/webapp/vendor/phpunit/phpunit/src/Framework/TestSuite.php:751 PHP 7. PHPUnit_Framework_TestResult->run() /home/webapp/vendor/phpunit/phpunit/src/Framework/TestCase.php:722 PHP 8. PHPUnit_Framework_TestCase->runBare() /home/webapp/vendor/phpunit/phpunit/src/Framework/TestResult.php:643 PHP 9. PHPUnit_Framework_TestCase->runTest() /home/webapp/vendor/phpunit/phpunit/src/Framework/TestCase.php:766 PHP 10. ReflectionMethod->invokeArgs() /home/webapp/vendor/phpunit/phpunit/src/Framework/TestCase.php:881 PHP 11. choosePasswordFormTest->testStoreSuccess() /home/webapp/vendor/phpunit/phpunit/src/Framework/TestCase.php:881 PHP 12. Illuminate\Http\Request->replace() /home/webapp/tests/choosePasswordFormTest.php:16
这可能与L5不在beta中这一事实有关,泰勒仍在开发测试代码。它将于下周进入Beta版,所以我要等到那时。
当前的phpunit alpha L5中还有其他问题-像这样:https : //github.com/laravel/framework/issues/6373#issuecomment-68617032
因此,请密切注意-并在修复后-尝试重新安装L5,看看它是否可以解决您的问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句