Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
martiendt authored and StyleCIBot committed Nov 4, 2017
1 parent cdcec4f commit 5c03104
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 58 deletions.
5 changes: 3 additions & 2 deletions app/Http/Controllers/RegisterController.php
Expand Up @@ -2,13 +2,14 @@

namespace App\Http\Controllers;

use App\User;
use App\Http\Requests\User\StoreUserRequest;
use App\Http\Resources\UserResource as UserResource;
use App\User;

class RegisterController extends Controller
{
public function register(StoreUserRequest $request) {
public function register(StoreUserRequest $request)
{
$user = new User;
$user->name = $request->name;
$user->email = $request->email;
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/UserController.php
Expand Up @@ -2,10 +2,10 @@

namespace App\Http\Controllers;

use App\User;
use App\Http\Resources\UserResource;
use App\Http\Requests\User\StoreUserRequest;
use App\Http\Requests\User\UpdateUserRequest;
use App\Http\Resources\UserResource;
use App\User;

class UserController extends Controller
{
Expand Down Expand Up @@ -77,7 +77,7 @@ public function destroy($id)
User::find($id)->delete();

return response([
'message' => 'success delete user : ' . $user->name
'message' => 'success delete user : '.$user->name,
]);
}
}
2 changes: 1 addition & 1 deletion app/Http/Requests/User/StoreUserRequest.php
Expand Up @@ -26,7 +26,7 @@ public function rules()
return [
'name' => 'required|max:255|unique:users',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:8|max:255'
'password' => 'required|min:8|max:255',
];
}
}
4 changes: 2 additions & 2 deletions app/Http/Requests/User/UpdateUserRequest.php
Expand Up @@ -24,8 +24,8 @@ public function authorize()
public function rules()
{
return [
'name' => 'required|max:255|unique:users,id,' . $this->id,
'email' => 'required|email|max:255|unique:users,id,' . $this->id
'name' => 'required|max:255|unique:users,id,'.$this->id,
'email' => 'required|email|max:255|unique:users,id,'.$this->id,
];
}
}
7 changes: 3 additions & 4 deletions app/Providers/AuthServiceProvider.php
Expand Up @@ -2,10 +2,9 @@

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
use Laravel\Passport\Passport;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

