Browse Source

Separate field validation test on full feature test

tags/1.2.9
Nafies Luthfi 7 years ago
parent
commit
6764661f90
  1. 14
      src/stubs/testcases/feature/full.stub
  2. 42
      tests/Generators/FeatureTestGeneratorTest.php

14
src/stubs/testcases/feature/full.stub

@ -45,19 +45,31 @@ class ManageMasterTest extends TestCase
}
/** @test */
public function create_master_action_must_pass_validations()
public function validate_master_name_is_required()
{
$this->loginAsUser();
// Name empty
$this->post(route('masters.store'), $this->getCreateFields(['name' => '']));
$this->assertSessionHasErrors('name');
}
/** @test */
public function validate_master_name_is_not_more_than_60_characters()
{
$this->loginAsUser();
// Name 70 characters
$this->post(route('masters.store'), $this->getCreateFields([
'name' => str_repeat('Test Title', 7),
]));
$this->assertSessionHasErrors('name');
}
/** @test */
public function validate_master_description_is_not_more_than_255_characters()
{
$this->loginAsUser();
// Description 256 characters
$this->post(route('masters.store'), $this->getCreateFields([

42
tests/Generators/FeatureTestGeneratorTest.php

@ -101,19 +101,31 @@ class Manage{$this->model_name}Test extends TestCase
}
/** @test */
public function create_{$this->lang_name}_action_must_pass_validations()
public function validate_{$this->lang_name}_name_is_required()
{
\$this->loginAsUser();
// Name empty
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['name' => '']));
\$this->assertSessionHasErrors('name');
}
/** @test */
public function validate_{$this->lang_name}_name_is_not_more_than_60_characters()
{
\$this->loginAsUser();
// Name 70 characters
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([
'name' => str_repeat('Test Title', 7),
]));
\$this->assertSessionHasErrors('name');
}
/** @test */
public function validate_{$this->lang_name}_description_is_not_more_than_255_characters()
{
\$this->loginAsUser();
// Description 256 characters
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([
@ -298,19 +310,31 @@ class Manage{$this->model_name}Test extends TestCase
}
/** @test */
public function create_{$this->lang_name}_action_must_pass_validations()
public function validate_{$this->lang_name}_name_is_required()
{
\$this->loginAsUser();
// Name empty
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['name' => '']));
\$this->assertSessionHasErrors('name');
}
/** @test */
public function validate_{$this->lang_name}_name_is_not_more_than_60_characters()
{
\$this->loginAsUser();
// Name 70 characters
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([
'name' => str_repeat('Test Title', 7),
]));
\$this->assertSessionHasErrors('name');
}
/** @test */
public function validate_{$this->lang_name}_description_is_not_more_than_255_characters()
{
\$this->loginAsUser();
// Description 256 characters
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([
@ -447,19 +471,31 @@ class Manage{$this->model_name}Test extends TestCase
}
/** @test */
public function create_{$this->lang_name}_action_must_pass_validations()
public function validate_{$this->lang_name}_name_is_required()
{
\$this->loginAsUser();
// Name empty
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['name' => '']));
\$this->assertSessionHasErrors('name');
}
/** @test */
public function validate_{$this->lang_name}_name_is_not_more_than_60_characters()
{
\$this->loginAsUser();
// Name 70 characters
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([
'name' => str_repeat('Test Title', 7),
]));
\$this->assertSessionHasErrors('name');
}
/** @test */
public function validate_{$this->lang_name}_description_is_not_more_than_255_characters()
{
\$this->loginAsUser();
// Description 256 characters
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([

Loading…
Cancel
Save