Skip to content

Commit

Permalink
tentando carregar as config do teste
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmmf committed May 5, 2017
1 parent 66c2b15 commit 82ca590
Show file tree
Hide file tree
Showing 31 changed files with 5,882 additions and 16 deletions.
21 changes: 21 additions & 0 deletions app/Group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php namespace App;

use Illuminate\Database\Eloquent\Model;

class Group extends Model {

protected $fillable = ["name"];

protected $dates = [];

public static $rules = [
"name" => "required",
];

public function players()
{
return $this->hasMany("App\Player");
}


}
9 changes: 9 additions & 0 deletions app/Http/Controllers/GroupsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php namespace App\Http\Controllers;

class GroupsController extends Controller {

const MODEL = "App\Group";

use RESTActions;

}
9 changes: 9 additions & 0 deletions app/Http/Controllers/PlayersController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php namespace App\Http\Controllers;

class PlayersController extends Controller {

const MODEL = "App\Player";

use RESTActions;

}
59 changes: 59 additions & 0 deletions app/Http/Controllers/RESTActions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Http\Response;

trait RESTActions {


public function all()
{
$m = self::MODEL;
return $this->respond(Response::HTTP_OK, $m::all());
}

public function get($id)
{
$m = self::MODEL;
$model = $m::find($id);
if(is_null($model)){
return $this->respond(Response::HTTP_NOT_FOUND);
}
return $this->respond(Response::HTTP_OK, $model);
}

public function add(Request $request)
{
$m = self::MODEL;
$this->validate($request, $m::$rules);
return $this->respond(Response::HTTP_CREATED, $m::create($request->all()));
}

public function put(Request $request, $id)
{
$m = self::MODEL;
$this->validate($request, $m::$rules);
$model = $m::find($id);
if(is_null($model)){
return $this->respond(Response::HTTP_NOT_FOUND);
}
$model->update($request->all());
return $this->respond(Response::HTTP_OK, $model);
}

public function remove($id)
{
$m = self::MODEL;
if(is_null($m::find($id))){
return $this->respond(Response::HTTP_NOT_FOUND);
}
$m::destroy($id);
return $this->respond(Response::HTTP_NO_CONTENT);
}

protected function respond($status, $data = [])
{
return response()->json($data, $status);
}

}
23 changes: 23 additions & 0 deletions app/Player.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php namespace App;

use Illuminate\Database\Eloquent\Model;

class Player extends Model {

protected $fillable = ["name", "group_id", "group_id"];

protected $dates = ["baithday"];

public static $rules = [
"name" => "required",
"group_id" => "numeric",
"group_id" => "required|numeric",
];

public function group()
{
return $this->belongsTo("App\Group");
}


}
4 changes: 3 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class AppServiceProvider extends ServiceProvider
*/
public function register()
{
//
// if ($this->app->environment() == 'local') {
$this->app->register('Wn\Generators\CommandsServiceProvider');
// }
}
}
8 changes: 5 additions & 3 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

require_once __DIR__.'/../vendor/autoload.php';
$envFile = defined('RUNNING_TESTS') ? '.env.testing' : '.env';

try {
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
//
echo 'deu merda no dotenv';
}

/*
Expand All @@ -23,9 +25,9 @@
realpath(__DIR__.'/../')
);

// $app->withFacades();
$app->withFacades();

// $app->withEloquent();
$app->withEloquent();

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -77,7 +79,7 @@
| totally optional, so you are not required to uncomment this line.
|
*/

$app->register('Wn\Generators\CommandsServiceProvider');
// $app->register(App\Providers\AppServiceProvider::class);
// $app->register(App\Providers\AuthServiceProvider::class);
// $app->register(App\Providers\EventServiceProvider::class);
Expand Down
10 changes: 10 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ paths:
data: tests/_data
support: tests/_support
envs: tests/_envs
env_file: .env.behat
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
extensions:
enabled:
- Codeception\Extension\RunFailed
modules:
config:
Db:
dsn: 'mysql:host=localhost;dbname=core_test'
user: 'root'
password: 'entrar'
dump: 'tests/_data/dump.sql'
populate: false
cleanup: true
15 changes: 14 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@
"symfony/http-foundation": "3.2.*",
"behat/behat": "^3.3",
"behat/mink": "^1.7",
"behat/mink-extension": "^2.2"
"behat/mink-extension": "^2.2",
"wn/lumen-generators": "^1.3",
"vlucas/phpdotenv": "^2.4"
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/",
"database/"
]
}
}
50 changes: 48 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions config/database.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
return [
'default' => 'local',
'migrations' => 'migrations',
'connections' => [
'local' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'core',
'username' => 'root',
'password' => 'entrar',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'testing' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'core_test',
'username' => 'root',
'password' => 'entrar',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
],
];
30 changes: 30 additions & 0 deletions config/testing/database.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
return [

'default' => 'local',
'migrations' => 'migrations',
'connections' => [
'local' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'core_test',
'username' => 'root',
'password' => 'entrar',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'testing' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'core_test',
'username' => 'root',
'password' => 'entrar',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
],
];
1,831 changes: 1,831 additions & 0 deletions database/adminer.php

Large diffs are not rendered by default.

Loading

0 comments on commit 82ca590

Please sign in to comment.