Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
89 | public function testManagerCreate() |
||
90 | { |
||
91 | $newJob = [ |
||
92 | 'term_qty' => $this->faker->numberBetween(1, 4), |
||
93 | 'salary_min' => $this->faker->numberBetween(60000, 80000), |
||
94 | 'salary_max' => $this->faker->numberBetween(80000, 100000), |
||
95 | 'noc' => $this->faker->numberBetween(1, 9999), |
||
96 | 'classification' => $this->faker->regexify('[A-Z]{2}-0[1-5]'), |
||
97 | 'manager_id' => $this->manager->id, |
||
98 | 'published' => $this->faker->boolean(50), |
||
99 | 'remote_work_allowed' => $this->faker->boolean(50), |
||
100 | 'open_date' => $this->faker->date('Y-m-d', strtotime('+1 day')), |
||
101 | 'open_time' => $this->faker->time(), |
||
102 | 'close_date' => $this->faker->date('Y-m-d', strtotime('+2 weeks')), |
||
103 | 'close_time' => $this->faker->time(), |
||
104 | 'start_date_time' => $this->faker->date('Y-m-d', strtotime('+2 weeks')) . ' ' . $this->faker->time(), |
||
105 | 'security_clearance' => SecurityClearance::inRandomOrder()->first()->id, |
||
106 | 'language_requirement' => LanguageRequirement::inRandomOrder()->first()->id, |
||
107 | 'department' => Department::inRandomOrder()->first()->id, |
||
108 | 'province' => Province::inRandomOrder()->first()->id, |
||
109 | 'city' => $this->faker->city, |
||
110 | 'title' => [ |
||
111 | 'en' => $this->faker->word, |
||
112 | 'fr' => $this->faker_fr->word |
||
113 | ], |
||
114 | 'impact' => [ |
||
115 | 'en' => $this->faker->paragraphs( |
||
116 | 2, |
||
117 | true |
||
118 | ), |
||
119 | 'fr' => $this->faker_fr->paragraphs( |
||
120 | 2, |
||
121 | true |
||
122 | ) |
||
123 | ], |
||
124 | 'branch' => [ |
||
125 | 'en' => $this->faker->word, |
||
126 | 'fr' => $this->faker_fr->word |
||
127 | ], |
||
128 | 'division' => [ |
||
129 | 'en' => $this->faker->word, |
||
130 | 'fr' => $this->faker_fr->word |
||
131 | ], |
||
132 | 'education' => [ |
||
133 | 'en' => $this->faker->sentence(), |
||
134 | 'fr' => $this->faker_fr->sentence() |
||
135 | ], |
||
136 | 'submit' => '', |
||
137 | ]; |
||
138 | |||
139 | $dbValues = array_slice($newJob, 0, 6); |
||
140 | |||
141 | $response = $this->followingRedirects() |
||
142 | ->actingAs($this->manager->user) |
||
143 | ->post('manager/jobs/', $newJob); |
||
144 | $response->assertStatus(200); |
||
145 | $response->assertViewIs('manager.job_index'); |
||
146 | $this->assertDatabaseHas('job_posters', $dbValues); |
||
147 | } |
||
171 |