Skip to content
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

- Add tests roles and logs #5

Merged
merged 7 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
71 changes: 71 additions & 0 deletions .env.behat
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
APP_NAME=community-with-legends
VITE_APP_NAME=community-with-legends
APP_ENV=local
APP_KEY=base64:sCsJw8z+d/4ymp0OvzSip2h4Vp2hZZhpV2uOxgTqP94=
APP_DEBUG=true
APP_URL=http://api.community-with-legends.mmr.localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=pgsql
DB_HOST=community-with-legends-db-dev
DB_PORT=5432
DB_DATABASE=community-with-legends
DB_USERNAME=community-with-legends
DB_PASSWORD=password
DB_ROOT_PASSWORD=example

SESSION_DRIVER=redis
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=redis

CACHE_STORE=redis
CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1

REDIS_CLIENT=phpredis
REDIS_HOST=community-with-legends-redis-dev
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

# DOCKER
DOCKER_APP_HOST_PORT=63861
DOCKER_DATABASE_HOST_PORT=63863
DOCKER_MAILPIT_DASHBOARD_HOST_PORT=63864
DOCKER_REDIS_HOST_PORT=63862
DOCKER_INSTALL_XDEBUG=true

DOCKER_HOST_USER_ID=1000
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ google-credentials.json
.composer
/public/build/
supervisord.pid
.php-cs-fixer.cache
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ shell-root:

test:
@docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} composer test
@docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} composer test-features

fix:
@docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} bash -c 'composer csf'
Expand Down
34 changes: 34 additions & 0 deletions app/Enums/Role.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace CommunityWithLegends\Enums;

enum Role: string
{
case User = "user";
case Administrator = "administrator";
case Moderator = "moderator";

public static function casesToSelect(): array
{
$cases = collect(Role::cases());

return $cases->map(
fn(Role $enum): array => [
"label" => $enum->label(),
"value" => $enum->value,
],
)->toArray();
}

public function label(): string
{
return __($this->value);
}

public function permissions(): array
{
return config("permission.permission_roles")[$this->value];
}
}
2 changes: 2 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;

/**
* @property string $name
Expand All @@ -23,6 +24,7 @@ class User extends Authenticatable
use HasApiTokens;
use HasFactory;
use Notifiable;
use HasRoles;

protected $fillable = [
"name",
Expand Down
20 changes: 15 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
{
"name": "blumilksoftware/community-with-legends",
"name": "mmr/community-with-legends",
"type": "project",
"description": "community-with-legends project.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/MRR-Group/blt"
}
],
"require": {
"php": "^8.3.4",
"ext-pdo": "*",
"guzzlehttp/guzzle": "^7.9.2",
"inertiajs/inertia-laravel": "^1.3.1",
"laravel/framework": "^11.34.2",
"laravel/sanctum": "^4.0.5",
"laravel/tinker": "^2.10.0"
"laravel/framework": "^11.43.2",
"laravel/sanctum": "^4.0.8",
"laravel/tinker": "^2.10.1",
"spatie/laravel-activitylog": "^4.10",
"spatie/laravel-permission": "^6.15"
},
"require-dev": {
"behat/behat": "^3.19",
"blumilksoftware/blt": "^v0.1.1",
"blumilksoftware/codestyle": "^v3.3.0",
"fakerphp/faker": "^1.24.1",
"mockery/mockery": "^1.6.12",
Expand Down Expand Up @@ -52,6 +61,7 @@
"@putenv XDEBUG_MODE=off",
"@php artisan test"
],
"test-features": "./vendor/bin/behat",
"analyse": "./vendor/bin/phpstan analyse",
"cs": "./vendor/bin/php-cs-fixer fix --dry-run --diff --config codestyle.php",
"csf": "./vendor/bin/php-cs-fixer fix --diff --config codestyle.php"
Expand Down
Loading
Loading