My controller is as follows,
class LoginAdminController extends Controller
{
public function loginAdmin($username, $password)
{
dd($username);
//check valid admin credentials
$pwd = admin_users::select('adm_password')->where('adm_username', $username)->first();
if(!empty($pwd))
{
if(Crypt::decrypt($pwd->adm_password) == $password)
{
$admin_users = admin_users::select('adm_user_id')->where('adm_username', $username)->first();
if(!empty($admin_users->adm_user_id))
{
return $admin_users->adm_user_id;
}
else
{
return FALSE;
}
}
else
{
return FALSE;
}
}
else
{
return FALSE;
}
}
}
My unit test case is follows,
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\Http\Controllers\Auth\LoginAdminController;
class LoginAdminTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
use WithoutMiddleware;
public function setUp()
{
parent::setUp();
}
public function testloginAdminValidData()
{
$response = $this->action('get', 'LoginAdminController@index');
var_dump($response->getContent());
}
}
I have to test this loginAdmin()
function for unit testing. There is no route defined for this method in routes.php
. Can I call this method directly from test case? If yes, then please give me command to call it with parameters. Thanks in advance
Aucun commentaire:
Enregistrer un commentaire