From 6764661f90a99cb3203ec388504981a1dc167de6 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sun, 7 Oct 2018 14:53:44 +0800 Subject: [PATCH] Separate field validation test on full feature test --- src/stubs/testcases/feature/full.stub | 14 ++++++++- tests/Generators/FeatureTestGeneratorTest.php | 42 +++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/stubs/testcases/feature/full.stub b/src/stubs/testcases/feature/full.stub index 16cf7c1..f0325b4 100644 --- a/src/stubs/testcases/feature/full.stub +++ b/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([ diff --git a/tests/Generators/FeatureTestGeneratorTest.php b/tests/Generators/FeatureTestGeneratorTest.php index f5cd6a6..f58398d 100644 --- a/tests/Generators/FeatureTestGeneratorTest.php +++ b/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([