class AuthServiceProvider extends ServiceProvider
{
Expand All @@ -27,7 +26,7 @@ public function boot()
{
$this->registerPolicies();

Route::group(['prefix' => 'api/v1'], function() {
Route::group(['prefix' => 'api/v1'], function () {
Passport::routes();
});
}
Expand Down
2 changes: 1 addition & 1 deletion app/User.php
Expand Up @@ -2,9 +2,9 @@

namespace App;

use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;

class User extends Authenticatable
{
Expand Down
4 changes: 1 addition & 3 deletions public/index.php
@@ -1,12 +1,10 @@
<?php

/**
* Laravel - A PHP Framework For Web Artisans
* Laravel - A PHP Framework For Web Artisans.
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/

define('LARAVEL_START', microtime(true));

/*
Expand Down
4 changes: 1 addition & 3 deletions server.php
@@ -1,12 +1,10 @@
<?php

/**
* Laravel - A PHP Framework For Web Artisans
* Laravel - A PHP Framework For Web Artisans.
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/

$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/RegisterationTest.php
Expand Up @@ -2,8 +2,8 @@

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class RegisterationTest extends TestCase
{
Expand All @@ -15,10 +15,10 @@ public function user_can_register()
$response = $this->json('POST', 'api/v1/register', [
'name' => 'John',
'email' => 'john.doe@gmail.com',
'password' => 'secret-password'
'password' => 'secret-password',
], [
'Accept' => 'application/json',
'Content-Type' => 'application/json'
'Content-Type' => 'application/json',
]);

$response->assertStatus(201);
Expand Down
44 changes: 22 additions & 22 deletions tests/Feature/UserTest.php
Expand Up @@ -3,9 +3,9 @@
namespace Tests\Feature;

use App\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Passport\Passport;
use Tests\TestCase;
use Laravel\Passport\Passport;
use Illuminate\Foundation\Testing\RefreshDatabase;

class UserTest extends TestCase
{
Expand All @@ -26,7 +26,7 @@ public function user_can_create_user()
$this->json('POST', 'api/v1/user', [
'name' => 'John',
'email' => 'john.doe@gmail.com',
'password' => 'secret-password'
'password' => 'secret-password',
], [$this->header])->assertStatus(201);

$this->assertInstanceOf(User::class, $this->user);
Expand All @@ -35,14 +35,14 @@ public function user_can_create_user()
/** @test */
public function user_can_read_single_user()
{
$this->json('GET', 'api/v1/user/' . $this->user->id, [], [$this->header])->assertJson([
"data" => [
"id" => $this->user->id,
"name" => $this->user->name,
"email" => $this->user->email,
"created_at" => $this->user->created_at,
"updated_at" => $this->user->updated_at,
]
$this->json('GET', 'api/v1/user/'.$this->user->id, [], [$this->header])->assertJson([
'data' => [
'id' => $this->user->id,
'name' => $this->user->name,
'email' => $this->user->email,
'created_at' => $this->user->created_at,
'updated_at' => $this->user->updated_at,
],
]);
}

Expand All @@ -57,17 +57,17 @@ public function user_can_read_all_user()
/** @test */
public function user_can_update_user()
{
$response = $this->json('PUT', 'api/v1/user/' . $this->user->id, [
"name" => "another name",
"email" => "another@email.com",
$response = $this->json('PUT', 'api/v1/user/'.$this->user->id, [
'name' => 'another name',
'email' => 'another@email.com',
], [$this->header])->assertJson([
"data" => [
"id" => $this->user->id,
"name" => "another name",
"email" => "another@email.com",
"created_at" => $this->user->created_at,
"updated_at" => $this->user->updated_at,
]
'data' => [
'id' => $this->user->id,
'name' => 'another name',
'email' => 'another@email.com',
'created_at' => $this->user->created_at,
'updated_at' => $this->user->updated_at,
],
]);

$response->assertStatus(200);
Expand All @@ -76,6 +76,6 @@ public function user_can_update_user()
/** @test */
public function user_can_delete_user()
{
$this->json('DELETE', 'api/v1/user/' . $this->user->id, [], [$this->header])->assertStatus(200);
$this->json('DELETE', 'api/v1/user/'.$this->user->id, [], [$this->header])->assertStatus(200);
}
}
5 changes: 2 additions & 3 deletions tests/TestCase.php
Expand Up @@ -9,7 +9,7 @@ abstract class TestCase extends BaseTestCase
use CreatesApplication;

/**
* Set up the test
* Set up the test.
*/
public function setUp()
{
Expand All @@ -21,8 +21,7 @@ public function setUp()

$this->header = [
'Accept' => 'application/json',
'Content-Type' => 'application/json'
'Content-Type' => 'application/json',
];
}

}
21 changes: 10 additions & 11 deletions tests/Unit/UserTest.php
Expand Up @@ -3,9 +3,9 @@
namespace Tests\Unit;

use App\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Passport\Passport;
use Tests\TestCase;
use Laravel\Passport\Passport;
use Illuminate\Foundation\Testing\RefreshDatabase;

class UserTest extends TestCase
{
Expand Down Expand Up @@ -37,21 +37,21 @@ public function name_should_be_unique()
$response = $this->json('POST', 'api/v1/user', [
'name' => 'John',
'email' => 'john.doe@gmail.com',
'password' => 'secret-password'
'password' => 'secret-password',
], [
'Accept' => 'application/json',
'Content-Type' => 'application/json'
'Content-Type' => 'application/json',
]);

$response->assertStatus(201);

$response = $this->json('POST', 'api/v1/user', [
'name' => 'John',
'email' => 'john.moe@gmail.com',
'password' => 'secret-password'
'password' => 'secret-password',
], [
'Accept' => 'application/json',
'Content-Type' => 'application/json'
'Content-Type' => 'application/json',
]);

$response->assertStatus(422);
Expand All @@ -63,24 +63,23 @@ public function email_should_be_unique()
$response = $this->json('POST', 'api/v1/user', [
'name' => 'John Doe',
'email' => 'john@gmail.com',
'password' => 'secret-password'
'password' => 'secret-password',
], [
'Accept' => 'application/json',
'Content-Type' => 'application/json'
'Content-Type' => 'application/json',
]);

$response->assertStatus(201);

$response = $this->json('POST', 'api/v1/user', [
'name' => 'John Moe',
'email' => 'john@gmail.com',
'password' => 'secret-password'
'password' => 'secret-password',
], [
'Accept' => 'application/json',
'Content-Type' => 'application/json'
'Content-Type' => 'application/json',
]);

$response->assertStatus(422);
}

}

0 comments on commit 5c03104

Please sign in to comment.