|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Lean\Installer\Tests; |
| 4 | + |
| 5 | +use Lean\Installer\Concerns\AcceptsCredentials; |
| 6 | + |
| 7 | +class CredentialsTest extends TestCase |
| 8 | +{ |
| 9 | + /** @test */ |
| 10 | + public function credentials_are_validated_locally() |
| 11 | + { |
| 12 | + $this->expectExceptionMessage('Interrupted by user'); |
| 13 | + |
| 14 | + $this->artisan('lean:setup') |
| 15 | + ->expectsQuestion("What's your email?", 'samuel.stanclgmail.com') |
| 16 | + ->expectsOutput('Invalid email') // <-- |
| 17 | + ->expectsQuestion("What's your email?", 'samuel.stancl@gmail.com') |
| 18 | + ->expectsQuestion("What's your password?", 'foo') |
| 19 | + ->expectsOutput('Invalid credentials') |
| 20 | + ->expectsConfirmation('Retry?', 'no') |
| 21 | + ->assertExitCode(1); |
| 22 | + } |
| 23 | + |
| 24 | + /** @test */ |
| 25 | + public function if_the_server_returns_an_error_it_will_be_shown() |
| 26 | + { |
| 27 | + $this->expectExceptionMessage('Interrupted by user'); |
| 28 | + |
| 29 | + $this->artisan('lean:setup') |
| 30 | + ->expectsQuestion("What's your email?", 'samuel.stancl@gmail.com') |
| 31 | + ->expectsQuestion("What's your password?", 'foo') |
| 32 | + ->expectsOutput('Invalid credentials') // <-- |
| 33 | + ->expectsConfirmation('Retry?', 'no') |
| 34 | + ->assertExitCode(1); |
| 35 | + } |
| 36 | + |
| 37 | + // Right now there's not a scenario when this can happen, because all validation happens on both |
| 38 | + // the frontend and the backend. Keeping this test here since the behavior itself is in place |
| 39 | + // and I may want to test this sometime, when the backend returns other validation errors. |
| 40 | + // /** @test */ |
| 41 | + // public function if_the_server_returns_errors_for_specific_fields_they_will_be_shown() |
| 42 | + // { |
| 43 | + // $this->expectExceptionMessage('Interrupted by user'); |
| 44 | + |
| 45 | + // $this->artisan('lean:setup') |
| 46 | + // ->expectsQuestion("What's your email?", 'samuel.stancl@gmail.com') |
| 47 | + // ->expectsQuestion("What's your password?", 'foo') |
| 48 | + // ->expectsOutput('Invalid credentials') |
| 49 | + // ->expectsConfirmation('Retry?', 'no') |
| 50 | + // ->assertExitCode(1); |
| 51 | + // } |
| 52 | + |
| 53 | + /** @test */ |
| 54 | + public function email_defaults_to_git_email() |
| 55 | + { |
| 56 | + AcceptsCredentials::$emailOverride = 'samuel.stancl+test@gmail.com'; |
| 57 | + |
| 58 | + $this->expectExceptionMessage('Interrupted by user'); |
| 59 | + |
| 60 | + $this->artisan('lean:setup') |
| 61 | + ->expectsChoice("What's your email?", 'samuel.stancl+test@gmail.com', ['samuel.stancl+test@gmail.com']) // <-- |
| 62 | + ->expectsQuestion("What's your password?", 'foo') |
| 63 | + ->expectsOutput('Invalid credentials') |
| 64 | + ->expectsConfirmation('Retry?', 'no') |
| 65 | + ->assertExitCode(1); |
| 66 | + } |
| 67 | +} |
0 commit comments