| Conditions | 1 |
| Paths | 1 |
| Total Lines | 109 |
| Code Lines | 62 |
| 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 |
||
| 12 | public function testFillProfile() { |
||
| 13 | |||
| 14 | // User with name / email / password, not saved to database |
||
| 15 | $user = factory(\App\Models\User::class)->make(); |
||
| 16 | |||
| 17 | // Register with factory credentials |
||
| 18 | $this->browse(function ($browser) use ($user) { |
||
| 19 | $browser->visit('/register') |
||
| 20 | ->type('name', $user->name) |
||
| 21 | ->type('email', $user->email) |
||
| 22 | ->type('password', $user->password) |
||
| 23 | ->type('password_confirmation', $user->password) |
||
| 24 | ->press('Register') |
||
| 25 | // Should be able to see My Profile after authentication |
||
| 26 | ->assertSee('My Profile'); |
||
| 27 | |||
| 28 | // Go to profile |
||
| 29 | $browser->clickLink('My Profile') |
||
| 30 | ->assertSee('About Me'); |
||
| 31 | |||
| 32 | // Go to My Experience, open accordion |
||
| 33 | $browser->clickLink('My Experience') |
||
| 34 | ->assertSee('My Experience') |
||
| 35 | ->press('Add Diploma/Degree') |
||
| 36 | ->assertSee('New Diploma/Degree'); |
||
| 37 | |||
| 38 | // Add a diploma |
||
| 39 | $browser->select('#degrees\5b new\5d \5b 1\5d degreeType', '4') |
||
| 40 | ->type('#degrees\5b new\5d \5b 1\5d degreeArea', 'Test area of study') |
||
| 41 | ->type('#degrees\5b new\5d \5b 1\5d degreeInstitution', 'Test institution'); |
||
| 42 | // TODO: Selectors for date picker |
||
| 43 | //->click('#degrees\5b new\5d \5b 1\5d degreeStartDate') |
||
| 44 | //->type('#degrees\5b new\5d \5b 1\5d degreeStartDate', ['2017'], ['{tab}'], ['0717']); |
||
| 45 | //->type('#degrees\5b new\5d \5b 1\5d degreeEndDate', '2018', ['{tab}'], '08', ['{tab}'], '18'); |
||
| 46 | |||
| 47 | $browser->script('window.scrollTo(0, 1000);'); |
||
| 48 | |||
| 49 | // Saved work sample name should be visible |
||
| 50 | $browser->assertSee('Save Diploma/Degree') |
||
| 51 | ->pause(777) // Fails without a short pause |
||
| 52 | ->press('Save Diploma/Degree') |
||
| 53 | ->assertSee('Phd, Test area of study'); |
||
| 54 | |||
| 55 | // TODO: Repeat for certification / equivalent experience |
||
| 56 | //$browser->press('Add Course/Certification') |
||
| 57 | // ->assertSee('New Course/Certification'); |
||
| 58 | |||
| 59 | // Go to My Skills page |
||
| 60 | $browser->clickLink('My Skills') |
||
| 61 | ->assertSee('My Skills') |
||
| 62 | ->press('Add Skill') |
||
| 63 | ->assertSee('New Skill'); |
||
| 64 | |||
| 65 | // Add a soft skill |
||
| 66 | $browser->select('#skill_declarations\5b new\5d \5b soft\5d \5b 1\5d skillSelection', '24') // Select dropdown by value |
||
| 67 | ->keys('#skill_declarations\5b new\5d \5b soft\5d \5b 1\5d skillSelection', |
||
| 68 | ['{tab}'], ['{tab}'], ['{arrow_right}']) // Keyboard controls were necessary to select skill level properly |
||
| 69 | ->type('#skill_declarations\5b new\5d \5b soft\5d \5b 1\5d skillDescription', 'Test skill description'); |
||
| 70 | |||
| 71 | $browser->script('window.scrollTo(0, 1000);'); |
||
| 72 | |||
| 73 | // Text corresponding to skill selection value should be visible |
||
| 74 | $browser->assertSee('Save Skill') |
||
| 75 | ->pause(777) |
||
| 76 | ->press('Save Skill') |
||
| 77 | ->assertSee('Passion'); |
||
| 78 | |||
| 79 | // TODO: Repeat for hard skill |
||
| 80 | |||
| 81 | // Go to My References, open accordion |
||
| 82 | $browser->clickLink('My References') |
||
| 83 | ->assertSee('My References') |
||
| 84 | ->press('Add Reference') |
||
| 85 | ->assertSee('New Reference'); |
||
| 86 | |||
| 87 | // Add a reference |
||
| 88 | $browser->type('#references\5b new\5d \5b 1\5d referenceName', 'Test Reference') |
||
| 89 | ->select('#references\5b new\5d \5b 1\5d referenceRelationship') // Selects random if not specified |
||
| 90 | ->type('#references\5b new\5d \5b 1\5d referenceEmail', '[email protected]') |
||
| 91 | ->type('#references\5b new\5d \5b 1\5d referenceDescription', 'Test reference description'); |
||
| 92 | |||
| 93 | // Scroll down (button click will fail if not visible on test browser screen) |
||
| 94 | $browser->script('window.scrollTo(0, 1000);'); |
||
| 95 | |||
| 96 | // Saved work sample name should be visible |
||
| 97 | $browser->assertSee('Save Reference') |
||
| 98 | ->pause(777) // Fails without a short pause |
||
| 99 | ->press('Save Reference') |
||
| 100 | ->assertSee('Test Reference'); |
||
| 101 | |||
| 102 | // Go to My Work Samples, open accordion |
||
| 103 | $browser->clickLink('My Work Samples') |
||
| 104 | ->assertSee('My Work Samples') |
||
| 105 | ->press('Add Sample') |
||
| 106 | ->assertSee('New Work Sample'); |
||
| 107 | |||
| 108 | // Add work sample data, wouln't work without copying the full selector |
||
| 109 | $browser->type('#work_samples\5b new\5d \5b 1\5d sampleName', 'Test Sample') |
||
| 110 | ->select('#work_samples\5b new\5d \5b 1\5d sampleType') // Selects random if not specified |
||
| 111 | ->type('#work_samples\5b new\5d \5b 1\5d sampleLink', 'http://talent.canada.ca') |
||
| 112 | ->type('#work_samples\5b new\5d \5b 1\5d sampleDescription', 'Test sample description'); |
||
| 113 | |||
| 114 | $browser->script('window.scrollTo(0, 1000);'); |
||
| 115 | |||
| 116 | // Saved work sample name should be visible |
||
| 117 | $browser->assertSee('Save Sample') |
||
| 118 | ->pause(777) // Fails without a short pause |
||
| 119 | ->press('Save Sample') |
||
| 120 | ->assertSee('Test Sample'); |
||
| 121 | |||
| 125 |