Reputation:
I am new in PHP. I tried to make a login form in laravel 5.
I have this controller method. It works properly.
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);
}
and i am testing this with phpunit test. The class is given below.
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());
}}
It shows following error. I don't understand what to do. Please help.
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
Upvotes: 2
Views: 1772
Reputation: 60048
Its probably related to the fact that L5 is not in beta - and Taylor is still working on the testing code. It is due to enter beta next week, so I'd wait until then.
There are other issues in the current alpha L5 for phpunit - like this: https://github.com/laravel/framework/issues/6373#issuecomment-68617032
So keep an eye on that - and when thats fixed - try a fresh install of L5 and see if it fixes your problem.
Upvotes: 1