-
Notifications
You must be signed in to change notification settings - Fork 24
PR a repositorio base para corrección - grupo 2 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
5515793
c79157f
c99e6a6
e9d6834
5a60738
b46b447
223d244
5445eee
f63c654
43e9aeb
576c53d
d165b6c
4bf580d
fada1ef
fe03a80
f5f5add
1a261dc
af4eafe
bf1cae4
9917089
8c4c1d8
3967a40
114d4da
597fc0a
45abdcd
e7d6cba
49d732e
a8b75fa
2cd8992
01b069e
ec84a16
99fea98
dd04c0d
13c4490
a75a863
f5b605c
8322d7b
4d50658
70843b3
dd8f219
532c1e8
3bcc649
ebd839d
d566c52
099ce6b
2b4a8eb
9a27c24
b27bd1b
b0932cb
07033f4
3e9eca2
b250399
666ffb0
cef0635
da82a4e
c6d4227
11f524e
c45cfc7
fb50982
d47a233
3d15809
b98e625
5136bbf
583b7c8
b20f8c8
33f1424
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| readme: | ||
| - src/README.md | ||
| - README.md | ||
|
|
||
| feature: | ||
| - src/app/**/* | ||
|
|
||
| tests: | ||
| - src/tests/**/* | ||
|
|
||
| good practices: | ||
| - git-hooks/**/* | ||
| - .github/workflows/**/* | ||
|
|
||
| automation: | ||
| - git-hooks/**/* | ||
| - .github/workflows/**/* | ||
|
|
||
| code quality: | ||
| - git-hooks/**/* | ||
| - .github/workflows/**/* | ||
|
|
||
| composer: | ||
| - src/composer.json | ||
| - composer.json | ||
|
|
||
| database: | ||
| - src/database/**/* | ||
|
|
||
| docker: | ||
| -docker/docker | ||
| -Dockerfile | ||
| -docker-compose.yml | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # This workflow will triage pull requests and apply a label based on the | ||
| # paths that are modified in the pull request. | ||
| # | ||
| # To use this workflow, you will need to set up a .github/labeler.yml | ||
| # file with configuration. For more information, see: | ||
| # https://github.com/actions/labeler | ||
|
|
||
| name: Labeler | ||
| on: [pull_request] | ||
|
|
||
| jobs: | ||
| label: | ||
|
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/labeler@v2 | ||
| with: | ||
| repo-token: "${{ secrets.GITHUB_TOKEN }}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| name: Laravel Validation | ||
| on: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice |
||
| push: | ||
| pull_request: | ||
| branches: | ||
| - develop | ||
|
|
||
| jobs: | ||
| validation: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Setup | ||
| run: | | ||
| docker-compose up -d | ||
| docker ps | ||
| - name: Build | ||
| run: | | ||
| docker exec -i laravel-php sh | ||
| cd src | ||
| composer install | ||
| cp .env.example .env | ||
| php artisan package:discover | ||
| php artisan key:generate | ||
| #- name: Database migation | ||
| # run: | | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No es necesario, eliminadlo |
||
| # docker exec -i laravel-php sh | ||
| # cd src | ||
| # php artisan migrate | ||
| #- name: Database migation | ||
| # run: | | ||
| # docker exec -i laravel-php sh | ||
| # cd src | ||
| # php artisan db:seed | ||
| - name: Linter | ||
| run: | | ||
| docker exec -i laravel-php sh | ||
| cd src | ||
| ./vendor/bin/phpcs -n app/* | ||
| ./vendor/bin/phpcs -n bootstrap/app.php | ||
| ./vendor/bin/phpcs -n config/* | ||
| ./vendor/bin/phpcs -n database/* | ||
| ./vendor/bin/phpcs -n postman/* | ||
| ./vendor/bin/phpcs -n public/* | ||
| ./vendor/bin/phpcs -n resources/* | ||
| ./vendor/bin/phpcs -n routes/* | ||
| ./vendor/bin/phpcs -n tests/* | ||
| - name: Test | ||
| run: | | ||
| docker exec -i laravel-php sh | ||
| cd src | ||
| ./vendor/bin/phpunit | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <?php | ||
|
|
||
| namespace App\DataSource\Database; | ||
|
|
||
| use App\Models\User; | ||
| use Exception; | ||
|
|
||
| class EloquentUser540DataSource | ||
| { | ||
| public function findByEmail($email): User | ||
| { | ||
| $user = User::query()->where('email', $email)->first(); | ||
| if (is_null($user)) { | ||
| throw new Exception('User not found'); | ||
| } | ||
| return $user; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,6 @@ public function __invoke(string $email): JsonResponse | |
| { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Este fichero no se utiliza, podríais eliminarlo, no aporta y es lo que viene de ejemplo |
||
| try { | ||
| $isEarlyAdopter = $this->isEarlyAdopterService->execute($email); | ||
|
|
||
| } catch (Exception $exception) { | ||
| return response()->json([ | ||
| 'error' => $exception->getMessage() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?php | ||
|
|
||
| namespace App\Models; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esto deberíais haberlo borrado, no movido :) |
||
|
|
||
| use Illuminate\Contracts\Auth\MustVerifyEmail; | ||
| use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
| use Illuminate\Database\Eloquent\Model; | ||
| use Illuminate\Foundation\Auth\User as Authenticatable; | ||
| use Illuminate\Notifications\Notifiable; | ||
|
|
||
| class User540 extends Model | ||
| { | ||
| use HasFactory; | ||
|
|
||
| protected $fillable = ['id', 'name', 'email']; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?php | ||
|
|
||
| namespace Database\Factories; | ||
|
|
||
| use App\Models\User540; | ||
| use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
|
||
| class User540Factory extends Factory | ||
| { | ||
| /** | ||
| * The name of the factory's corresponding model. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $model = User::class; | ||
|
|
||
| /** | ||
| * Define the model's default state. | ||
| * | ||
| * @return array | ||
| */ | ||
| public function definition() | ||
| { | ||
| return [ | ||
| 'id' => 1, | ||
| 'name' => 'user_name', | ||
| 'email' => 'email@email.com' | ||
| ]; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| <?php | ||
|
|
||
| namespace Tests\Integration\DataSources; | ||
|
|
||
| use App\DataSource\Database\EloquentUser540DataSource; | ||
| use App\Models\User540; | ||
| use Exception; | ||
| use Illuminate\Foundation\Testing\RefreshDatabase; | ||
| use Tests\TestCase; | ||
|
|
||
| class EloquentUserDataSourceTest extends TestCase | ||
| { | ||
| use RefreshDatabase; | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function findsUserByEmail() | ||
| { | ||
| User540::factory(User540::class)->create(); | ||
| $eloquentUserDataSource = new EloquentUser540DataSource(); | ||
|
|
||
| $user = $eloquentUserDataSource->findByEmail('email@email.com'); | ||
|
|
||
| $this->assertInstanceOf(User::class, $user); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function noUserIsFoundForTheGivenEmailI() | ||
| { | ||
| $eloquentUserDataSource = new EloquentUser540DataSource(); | ||
|
|
||
| $this->expectException(Exception::class); | ||
|
|
||
| $eloquentUserDataSource->findByEmail('email@email.com'); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function noUserIsFoundForTheGivenEmailII() | ||
| { | ||
| User540::factory(User540::class)->create(); | ||
| $eloquentUserDataSource = new EloquentUser540DataSource(); | ||
|
|
||
| try { | ||
| $eloquentUserDataSource->findByEmail('not_known@email.com'); | ||
| } catch (Exception $exception) { | ||
| $this->assertEquals('User not found', $exception->getMessage()); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice