Here is my Code.
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\Models\master\Company;
use App\User;
class JobReferenceControllerTest extends TestCase
{
public function setUp(){
parent::setUp();
// $this->mock = \Mockery::mock('Moloquent','App\Models\master\Company');
$company = new Company;
$company->cmp_name = 'TestCompany123';
$company->cmp_website = 'www.testcompany.com';
$company->cmp_desc = 'This is Description';
$company->cmp_employe = '0-100';
$company->save();
}
public function testAddJobWithoutTitleFunctionality(){
$company = Company::where('cmp_name','=','TestCompany123')->orderBy('created_at','desc')->first();
$status = true;
if($company == null){
$status = false;
}
$this->assertEquals($status,true);
$parameters = [
'job_description' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
'job_type' => 'WALKIN',
'job_valid_to' => '2016-07-07',
'for_company_id' => $company->_id
];
$cookies = [];
$files = [];
$user = User::where('email','=','lokesh@skoolkhojo.com')->first();
if($user != null){
$this->be($user);
}
$response = $this->action('POST', '\App\Http\Controllers\Api\Features\JobReferenceController@store', $parameters);
// var_dump($response->getContent());
$this->assertEquals(400, $response->getStatusCode());
}
public function testAddJobFunctionality(){
$this->withoutMiddleware();
$company = Company::where('cmp_name','=','TestCompany123')->orderBy('created_at','desc')->first();
$status = true;
if($company == null){
$status = false;
}
$this->assertEquals($status,true);
$parameters = [
'job_title' => 'Dummy Job',
'job_description' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
'job_type' => 'WALKIN',
'job_valid_to' => '2016-07-07',
'for_company_id' => $company->_id
];
$user = User::where('email','=','lokesh@skoolkhojo.com')->first();
if($user != null){
$this->be($user);
}
$action = '\App\Http\Controllers\Api\Features\JobReferenceController@store';
$response = $this->action('POST',$action, $parameters);
$this->assertEquals(200, $response->getStatusCode());
}
public function tearDown(){
$company = Company::where('cmp_name','=','TestCompany123')->orderBy('created_at','desc')->first();
if($company != null){
$company->delete();
}
parent::tearDown();
}
}
It execute the statement for first time
$response = $this->action('POST',$action, $parameters);
Latter says
1) JobReferenceControllerTest::testAddJobFunctionality InvalidArgumentException: Action App\Http\Controllers\Api\Features\JobReferenceController@store not defined.
/Users/lokesh/Documents/projects/skoolkhojo_v2/skoolkhojo_services/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:590 /Users/lokesh/Documents/projects/skoolkhojo_v2/skoolkhojo_services/vendor/laravel/framework/src/Illuminate/Foundation/Testing/CrawlerTrait.php:435 /Users/lokesh/Documents/projects/skoolkhojo_v2/skoolkhojo_services/tests/Http/Controllers/Api/Features/JobReferenceControllerTest.php:81
Could anyone please help me out to figure out why action method is executes perfectly for once than say action not found.
Please help me out.
Thanks in Advance.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire