Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
5515793
[] - Pre-commit hook for laravel added and README.md updated
MKoding Apr 21, 2021
c79157f
[] - Merge 540/laravel-docker into the repository
MKoding Apr 21, 2021
c99e6a6
[#2] - Pre-commit hook for PHP Unit Test updated
MKoding Apr 21, 2021
e9d6834
Create label.yml for automatic labeling
MKoding Apr 21, 2021
5a60738
[] - Create labeler.yml for automatic labeling.
MKoding Apr 21, 2021
b46b447
Update .gitignore
MKoding Apr 22, 2021
223d244
[] - Deleted mysql/ib* files
MKoding Apr 22, 2021
5445eee
Merge pull request #4 from MKoding/auto-labeling
MKoding Apr 22, 2021
f63c654
Merge pull request #3 from MKoding/pre-commit
MKoding Apr 22, 2021
43e9aeb
Merge pull request #7 from MKoding/gitignore
MKoding Apr 22, 2021
576c53d
Merge pull request #7 from MKoding/gitignore
idoate Apr 22, 2021
d165b6c
[] - updated .gitignore and testing pre-commit
idoate Apr 28, 2021
4bf580d
[] - Fixing pre-commit errors in status controller
idoate Apr 28, 2021
fada1ef
Merge pull request #18 from MKoding/gitignore
idoate Apr 28, 2021
fe03a80
[] - Updated readme.md with git rules
idoate Apr 28, 2021
f5f5add
Merge pull request #19 from MKoding/readme
MKoding Apr 28, 2021
1a261dc
[] - Pre-commit and README updated
MKoding May 5, 2021
af4eafe
[] - 540-develop merge
MKoding May 5, 2021
bf1cae4
Merge branch '540-develop' into 540-update
MKoding May 5, 2021
9917089
Merge pull request #20 from MKoding/pre-commit
MKoding May 5, 2021
8c4c1d8
Merge pull request #22 from MKoding/540-update
MKoding May 5, 2021
3967a40
[#11] - Endpoint create wallet cryptocurrency
idoate May 5, 2021
114d4da
Merge pull request #23 from MKoding/get-wallet-id
MKoding May 6, 2021
597fc0a
[] - Project cache files cleanup
MKoding May 7, 2021
45abdcd
Merge pull request #24 from MKoding/clean-project
idoate May 10, 2021
e7d6cba
[] - Added database migrations and seeders
MKoding May 11, 2021
49d732e
Merge pull request #25 from MKoding/database
idoate May 11, 2021
a8b75fa
[] - Updated database migrations and seeders with users table
MKoding May 11, 2021
2cd8992
Merge pull request #26 from MKoding/database
MKoding May 12, 2021
01b069e
[#11] - Updated and closed issue #11 'Get wallet by id'
MKoding May 12, 2021
ec84a16
Merge pull request #27 from MKoding/get-wallet
idoate May 12, 2021
99fea98
[#14] - Closed issue #14 'Get wallet by id unit tests'
MKoding May 12, 2021
dd04c0d
[#1|#8] - Closed issues #1 and #8 'Buy and sell coins endpoints'
MKoding May 13, 2021
13c4490
Merge pull request #28 from MKoding/get-wallet-test
MKoding May 13, 2021
a75a863
[#1|#8] - Updated with the changes suggested in the pull request
MKoding May 13, 2021
f5b605c
Merge pull request #29 from MKoding/buy-sell-coins
MKoding May 13, 2021
8322d7b
[#12] - Closed issue #12 'Get wallet balance by id'
MKoding May 13, 2021
4d50658
[#10] - Closed issue #10 'Open wallet by user id'
MKoding May 13, 2021
70843b3
Merge pull request #30 from MKoding/wallet-balance
MKoding May 13, 2021
dd8f219
Merge pull request #31 from MKoding/wallet-open
MKoding May 13, 2021
532c1e8
[#32|#9] - Closed issues #32 and #9 'Buy and sell coins unit tests'
MKoding May 13, 2021
3bcc649
Merge pull request #33 from MKoding/buy-sell-coins-test
MKoding May 13, 2021
ebd839d
[#15] - Closed issue #15 'Get wallet balance by id unit tests'
MKoding May 14, 2021
d566c52
[#13] - Closed issue #13 'Open wallet by user id unit tests'
MKoding May 14, 2021
099ce6b
[#37] - Closed issue #37 'Create database migations and seeders'
MKoding May 14, 2021
2b4a8eb
Merge pull request #34 from MKoding/wallet-balance-test
MKoding May 14, 2021
9a27c24
Merge pull request #38 from MKoding/wallet-open-test
MKoding May 14, 2021
b27bd1b
Merge pull request #39 from MKoding/database-migrations-seeders
MKoding May 14, 2021
b0932cb
[] - Fixed multiple bugs and improved code quality
MKoding May 14, 2021
07033f4
[] - Fixed incorrect naming in unit tests
MKoding May 14, 2021
3e9eca2
Merge pull request #40 from MKoding/debugging
MKoding May 14, 2021
b250399
[#5] - Closed issue #5 'Create auto validation for laravel project'
MKoding May 15, 2021
666ffb0
[] - Fixed some REDAME.md bugs
MKoding May 15, 2021
cef0635
Merge pull request #41 from MKoding/github-actions
MKoding May 15, 2021
da82a4e
[] - Updated README.md
MKoding May 15, 2021
c6d4227
[] - Updated labeller.yml
MKoding May 15, 2021
11f524e
[] - Fixed labeler.yml bugs
MKoding May 15, 2021
c45cfc7
Merge pull request #42 from MKoding/readme
MKoding May 15, 2021
fb50982
[#35] - Closed issue #35 'Create all the integration tests for the la…
MKoding May 15, 2021
d47a233
Merge pull request #43 from MKoding/integration-tests
MKoding May 16, 2021
3d15809
[] - Multiple bugs fixed in the tests and datasources
MKoding May 16, 2021
b98e625
[#16] - Closed issue #16 'Create all the E2E tests for the laravel pr…
MKoding May 16, 2021
5136bbf
Merge pull request #44 from MKoding/bug-fixing
MKoding May 16, 2021
583b7c8
Merge pull request #45 from MKoding/E2E-tests
MKoding May 16, 2021
b20f8c8
[] - Refactor of the code by splitting API functions in different cla…
MKoding May 17, 2021
33f1424
Merge pull request #46 from MKoding/code-refactor
MKoding May 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
readme:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

- 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
19 changes: 19 additions & 0 deletions .github/workflows/label.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 }}"
53 changes: 53 additions & 0 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Laravel Validation
on:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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: |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ bundles/
.hg/
.git/
vendor/pkg/
vendor
pyenv
Vagrantfile
Vagrantfile
mysql/ib*
*.cache
mysql/laravel/*.frm
mysql/laravel/*.ibd
18 changes: 18 additions & 0 deletions 540-example/app/datasource/database/EloquentUser540DataSource.php
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
Expand Up @@ -24,7 +24,6 @@ public function __invoke(string $email): JsonResponse
{

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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()
Expand Down
16 changes: 16 additions & 0 deletions 540-example/app/models/User540.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Models;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Up @@ -2,21 +2,21 @@

namespace App\Services\EarlyAdopter;

use App\DataSource\Database\EloquentUserDataSource;
use App\DataSource\Database\EloquentUser540DataSource;
use Exception;

class IsEarlyAdopterService
{
/**
* @var EloquentUserDataSource
* @var EloquentUser540DataSource
*/
private $eloquentUserDataSource;

/**
* IsEarlyAdopterService constructor.
* @param EloquentUserDataSource $eloquentUserDataSource
* @param EloquentUser540DataSource $eloquentUserDataSource
*/
public function __construct(EloquentUserDataSource $eloquentUserDataSource)
public function __construct(EloquentUser540DataSource $eloquentUserDataSource)
{
$this->eloquentUserDataSource = $eloquentUserDataSource;
}
Expand Down
30 changes: 30 additions & 0 deletions 540-example/database/factories/User540Factory.php
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
Expand Up @@ -2,7 +2,7 @@

namespace Tests\Integration\Controller;

use App\Models\User;
use App\Models\User540;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Response;
use Tests\TestCase;
Expand All @@ -16,7 +16,7 @@ class IsEarlyAdopterUserControllerTest extends TestCase
*/
public function noUserFoundForGivenEmail()
{
User::factory(User::class)->create();
User540::factory(User540::class)->create();

$response = $this->get('/api/user/another@email.com');

Expand All @@ -28,7 +28,7 @@ public function noUserFoundForGivenEmail()
*/
public function userIsEarlyAdopter()
{
User::factory(User::class)->create();
User540::factory(User540::class)->create();

$response = $this->get('/api/user/email@email.com');

Expand Down
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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace Tests\Unit\Services\EarlyAdopter;

use App\DataSource\Database\EloquentUserDataSource;
use App\Models\User;
use App\DataSource\Database\EloquentUser540DataSource;
use App\Models\User540;
use App\Services\EarlyAdopter\IsEarlyAdopterService;
use PHPUnit\Framework\TestCase;
use Prophecy\Prophet;

class IsEarlyAdopterServiceTest extends TestCase
{
/**
* @var EloquentUserDataSource
* @var EloquentUser540DataSource
*/
private $eloquentUserDataSource;

Expand All @@ -27,7 +27,7 @@ protected function setUp(): void
{
parent::setUp();
$prophet = new Prophet();
$this->eloquentUserDataSource = $prophet->prophesize(EloquentUserDataSource::class);
$this->eloquentUserDataSource = $prophet->prophesize(EloquentUser540DataSource::class);

$this->isEarlyAdopterService = new IsEarlyAdopterService($this->eloquentUserDataSource->reveal());
}
Expand All @@ -38,7 +38,7 @@ protected function setUp(): void
public function userIsNotEarlyAdopter()
{
$email = 'not_early_adopter@email.com';
$user = new User();
$user = new User540();
$user->fill(['id' => 9999, 'email' => $email]);

$this->eloquentUserDataSource->findByEmail($email)->shouldBeCalledOnce()->willReturn($user);
Expand All @@ -54,7 +54,7 @@ public function userIsNotEarlyAdopter()
public function userIsAnEarlyAdopter()
{
$email = 'not_early_adopter@email.com';
$user = new User();
$user = new User540();
$user->fill(['id' => 1, 'email' => $email]);

$this->eloquentUserDataSource->findByEmail($email)->shouldBeCalledOnce()->willReturn($user);
Expand Down
Loading