diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index d24db0d..610721f 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -42,6 +42,9 @@ jobs: - name: Install dependencies run: composer update --prefer-dist --no-progress + - name: Run PHP-CS-Fixer + run: composer cs:check + - name: Create env run: php qt core:env diff --git a/.gitignore b/.gitignore index 609ca42..8579df1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,30 @@ /vendor /.idea /nbproject/private/ -/shared/store/* -/shared/emails/* .env composer.lock -.phpunit.result.cache \ No newline at end of file +.phpunit.result.cache +.php-cs-fixer.cache +debug.log + +# Runtime data +/shared/store/* +/shared/emails/* +/shared/config/auth.php +/shared/config/modules.php + +# Generated modules +/modules + +# Published assets +/public/assets/DebugBar +/public/assets/OpenApiUi +/public/assets/Web +/public/uploads + +# Test runtime +/tests/_root/.env.testing +/tests/_root/modules +/tests/_root/shared/store/* +/tests/_root/shared/config/auth.php +/tests/_root/logs \ No newline at end of file diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..e52085f --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,36 @@ +in(__DIR__) + ->exclude([ + 'vendor', + 'modules', + 'public/assets', + 'public/uploads', + ]) + ->name('*.php'); + +return (new Config()) + ->setRiskyAllowed(false) + ->setRules([ + // Base standard + '@PSR12' => true, + + // Syntax & consistency + 'array_syntax' => ['syntax' => 'short'], + 'binary_operator_spaces' => ['default' => 'single_space'], + 'cast_spaces' => ['space' => 'single'], + 'concat_space' => ['spacing' => 'one'], + 'single_quote' => true, + 'trailing_comma_in_multiline' => true, + 'no_unused_imports' => true, + 'no_extra_blank_lines' => true, + 'blank_line_after_namespace' => true, + 'blank_line_after_opening_tag' => true, + ]) + ->setFinder($finder); diff --git a/composer.json b/composer.json index df05418..cc135be 100644 --- a/composer.json +++ b/composer.json @@ -5,6 +5,7 @@ "license": "MIT", "type": "project", "require": { + "php": "^7.4 || ^8.0", "quantum/framework": "dev-master", "fakerphp/faker": "^1.15", "bluemmb/faker-picsum-photos-provider": "^2.0", @@ -13,7 +14,8 @@ }, "require-dev": { "phpunit/phpunit": "^9.0", - "mockery/mockery": "^1.2" + "mockery/mockery": "^1.2", + "friendsofphp/php-cs-fixer": "^3.94" }, "autoload": { "psr-4": { @@ -35,6 +37,8 @@ "php qt install:debugbar", "php qt core:version" ], + "cs:check": "vendor/bin/php-cs-fixer check", + "cs:fix": "vendor/bin/php-cs-fixer fix", "test": "vendor/bin/phpunit --stderr --coverage-clover coverage.xml" }, "config": { diff --git a/helpers/functions.php b/helpers/functions.php index 96b06de..5b0fe4b 100644 --- a/helpers/functions.php +++ b/helpers/functions.php @@ -26,7 +26,7 @@ */ function url_with_lang(string $lang): string { - if (!in_array($lang, (array)config()->get('lang.supported'))) { + if (!in_array($lang, (array) config()->get('lang.supported'))) { $lang = config()->get('lang.default'); } @@ -35,7 +35,7 @@ function url_with_lang(string $lang): string } if (preg_match('/' . preg_quote(current_lang()) . '/', route_uri())) { - return base_url() . preg_replace('/' . preg_quote(current_lang(), '/') . "/", $lang, route_uri(), 1); + return base_url() . preg_replace('/' . preg_quote(current_lang(), '/') . '/', $lang, route_uri(), 1); } $url = base_url(true); @@ -47,7 +47,7 @@ function url_with_lang(string $lang): string if (!empty(route_prefix()) && $langSegmentIndex == 1) { $langSegmentIndex += 1; - $uri = preg_replace('/' . preg_quote(route_prefix(), '/') . "/", '', route_uri(), 1); + $uri = preg_replace('/' . preg_quote(route_prefix(), '/') . '/', '', route_uri(), 1); } $segments = explode('/', $uri); @@ -103,7 +103,7 @@ function create_user_directory(string $uuid) { $userDirectory = uploads_dir() . DS . $uuid; - if(!fs()->isDirectory($userDirectory)) { + if (!fs()->isDirectory($userDirectory)) { fs()->makeDirectory($userDirectory); } } @@ -143,4 +143,4 @@ function nav_ref_decode(?string $ref): string $decoded = $ref ? base64_decode(strtr($ref, '-_', '+/'), true) : false; return '/posts' . ($decoded ? '?' . $decoded : ''); -} \ No newline at end of file +} diff --git a/migrations/create_table_comments_1698145440.php b/migrations/create_table_comments_1698145440.php index 94525cf..c0fe8fc 100644 --- a/migrations/create_table_comments_1698145440.php +++ b/migrations/create_table_comments_1698145440.php @@ -5,7 +5,6 @@ class Create_table_comments_1698145440 extends QtMigration { - public function up(?TableFactory $tableFactory) { $table = $tableFactory->create('comments'); diff --git a/migrations/create_table_posts_1669639752.php b/migrations/create_table_posts_1669639752.php index 03de208..f7473e7 100644 --- a/migrations/create_table_posts_1669639752.php +++ b/migrations/create_table_posts_1669639752.php @@ -5,7 +5,6 @@ class Create_table_posts_1669639752 extends QtMigration { - public function up(?TableFactory $tableFactory) { $table = $tableFactory->create('posts'); diff --git a/migrations/create_table_users_1669639740.php b/migrations/create_table_users_1669639740.php index 9d2f146..dfea921 100644 --- a/migrations/create_table_users_1669639740.php +++ b/migrations/create_table_users_1669639740.php @@ -5,7 +5,6 @@ class Create_table_users_1669639740 extends QtMigration { - public function up(?TableFactory $tableFactory) { $table = $tableFactory->create('users'); diff --git a/public/index.php b/public/index.php index a72c6a7..ca2a8e2 100644 --- a/public/index.php +++ b/public/index.php @@ -15,12 +15,13 @@ * Directory separator * ----------------------------------------------------------------------------- */ -if (!defined('DS')) define('DS', DIRECTORY_SEPARATOR); - +if (!defined('DS')) { + define('DS', DIRECTORY_SEPARATOR); +} /* * ----------------------------------------------------------------------------- * Starting the app * ----------------------------------------------------------------------------- */ -AppFactory::create(AppType::WEB, dirname(__DIR__))->start(); \ No newline at end of file +AppFactory::create(AppType::WEB, dirname(__DIR__))->start(); diff --git a/shared/Commands/CommandValidationTrait.php b/shared/Commands/CommandValidationTrait.php index aef9a95..5a7f7cf 100644 --- a/shared/Commands/CommandValidationTrait.php +++ b/shared/Commands/CommandValidationTrait.php @@ -26,7 +26,6 @@ */ trait CommandValidationTrait { - /** * @var Validator */ @@ -78,4 +77,4 @@ public function firstError(): ?string return null; } -} \ No newline at end of file +} diff --git a/shared/Commands/CommentCreateCommand.php b/shared/Commands/CommentCreateCommand.php index b36ec0d..14dadca 100644 --- a/shared/Commands/CommentCreateCommand.php +++ b/shared/Commands/CommentCreateCommand.php @@ -29,7 +29,6 @@ */ class CommentCreateCommand extends QtCommand { - use CommandValidationTrait; /** @@ -102,4 +101,4 @@ protected function validationRules(): array ], ]; } -} \ No newline at end of file +} diff --git a/shared/Commands/CommentDeleteCommand.php b/shared/Commands/CommentDeleteCommand.php index fccbb3e..f56c1a4 100644 --- a/shared/Commands/CommentDeleteCommand.php +++ b/shared/Commands/CommentDeleteCommand.php @@ -126,4 +126,4 @@ private function deleteAllComments() $this->info('All comments have been deleted successfully'); } -} \ No newline at end of file +} diff --git a/shared/Commands/DemoCommand.php b/shared/Commands/DemoCommand.php index 53e3318..a49df88 100644 --- a/shared/Commands/DemoCommand.php +++ b/shared/Commands/DemoCommand.php @@ -41,11 +41,10 @@ */ class DemoCommand extends QtCommand { - /** * Default password for generated users */ - const DEFAULT_PASSWORD = 'password'; + public const DEFAULT_PASSWORD = 'password'; /** * Command name @@ -70,7 +69,7 @@ class DemoCommand extends QtCommand * @var array */ protected array $options = [ - ['yes', 'y', 'none', 'Acceptance of the confirmations'] + ['yes', 'y', 'none', 'Acceptance of the confirmations'], ]; /** @@ -150,7 +149,7 @@ public function exec(): void } $progress->finish(); - $this->info(PHP_EOL . "Demo project created successfully"); + $this->info(PHP_EOL . 'Demo project created successfully'); } /** @@ -162,39 +161,39 @@ private function getSteps(): array return [ [ 'message' => 'Creating API module', - 'action' => function() { + 'action' => function () { $this->createModule('Api', 'DemoApi', false); - } + }, ], [ 'message' => 'Creating Web module', - 'action' => function() { + 'action' => function () { $this->createModule('Web', 'DemoWeb', true); - } + }, ], [ 'message' => 'Cleaning up uploads & rebuilding database', - 'action' => function() { + 'action' => function () { $this->resetDatabase(); - } + }, ], [ 'message' => 'Generating users', - 'action' => function() { + 'action' => function () { $this->generatedUsers = $this->generateUsers(); - } + }, ], [ 'message' => 'Generating posts', - 'action' => function() { + 'action' => function () { $this->generatedPosts = $this->generatePosts($this->generatedUsers); - } + }, ], [ 'message' => 'Generating comments', - 'action' => function() { + 'action' => function () { $this->generateComments($this->generatedUsers, $this->generatedPosts); - } + }, ], ]; } @@ -227,7 +226,7 @@ private function createModule(string $moduleName, string $template, bool $withAs 'module' => $moduleName, '--yes' => true, '--template' => $template, - '--with-assets' => $withAssets + '--with-assets' => $withAssets, ]); } @@ -296,7 +295,7 @@ private function generateComments(array $users, array $posts): void $this->runCommandInternally(self::COMMANDS['comment_create'], [ 'post_uuid' => $post['uuid'], 'user_uuid' => $commentUser['uuid'], - 'content' => textCleanUp($this->faker->realText(rand(20, 100))), + 'content' => textCleanUp($this->faker->realText(rand(20, 100))), ]); } } @@ -332,7 +331,7 @@ private function generateUserData(): array 'lastname' => $this->faker->lastName(), 'uuid' => $userUuid, 'role' => Role::EDITOR, - 'image' => $imageName + 'image' => $imageName, ]; } @@ -375,7 +374,7 @@ private function generatePostData(array $user): array */ private function getRandomUserExcept(array $users, string $excludeUuid): array { - $candidates = array_filter($users, function($u) use ($excludeUuid) { + $candidates = array_filter($users, function ($u) use ($excludeUuid) { return $u['uuid'] !== $excludeUuid; }); @@ -458,7 +457,7 @@ private function resetDatabase(): void private function runCommandInternally(string $commandName, array $arguments = []) { $command = $this->getApplication()->find($commandName); - $command->run(new ArrayInput($arguments), new NullOutput); + $command->run(new ArrayInput($arguments), new NullOutput()); } /** @@ -496,19 +495,21 @@ private function buildCommand(string $commandName, array $arguments): array foreach ($arguments as $key => $value) { if (!is_int($key) && substr($key, 0, 2) !== '--') { - $command[] = (string)$value; + $command[] = (string) $value; continue; } if (is_bool($value)) { - if ($value) $command[] = $key; + if ($value) { + $command[] = $key; + } continue; } if (is_array($value)) { foreach ($value as $item) { $command[] = $key; - $command[] = (string)$item; + $command[] = (string) $item; } continue; } @@ -519,9 +520,9 @@ private function buildCommand(string $commandName, array $arguments): array continue; } - $command[] = (string)$value; + $command[] = (string) $value; } return $command; } -} \ No newline at end of file +} diff --git a/shared/Commands/PostCreateCommand.php b/shared/Commands/PostCreateCommand.php index 2959d8c..1700590 100644 --- a/shared/Commands/PostCreateCommand.php +++ b/shared/Commands/PostCreateCommand.php @@ -29,7 +29,6 @@ */ class PostCreateCommand extends QtCommand { - use CommandValidationTrait; /** @@ -112,4 +111,4 @@ protected function validationRules(): array ], ]; } -} \ No newline at end of file +} diff --git a/shared/Commands/PostDeleteCommand.php b/shared/Commands/PostDeleteCommand.php index 067baed..8699d45 100644 --- a/shared/Commands/PostDeleteCommand.php +++ b/shared/Commands/PostDeleteCommand.php @@ -27,7 +27,6 @@ */ class PostDeleteCommand extends QtCommand { - /** * Command name * @var string|null @@ -123,8 +122,8 @@ private function deleteSinglePost(string $uuid) */ private function deleteAllPosts() { - service(PostService::class)->deleteAllPosts(); + service(PostService::class)->deleteAllPosts(); $this->info('All posts have been deleted successfully'); } -} \ No newline at end of file +} diff --git a/shared/Commands/PostShowCommand.php b/shared/Commands/PostShowCommand.php index 9eea6c4..db9dd5d 100644 --- a/shared/Commands/PostShowCommand.php +++ b/shared/Commands/PostShowCommand.php @@ -29,16 +29,15 @@ */ class PostShowCommand extends QtCommand { - /** * Posts per page */ - const POSTS_PER_PAGE = 20; + public const POSTS_PER_PAGE = 20; /** * Current page */ - const CURRENT_PAGE = 1; + public const CURRENT_PAGE = 1; /** * Command name @@ -63,7 +62,7 @@ class PostShowCommand extends QtCommand * @var array */ protected array $args = [ - ['uuid', 'optional', 'Post uuid'] + ['uuid', 'optional', 'Post uuid'], ]; /** @@ -128,7 +127,7 @@ private function composeTableRow(array $item, int $maxContentLength = 25): array $item['title'] ?? '', $content, $item['author'], - $item['date'] ?? '' + $item['date'] ?? '', ]; } -} \ No newline at end of file +} diff --git a/shared/Commands/PostUpdateCommand.php b/shared/Commands/PostUpdateCommand.php index dcaf540..639c782 100644 --- a/shared/Commands/PostUpdateCommand.php +++ b/shared/Commands/PostUpdateCommand.php @@ -29,7 +29,6 @@ */ class PostUpdateCommand extends QtCommand { - use CommandValidationTrait; /** @@ -55,7 +54,7 @@ class PostUpdateCommand extends QtCommand * @var array */ protected array $args = [ - ['uuid', 'required', 'Post uuid'] + ['uuid', 'required', 'Post uuid'], ]; /** @@ -126,4 +125,4 @@ protected function validationRules(): array ], ]; } -} \ No newline at end of file +} diff --git a/shared/Commands/UserCreateCommand.php b/shared/Commands/UserCreateCommand.php index bc114fd..92a9c42 100644 --- a/shared/Commands/UserCreateCommand.php +++ b/shared/Commands/UserCreateCommand.php @@ -32,7 +32,6 @@ */ class UserCreateCommand extends QtCommand { - use CommandValidationTrait; /** @@ -128,4 +127,4 @@ protected function validationRules(): array ], ]; } -} \ No newline at end of file +} diff --git a/shared/Commands/UserDeleteCommand.php b/shared/Commands/UserDeleteCommand.php index b3dc81d..a8a0654 100644 --- a/shared/Commands/UserDeleteCommand.php +++ b/shared/Commands/UserDeleteCommand.php @@ -27,7 +27,6 @@ */ class UserDeleteCommand extends QtCommand { - /** * Command name * @var string|null @@ -114,4 +113,4 @@ private function deleteAllUsers() $this->info('All users have been deleted successfully'); } -} \ No newline at end of file +} diff --git a/shared/Commands/UserShowCommand.php b/shared/Commands/UserShowCommand.php index 6a43d7a..bef7d4a 100644 --- a/shared/Commands/UserShowCommand.php +++ b/shared/Commands/UserShowCommand.php @@ -29,7 +29,6 @@ */ class UserShowCommand extends QtCommand { - /** * Command name * @var string|null @@ -53,7 +52,7 @@ class UserShowCommand extends QtCommand * @var array */ protected array $args = [ - ['uuid', 'optional', 'User uuid'] + ['uuid', 'optional', 'User uuid'], ]; /** @@ -109,4 +108,4 @@ private function composeTableRow(array $item): array $item['role'] ?? '', ]; } -} \ No newline at end of file +} diff --git a/shared/DTOs/CommentDTO.php b/shared/DTOs/CommentDTO.php index 8d4d3c9..8da7d7f 100644 --- a/shared/DTOs/CommentDTO.php +++ b/shared/DTOs/CommentDTO.php @@ -60,7 +60,7 @@ public function __construct( */ public static function fromRequest(Request $request, string $postUuid, string $userUuid): self { - return new self($postUuid, $userUuid, trim((string)$request->get('content'))); + return new self($postUuid, $userUuid, trim((string) $request->get('content'))); } public function getPostUuid(): string diff --git a/shared/Enums/Role.php b/shared/Enums/Role.php index cdab1a7..24c3bb3 100644 --- a/shared/Enums/Role.php +++ b/shared/Enums/Role.php @@ -20,7 +20,7 @@ */ class Role { - const ADMIN = 'admin'; + public const ADMIN = 'admin'; - const EDITOR = 'editor'; -} \ No newline at end of file + public const EDITOR = 'editor'; +} diff --git a/shared/Models/Comment.php b/shared/Models/Comment.php index bb2480b..8b8e368 100644 --- a/shared/Models/Comment.php +++ b/shared/Models/Comment.php @@ -25,7 +25,6 @@ */ class Comment extends DbModel { - use HasTimestamps; use SoftDeletes; @@ -63,7 +62,7 @@ public function relations(): array 'type' => Relation::BELONGS_TO, 'foreign_key' => 'user_uuid', 'local_key' => 'uuid', - ] + ], ]; } -} \ No newline at end of file +} diff --git a/shared/Models/Post.php b/shared/Models/Post.php index 4227b7c..c176599 100644 --- a/shared/Models/Post.php +++ b/shared/Models/Post.php @@ -25,7 +25,6 @@ */ class Post extends DbModel { - use HasTimestamps; use SoftDeletes; @@ -64,7 +63,7 @@ public function relations(): array 'type' => Relation::BELONGS_TO, 'foreign_key' => 'user_uuid', 'local_key' => 'uuid', - ] + ], ]; } -} \ No newline at end of file +} diff --git a/shared/Models/User.php b/shared/Models/User.php index e6fba2a..19977fd 100644 --- a/shared/Models/User.php +++ b/shared/Models/User.php @@ -23,7 +23,6 @@ */ class User extends DbModel { - use HasTimestamps; /** @@ -59,4 +58,4 @@ class User extends DbModel 'otp_expires', 'otp_token', ]; -} \ No newline at end of file +} diff --git a/shared/Services/AuthService.php b/shared/Services/AuthService.php index c669b7a..8cbee97 100644 --- a/shared/Services/AuthService.php +++ b/shared/Services/AuthService.php @@ -31,7 +31,6 @@ */ class AuthService extends QtService implements AuthServiceInterface { - /** * @var User */ @@ -183,8 +182,8 @@ private function createUserDirectory(string $uuid) { $userDirectory = uploads_dir() . DS . $uuid; - if(!fs()->isDirectory($userDirectory)) { + if (!fs()->isDirectory($userDirectory)) { fs()->makeDirectory($userDirectory); } } -} \ No newline at end of file +} diff --git a/shared/Services/CommentService.php b/shared/Services/CommentService.php index 47afc5c..bd41d40 100644 --- a/shared/Services/CommentService.php +++ b/shared/Services/CommentService.php @@ -28,7 +28,6 @@ */ class CommentService extends QtService { - /** * @var Comment */ @@ -130,4 +129,4 @@ public function transformData(array $comments): array { return transform($comments, $this->transformer); } -} \ No newline at end of file +} diff --git a/shared/Services/PostService.php b/shared/Services/PostService.php index c32e08b..1fdca3b 100644 --- a/shared/Services/PostService.php +++ b/shared/Services/PostService.php @@ -39,7 +39,6 @@ */ class PostService extends QtService { - /** * @var DbModel */ @@ -91,7 +90,7 @@ public function getPosts(?int $perPage = null, ?int $currentPage = null, ?string $criterias = [ ['title', 'LIKE', $searchTerm], - ['content', 'LIKE', $searchTerm] + ['content', 'LIKE', $searchTerm], ]; $query->criterias($criterias); @@ -252,4 +251,4 @@ public function transformData(array $posts): array { return transform($posts, $this->transformer); } -} \ No newline at end of file +} diff --git a/shared/Transformers/PostTransformer.php b/shared/Transformers/PostTransformer.php index f328cd3..6eafb88 100644 --- a/shared/Transformers/PostTransformer.php +++ b/shared/Transformers/PostTransformer.php @@ -22,7 +22,6 @@ */ class PostTransformer implements TransformerInterface { - /** * Transforms the post data * @param $item @@ -36,7 +35,7 @@ public function transform($item): array 'content' => markdown_to_html($item->content, true), 'image' => $item->image ? $item->user_directory . '/' . $item->image : null, 'date' => date('Y/m/d H:i', strtotime($item->updated_at)), - 'author' => $item->firstname . ' ' . $item->lastname + 'author' => $item->firstname . ' ' . $item->lastname, ]; } -} \ No newline at end of file +} diff --git a/shared/config/cache.php b/shared/config/cache.php index 8e0e8df..3ece17a 100644 --- a/shared/config/cache.php +++ b/shared/config/cache.php @@ -19,24 +19,23 @@ 'file' => [ 'prefix' => str_replace(' ', '', env('APP_NAME')), 'path' => base_dir() . DS . 'cache' . DS . 'data', - 'ttl' => 600 + 'ttl' => 600, ], 'database' => [ 'prefix' => str_replace(' ', '', env('APP_NAME')), 'table' => 'cache', - 'ttl' => 60 + 'ttl' => 60, ], 'memcached' => [ 'prefix' => str_replace(' ', '', env('APP_NAME')), 'host' => '127.0.0.1', 'port' => 11211, - 'ttl' => 60 + 'ttl' => 60, ], 'redis' => [ 'prefix' => str_replace(' ', '', env('APP_NAME')), 'host' => '127.0.0.1', 'port' => 6379, - 'ttl' => 60 - ] + 'ttl' => 60, + ], ]; - diff --git a/shared/config/captcha.php b/shared/config/captcha.php index 372bccc..908df57 100644 --- a/shared/config/captcha.php +++ b/shared/config/captcha.php @@ -18,5 +18,5 @@ 'type' => 'invisible', 'site_key' => env('HCAPTCHA_SITE_KEY'), 'secret_key' => env('HCAPTCHA_SECRET_KEY'), - ] + ], ]; diff --git a/shared/config/database.php b/shared/config/database.php index 849e860..d15a881 100644 --- a/shared/config/database.php +++ b/shared/config/database.php @@ -25,12 +25,12 @@ * charset: Default charset */ 'mysql' => [ - 'driver' => env("DB_DRIVER", "mysql"), - 'host' => env("DB_HOST", "localhost"), - 'dbname' => env("DB_NAME"), - 'username' => env("DB_USERNAME", "root"), - 'password' => env("DB_PASSWORD"), - 'charset' => env("DB_CHARSET", 'utf8'), + 'driver' => env('DB_DRIVER', 'mysql'), + 'host' => env('DB_HOST', 'localhost'), + 'dbname' => env('DB_NAME'), + 'username' => env('DB_USERNAME', 'root'), + 'password' => env('DB_PASSWORD'), + 'charset' => env('DB_CHARSET', 'utf8'), ], 'sqlite' => [ 'driver' => 'sqlite', @@ -47,9 +47,9 @@ 'min_length' => 2, 'mode' => 'or', 'score_key' => 'scoreKey', - 'algorithm' => 1 + 'algorithm' => 1, ], ], 'database_dir' => base_dir() . DS . 'shared' . DS . 'store', - ] -]; \ No newline at end of file + ], +]; diff --git a/shared/config/dependencies.php b/shared/config/dependencies.php index 8641489..0b0ccc6 100644 --- a/shared/config/dependencies.php +++ b/shared/config/dependencies.php @@ -8,4 +8,4 @@ */ \Quantum\Loader\Setup::class => Quantum\Loader\Setup::class, \Shared\Transformers\PostTransformer::class => \Shared\Transformers\PostTransformer::class, -]; \ No newline at end of file +]; diff --git a/shared/config/env.php b/shared/config/env.php index 8b42835..5473805 100644 --- a/shared/config/env.php +++ b/shared/config/env.php @@ -8,5 +8,5 @@ * * Project environment configuration to use (local, staging, production, etc.). */ - 'app_env' => 'production' + 'app_env' => 'production', ]; diff --git a/shared/config/fs.php b/shared/config/fs.php index c32ded3..c3e945d 100644 --- a/shared/config/fs.php +++ b/shared/config/fs.php @@ -13,7 +13,7 @@ 'params' => [ 'app_key' => '', 'app_secret' => '', - ] + ], ], 'gdrive' => [ @@ -21,6 +21,6 @@ 'params' => [ 'app_key' => '', 'app_secret' => '', - ] - ] + ], + ], ]; diff --git a/shared/config/lang.php b/shared/config/lang.php index 56835fb..407b240 100644 --- a/shared/config/lang.php +++ b/shared/config/lang.php @@ -10,4 +10,4 @@ 'supported' => ['en', 'es'], 'default' => 'en', 'url_segment' => 1, -]; \ No newline at end of file +]; diff --git a/shared/config/logging.php b/shared/config/logging.php index ad921d1..4da0fe7 100644 --- a/shared/config/logging.php +++ b/shared/config/logging.php @@ -16,5 +16,5 @@ 'daily' => [ 'path' => logs_dir(), 'level' => 'warning', - ] -]; \ No newline at end of file + ], +]; diff --git a/shared/config/mailer.php b/shared/config/mailer.php index 1f19a36..f8b344a 100644 --- a/shared/config/mailer.php +++ b/shared/config/mailer.php @@ -11,7 +11,7 @@ 'default' => 'smtp', 'mail_trap' => true, - + 'smtp' => [ 'host' => env('MAIL_HOST'), 'secure' => env('MAIL_SMTP_SECURE'), @@ -21,19 +21,19 @@ ], 'sendinblue' => [ - 'api_key' => env("SENDINBLUE_APIKEY", null), + 'api_key' => env('SENDINBLUE_APIKEY', null), ], - + 'sendgrid' => [ - 'api_key' => env("SENDGRID_APIKEY", null), + 'api_key' => env('SENDGRID_APIKEY', null), ], 'mailgun' => [ - 'api_key' => env("MAILGUN_APIKEY", null), - 'domain' => env("MAILGUN_DOMAIN", null), + 'api_key' => env('MAILGUN_APIKEY', null), + 'domain' => env('MAILGUN_DOMAIN', null), ], - + 'mandrill' => [ - 'api_key' => env("MANDRILL_APIKEY", null), + 'api_key' => env('MANDRILL_APIKEY', null), ], ]; diff --git a/shared/config/modules.php b/shared/config/modules.php deleted file mode 100644 index 0b67a5f..0000000 --- a/shared/config/modules.php +++ /dev/null @@ -1,3 +0,0 @@ - 'native', 'native' => [ - 'timeout' => 300 + 'timeout' => 300, ], 'database' => [ 'table' => 'sessions', 'timeout' => 300, - ] -]; \ No newline at end of file + ], +]; diff --git a/shared/config/view.php b/shared/config/view.php index 64560e8..27b9e16 100644 --- a/shared/config/view.php +++ b/shared/config/view.php @@ -1,6 +1,5 @@ 'UTF-8', 'debug' => false, 'cache' => false, - ] + ], ]; diff --git a/shared/config/view_cache.php b/shared/config/view_cache.php index 558a192..da8e90a 100644 --- a/shared/config/view_cache.php +++ b/shared/config/view_cache.php @@ -2,6 +2,6 @@ return [ 'ttl' => 300, - 'cache_dir' => 'cache', - 'minify' => true -]; \ No newline at end of file + 'cache_dir' => 'cache', + 'minify' => true, +]; diff --git a/shared/resources/lang/en/common.php b/shared/resources/lang/en/common.php index 1c71665..3175b7a 100644 --- a/shared/resources/lang/en/common.php +++ b/shared/resources/lang/en/common.php @@ -102,4 +102,4 @@ // ───── Languages ────────────────────────────────────────── 'en' => 'English', 'es' => 'Spanish', -]; \ No newline at end of file +]; diff --git a/shared/resources/lang/en/validation.php b/shared/resources/lang/en/validation.php index 9ff7a13..b95afae 100644 --- a/shared/resources/lang/en/validation.php +++ b/shared/resources/lang/en/validation.php @@ -83,4 +83,4 @@ 'internal-empty-response' => 'The captcha response is required.', 'replay-attack' => 'Potential replay attack detected.', ], -]; \ No newline at end of file +]; diff --git a/shared/resources/lang/es/common.php b/shared/resources/lang/es/common.php index e473b93..56fc67e 100644 --- a/shared/resources/lang/es/common.php +++ b/shared/resources/lang/es/common.php @@ -102,4 +102,4 @@ // ───── Languages ────────────────────────────────────────── 'en' => 'Inglés', 'es' => 'Español', -]; \ No newline at end of file +]; diff --git a/shared/resources/lang/es/validation.php b/shared/resources/lang/es/validation.php index 9d399bc..9b2f390 100644 --- a/shared/resources/lang/es/validation.php +++ b/shared/resources/lang/es/validation.php @@ -83,4 +83,4 @@ 'internal-empty-response' => 'La respuesta del captcha es obligatoria.', 'replay-attack' => 'Se detectó un posible ataque de repetición.', ], -]; \ No newline at end of file +]; diff --git a/tests/Feature/AppTestCase.php b/tests/Feature/AppTestCase.php index bc2acc8..56e9856 100644 --- a/tests/Feature/AppTestCase.php +++ b/tests/Feature/AppTestCase.php @@ -11,7 +11,6 @@ class AppTestCase extends TestCase { - protected string $defaultEmail = 'default@quantumphp.io'; protected string $defaultPassword = 'password'; @@ -26,7 +25,7 @@ public function setUp(): void { parent::setUp(); ob_start(); - + self::$app = createApp(AppType::WEB, PROJECT_ROOT); } @@ -42,8 +41,7 @@ public function request( array $params = [], array $headers = [], array $files = [] - ): Response - { + ): Response { Di::resetContainer(); Request::create($method, $url, $params, $headers, $files); self::$app->start(); @@ -54,9 +52,9 @@ protected function signInAndGetTokens(): array { $response = $this->request('post', '/api/signin', [ 'email' => $this->defaultEmail, - 'password' => $this->defaultPassword + 'password' => $this->defaultPassword, ]); return $response->get('tokens'); } -} \ No newline at end of file +} diff --git a/tests/Feature/modules/Api/AuthControllerTest.php b/tests/Feature/modules/Api/AuthControllerTest.php index ac880d0..f52f79b 100644 --- a/tests/Feature/modules/Api/AuthControllerTest.php +++ b/tests/Feature/modules/Api/AuthControllerTest.php @@ -12,7 +12,6 @@ class AuthControllerTest extends AppTestCase { - private Generator $faker; public function setUp(): void @@ -186,12 +185,12 @@ public function testModuleApiVerifyEndpoint() createUser([ 'email' => $email, 'otp_token' => base64_encode($otp), - 'otp' => (string)$otp, + 'otp' => (string) $otp, 'otp_expires' => date('Y-m-d H:i:s', time() + 300), // 5 minutes from now ]); $response = $this->request('post', '/api/en/verify', [ - 'otp' => (string)$otp, + 'otp' => (string) $otp, 'code' => base64_encode($otp), ]); @@ -259,4 +258,4 @@ protected function assertError($response, $expected) $this->assertStringContainsString($expected, $actual); } -} \ No newline at end of file +} diff --git a/tests/Feature/modules/Api/CommentControllerTest.php b/tests/Feature/modules/Api/CommentControllerTest.php index 1180a8f..5422869 100644 --- a/tests/Feature/modules/Api/CommentControllerTest.php +++ b/tests/Feature/modules/Api/CommentControllerTest.php @@ -10,7 +10,6 @@ class CommentControllerTest extends AppTestCase { - private array $tokens = []; private $post = null; @@ -84,4 +83,4 @@ public function testModuleApiCommentDeleteEndpoint() $this->assertEquals('Deleted successfully', $response->get('message')); } -} \ No newline at end of file +} diff --git a/tests/Feature/modules/Api/PostControllerTest.php b/tests/Feature/modules/Api/PostControllerTest.php index 681f29e..8d84fad 100644 --- a/tests/Feature/modules/Api/PostControllerTest.php +++ b/tests/Feature/modules/Api/PostControllerTest.php @@ -9,29 +9,28 @@ class PostControllerTest extends AppTestCase { - - public function setUp(): void - { - parent::setUp(); + public function setUp(): void + { + parent::setUp(); Request::flush(); - } + } public function tearDown(): void { parent::tearDown(); } - public function testModuleApiPostsEndpoint() - { + public function testModuleApiPostsEndpoint() + { $method = 'GET'; $endpoint = '/api/posts'; - $response = $this->request($method, $endpoint); + $response = $this->request($method, $endpoint); - $this->assertIsObject($response); + $this->assertIsObject($response); - $this->assertEquals('success', $response->get('status')); + $this->assertEquals('success', $response->get('status')); $this->assertArrayHasKey('data', $response->all()); @@ -52,35 +51,35 @@ public function testModuleApiPostsEndpoint() $this->assertArrayHasKey('date', $firstPost); $this->assertArrayHasKey('author', $firstPost); - $this->assertArrayHasKey('pagination', $response->all()); + $this->assertArrayHasKey('pagination', $response->all()); $pagination = $response->get('pagination'); $this->assertIsArray($pagination); - $this->assertArrayHasKey('total_records', $pagination); - $this->assertArrayHasKey('current_page', $pagination); - $this->assertArrayHasKey('next_page', $pagination); - $this->assertArrayHasKey('prev_page', $pagination); + $this->assertArrayHasKey('total_records', $pagination); + $this->assertArrayHasKey('current_page', $pagination); + $this->assertArrayHasKey('next_page', $pagination); + $this->assertArrayHasKey('prev_page', $pagination); $this->assertEquals(10, $pagination['total_records']); - $this->assertEquals(1, $pagination['current_page']); - $this->assertEquals(2, $pagination['next_page']); - $this->assertEquals(1,$pagination['prev_page']); - } + $this->assertEquals(1, $pagination['current_page']); + $this->assertEquals(2, $pagination['next_page']); + $this->assertEquals(1, $pagination['prev_page']); + } - public function testModuleApiSinglePostEndpoint() - { + public function testModuleApiSinglePostEndpoint() + { $method = 'GET'; $endpoint = '/api/post/'; - $post = ModelFactory::get(Post::class)->first(); + $post = ModelFactory::get(Post::class)->first(); - $response = $this->request($method, $endpoint . $post->uuid); + $response = $this->request($method, $endpoint . $post->uuid); - $this->assertIsObject($response); + $this->assertIsObject($response); - $this->assertEquals('success', $response->get('status')); + $this->assertEquals('success', $response->get('status')); $this->assertArrayHasKey('data', $response->all()); @@ -88,13 +87,13 @@ public function testModuleApiSinglePostEndpoint() $this->assertIsArray($post); - $this->assertArrayHasKey('uuid', $post); - $this->assertArrayHasKey('title', $post); - $this->assertArrayHasKey('content', $post); - $this->assertArrayHasKey('image', $post); - $this->assertArrayHasKey('date', $post); - $this->assertArrayHasKey('author', $post); - $this->assertArrayHasKey('comments', $post); + $this->assertArrayHasKey('uuid', $post); + $this->assertArrayHasKey('title', $post); + $this->assertArrayHasKey('content', $post); + $this->assertArrayHasKey('image', $post); + $this->assertArrayHasKey('date', $post); + $this->assertArrayHasKey('author', $post); + $this->assertArrayHasKey('comments', $post); $firstComment = $post['comments'][0]; @@ -105,5 +104,5 @@ public function testModuleApiSinglePostEndpoint() $this->assertArrayHasKey('author', $firstComment); $this->assertArrayHasKey('content', $firstComment); $this->assertArrayHasKey('date', $firstComment); - } -} \ No newline at end of file + } +} diff --git a/tests/Feature/modules/Api/PostManagementControllerTest.php b/tests/Feature/modules/Api/PostManagementControllerTest.php index cda567b..fc115b9 100644 --- a/tests/Feature/modules/Api/PostManagementControllerTest.php +++ b/tests/Feature/modules/Api/PostManagementControllerTest.php @@ -9,59 +9,58 @@ class PostManagementControllerTest extends AppTestCase { - private $tokens = []; - public function setUp(): void - { - parent::setUp(); + public function setUp(): void + { + parent::setUp(); $this->tokens = $this->signInAndGetTokens(); Request::flush(); - } + } public function tearDown(): void { parent::tearDown(); } - public function testModuleApiMyPostsEndpoint() - { + public function testModuleApiMyPostsEndpoint() + { $method = 'GET'; $endpoint = '/api/my-posts'; $body = []; $headers = [ 'Authorization' => 'Bearer ' . $this->tokens['access_token'], - 'refresh_token' => $this->tokens['refresh_token'] + 'refresh_token' => $this->tokens['refresh_token'], ]; - $response = $this->request($method, $endpoint, $body, $headers); + $response = $this->request($method, $endpoint, $body, $headers); - $this->assertIsObject($response); + $this->assertIsObject($response); - $this->assertEquals('success', $response->get('status')); + $this->assertEquals('success', $response->get('status')); - $this->assertArrayHasKey('data', $response->all()); + $this->assertArrayHasKey('data', $response->all()); $postData = $response->get('data'); - $this->assertCount(10, $postData); + $this->assertCount(10, $postData); $firstPost = $postData[0]; $this->assertIsArray($firstPost); - $this->assertArrayHasKey('uuid', $firstPost); - $this->assertArrayHasKey('title', $firstPost); - $this->assertArrayHasKey('content', $firstPost); - $this->assertArrayHasKey('image', $firstPost); - $this->assertArrayHasKey('date', $firstPost); - $this->assertArrayHasKey('author', $firstPost); - } + $this->assertArrayHasKey('uuid', $firstPost); + $this->assertArrayHasKey('title', $firstPost); + $this->assertArrayHasKey('content', $firstPost); + $this->assertArrayHasKey('image', $firstPost); + $this->assertArrayHasKey('date', $firstPost); + $this->assertArrayHasKey('author', $firstPost); + } - public function testModuleApiPostCreateEndpoint() - { + public function testModuleApiPostCreateEndpoint() + { $method = 'POST'; $endpoint = '/api/my-posts/create'; $body = [ @@ -72,9 +71,9 @@ public function testModuleApiPostCreateEndpoint() ]; $headers = ['Authorization' => 'Bearer ' . $this->tokens['access_token']]; - $response = $this->request($method, $endpoint, $body, $headers); + $response = $this->request($method, $endpoint, $body, $headers); - $this->assertIsObject($response); + $this->assertIsObject($response); $this->assertEquals('success', $response->get('status')); @@ -94,8 +93,8 @@ public function testModuleApiPostCreateEndpoint() ModelFactory::get(Post::class)->findOneBy('uuid', $post['uuid'])->delete(); } - public function testModuleApiAmendPostEndpoint() - { + public function testModuleApiAmendPostEndpoint() + { $method = 'PUT'; $endpoint = '/api/my-posts/amend/'; $body = [ @@ -104,15 +103,15 @@ public function testModuleApiAmendPostEndpoint() ]; $headers = ['Authorization' => 'Bearer ' . $this->tokens['access_token']]; - $post = ModelFactory::get(Post::class)->first(); + $post = ModelFactory::get(Post::class)->first(); - $response = $this->request($method, $endpoint . $post->uuid, $body, $headers); + $response = $this->request($method, $endpoint . $post->uuid, $body, $headers); - $this->assertIsObject($response); + $this->assertIsObject($response); - $this->assertEquals('success', $response->get('status')); + $this->assertEquals('success', $response->get('status')); - $this->assertEquals('Updated successfully', $response->get('message')); + $this->assertEquals('Updated successfully', $response->get('message')); $post = $response->get('data'); @@ -124,10 +123,10 @@ public function testModuleApiAmendPostEndpoint() $this->assertArrayHasKey('image', $post); $this->assertArrayHasKey('date', $post); $this->assertArrayHasKey('author', $post); - } + } - public function testModuleApiDeletePostEndpoint() - { + public function testModuleApiDeletePostEndpoint() + { $method = 'POST'; $endpoint = '/api/my-posts/create'; $body = [ @@ -152,23 +151,23 @@ public function testModuleApiDeletePostEndpoint() $this->assertEquals('success', $response->get('status')); $this->assertEquals('Deleted successfully', $response->get('message')); - } + } - public function testModuleApiDeletePostImageEndpoint() - { + public function testModuleApiDeletePostImageEndpoint() + { $method = 'DELETE'; $endpoint = '/api/my-posts/delete-image/'; $body = []; $headers = ['Authorization' => 'Bearer ' . $this->tokens['access_token']]; - $post = ModelFactory::get(Post::class)->first(); + $post = ModelFactory::get(Post::class)->first(); - $response = $this->request($method, $endpoint . $post->uuid, $body, $headers); + $response = $this->request($method, $endpoint . $post->uuid, $body, $headers); - $this->assertIsObject($response); + $this->assertIsObject($response); - $this->assertEquals('success', $response->get('status')); + $this->assertEquals('success', $response->get('status')); - $this->assertEquals('Deleted successfully', $response->get('message')); - } -} \ No newline at end of file + $this->assertEquals('Deleted successfully', $response->get('message')); + } +} diff --git a/tests/Helpers/functions.php b/tests/Helpers/functions.php index f6056ee..d4618a1 100644 --- a/tests/Helpers/functions.php +++ b/tests/Helpers/functions.php @@ -51,7 +51,8 @@ function createModule(string $moduleName, string $template, bool $withAssets = f $moduleManager->addModuleConfig(); - $route = new Route(['GET'], 'dummy', null, null, function () {}); + $route = new Route(['GET'], 'dummy', null, null, function () { + }); $route->module($moduleName); $matchedRoute = new MatchedRoute($route, []); Request::setMatchedRoute($matchedRoute); @@ -64,6 +65,14 @@ function removeModule() deleteDirectory(uploads_dir()); deleteDirectory(modules_dir()); + if (!is_dir(uploads_dir())) { + mkdir(uploads_dir(), 0777, true); + } + + if (!file_exists(uploads_dir() . DS . '.gitkeep')) { + file_put_contents(uploads_dir() . DS . '.gitkeep', ''); + } + file_put_contents( base_dir() . DS . 'shared' . DS . 'config' . DS . 'modules.php', " 'admin', 'email' => 'default@quantumphp.io', 'password' => (new Hasher())->hash('password'), - ], $overrides)); + ], $overrides) + ); } function createUserPosts(AuthUser $user): array @@ -156,4 +166,4 @@ function dbCleanUp() ServiceFactory::get(AuthService::class)->deleteAllUsers(); ServiceFactory::get(PostService::class)->deleteAllPosts(); ServiceFactory::get(CommentService::class)->deleteAllComments(); -} \ No newline at end of file +} diff --git a/tests/Unit/shared/Services/AuthServiceTest.php b/tests/Unit/shared/Services/AuthServiceTest.php index ba56993..f200913 100644 --- a/tests/Unit/shared/Services/AuthServiceTest.php +++ b/tests/Unit/shared/Services/AuthServiceTest.php @@ -11,7 +11,6 @@ class AuthServiceTest extends TestCase { - protected $authService; public function setUp(): void @@ -131,4 +130,4 @@ public function testAuthServiceUserSchema() $this->assertArrayHasKey('name', $userSchema['username']); $this->assertArrayHasKey('visible', $userSchema['username']); } -} \ No newline at end of file +} diff --git a/tests/Unit/shared/Services/CommentServiceTest.php b/tests/Unit/shared/Services/CommentServiceTest.php index 6cfc9d7..9b824e2 100644 --- a/tests/Unit/shared/Services/CommentServiceTest.php +++ b/tests/Unit/shared/Services/CommentServiceTest.php @@ -12,7 +12,6 @@ class CommentServiceTest extends TestCase { - protected $commentService; protected $postService; @@ -107,4 +106,4 @@ public function testCommentServiceDeleteComment() $this->assertTrue($comment->isEmpty()); } -} \ No newline at end of file +} diff --git a/tests/Unit/shared/Services/PostServiceTest.php b/tests/Unit/shared/Services/PostServiceTest.php index 9734553..8ebfdae 100644 --- a/tests/Unit/shared/Services/PostServiceTest.php +++ b/tests/Unit/shared/Services/PostServiceTest.php @@ -14,9 +14,9 @@ class PostServiceTest extends TestCase { - const PER_PAGE = 10; + public const PER_PAGE = 10; - const CURRENT_PAGE = 1; + public const CURRENT_PAGE = 1; protected $authService; @@ -76,7 +76,7 @@ public function testPostServiceGetPostsWithSearch() $uniqueKeyword = 'SEARCH_TOKEN_' . uniqid(); $title = "Title with {$uniqueKeyword}"; - $content = "Some content"; + $content = 'Some content'; $post = $this->postService->addPost(new PostDTO( $title, @@ -149,8 +149,6 @@ public function testPostServiceAddNewPost() $this->assertEquals('Content of just another post', $post->content); - - $this->postService->deletePost($newPost->uuid); } @@ -179,7 +177,6 @@ public function testPostServiceUpdatePost() $this->assertEquals('image.jpg', $post->image); - } public function testPostServiceDeletePost() @@ -234,4 +231,4 @@ public function testPostServiceSaveAndDeleteImage() $this->assertFileDoesNotExist(uploads_dir() . DS . $userUuid . DS . $image); } -} \ No newline at end of file +} diff --git a/tests/_root/helpers/functions.php b/tests/_root/helpers/functions.php index 5bc6d94..c34e57c 100644 --- a/tests/_root/helpers/functions.php +++ b/tests/_root/helpers/functions.php @@ -5,7 +5,7 @@ function url_with_lang(string $lang): string { - if (!in_array($lang, (array)config()->get('lang.supported'))) { + if (!in_array($lang, (array) config()->get('lang.supported'))) { $lang = config()->get('lang.default'); } @@ -14,7 +14,7 @@ function url_with_lang(string $lang): string } if (preg_match('/' . preg_quote(current_lang()) . '/', route_uri())) { - return base_url() . preg_replace('/' . preg_quote(current_lang(), '/') . "/", $lang, route_uri(), 1); + return base_url() . preg_replace('/' . preg_quote(current_lang(), '/') . '/', $lang, route_uri(), 1); } $url = base_url(true); @@ -26,7 +26,7 @@ function url_with_lang(string $lang): string if (!empty(route_prefix()) && $langSegmentIndex == 1) { $langSegmentIndex += 1; - $uri = preg_replace('/' . preg_quote(route_prefix(), '/') . "/", '', route_uri(), 1); + $uri = preg_replace('/' . preg_quote(route_prefix(), '/') . '/', '', route_uri(), 1); } $segments = explode('/', $uri); diff --git a/tests/_root/shared/config/app.php b/tests/_root/shared/config/app.php index 1c8f290..4bc93b1 100644 --- a/tests/_root/shared/config/app.php +++ b/tests/_root/shared/config/app.php @@ -8,4 +8,4 @@ 'base_url' => 'http://localhost', 'debug' => false, 'test' => 'Testing', -]; \ No newline at end of file +]; diff --git a/tests/_root/shared/config/database.php b/tests/_root/shared/config/database.php index c8e4eac..7be8ff4 100644 --- a/tests/_root/shared/config/database.php +++ b/tests/_root/shared/config/database.php @@ -4,12 +4,12 @@ 'default' => 'sleekdb', 'mysql' => [ - 'driver' => env("DB_DRIVER", "mysql"), - 'host' => env("DB_HOST", "localhost"), - 'dbname' => env("DB_NAME"), - 'username' => env("DB_USERNAME", "root"), - 'password' => env("DB_PASSWORD"), - 'charset' => env("DB_CHARSET", 'utf8'), + 'driver' => env('DB_DRIVER', 'mysql'), + 'host' => env('DB_HOST', 'localhost'), + 'dbname' => env('DB_NAME'), + 'username' => env('DB_USERNAME', 'root'), + 'password' => env('DB_PASSWORD'), + 'charset' => env('DB_CHARSET', 'utf8'), ], 'sqlite' => [ 'driver' => 'sqlite', @@ -25,9 +25,9 @@ 'min_length' => 2, 'mode' => 'or', 'score_key' => 'scoreKey', - 'algorithm' => 1 + 'algorithm' => 1, ], ], 'database_dir' => base_dir() . DS . 'shared' . DS . 'store', - ] -]; \ No newline at end of file + ], +]; diff --git a/tests/_root/shared/config/dependencies.php b/tests/_root/shared/config/dependencies.php index c29cc1c..fd34886 100644 --- a/tests/_root/shared/config/dependencies.php +++ b/tests/_root/shared/config/dependencies.php @@ -2,4 +2,4 @@ return [ \Shared\Transformers\PostTransformer::class, -]; \ No newline at end of file +]; diff --git a/tests/_root/shared/config/env.php b/tests/_root/shared/config/env.php index dafbe24..3d99831 100644 --- a/tests/_root/shared/config/env.php +++ b/tests/_root/shared/config/env.php @@ -1,5 +1,5 @@ 'testing' + 'app_env' => 'testing', ]; diff --git a/tests/_root/shared/config/fs.php b/tests/_root/shared/config/fs.php index 6c982b9..89350a4 100644 --- a/tests/_root/shared/config/fs.php +++ b/tests/_root/shared/config/fs.php @@ -8,7 +8,7 @@ 'params' => [ 'app_key' => '', 'app_secret' => '', - ] + ], ], 'gdrive' => [ @@ -16,6 +16,6 @@ 'params' => [ 'app_key' => '', 'app_secret' => '', - ] - ] + ], + ], ]; diff --git a/tests/_root/shared/config/lang.php b/tests/_root/shared/config/lang.php index abd9dc0..8f1675a 100644 --- a/tests/_root/shared/config/lang.php +++ b/tests/_root/shared/config/lang.php @@ -10,4 +10,4 @@ 'supported' => ['en', 'ru', 'am'], 'default' => 'en', 'url_segment' => 1, -]; \ No newline at end of file +]; diff --git a/tests/_root/shared/config/logging.php b/tests/_root/shared/config/logging.php index 9983c17..0fff5b7 100644 --- a/tests/_root/shared/config/logging.php +++ b/tests/_root/shared/config/logging.php @@ -1,4 +1,5 @@ 'single', @@ -10,5 +11,5 @@ 'daily' => [ 'path' => logs_dir(), 'level' => 'warning', - ] -]; \ No newline at end of file + ], +]; diff --git a/tests/_root/shared/config/mailer.php b/tests/_root/shared/config/mailer.php index 110d590..4f17898 100644 --- a/tests/_root/shared/config/mailer.php +++ b/tests/_root/shared/config/mailer.php @@ -4,7 +4,7 @@ 'default' => 'smtp', 'mail_trap' => true, - + 'smtp' => [ 'host' => env('MAIL_HOST'), 'secure' => env('MAIL_SMTP_SECURE'), @@ -14,19 +14,19 @@ ], 'sendinblue' => [ - 'api_key' => env("SENDINBLUE_APIKEY", null), + 'api_key' => env('SENDINBLUE_APIKEY', null), ], - + 'sendgrid' => [ - 'api_key' => env("SENDGRID_APIKEY", null), + 'api_key' => env('SENDGRID_APIKEY', null), ], 'mailgun' => [ - 'api_key' => env("MAILGUN_APIKEY", null), - 'domain' => env("MAILGUN_DOMAIN", null), + 'api_key' => env('MAILGUN_APIKEY', null), + 'domain' => env('MAILGUN_DOMAIN', null), ], - + 'mandrill' => [ - 'api_key' => env("MANDRILL_APIKEY", null), + 'api_key' => env('MANDRILL_APIKEY', null), ], ]; diff --git a/tests/_root/shared/config/view.php b/tests/_root/shared/config/view.php index fae49b0..7c65484 100644 --- a/tests/_root/shared/config/view.php +++ b/tests/_root/shared/config/view.php @@ -1,4 +1,5 @@ 'html', @@ -8,5 +9,5 @@ 'charset' => 'UTF-8', 'debug' => false, 'cache' => false, - ] + ], ]; diff --git a/tests/_root/shared/resources/lang/en/common.php b/tests/_root/shared/resources/lang/en/common.php index ddd785d..725ef38 100644 --- a/tests/_root/shared/resources/lang/en/common.php +++ b/tests/_root/shared/resources/lang/en/common.php @@ -101,4 +101,4 @@ // ───── Languages ────────────────────────────────────────── 'en' => 'English', 'es' => 'Spanish', -]; \ No newline at end of file +]; diff --git a/tests/_root/shared/resources/lang/en/validation.php b/tests/_root/shared/resources/lang/en/validation.php index 9ff7a13..b95afae 100644 --- a/tests/_root/shared/resources/lang/en/validation.php +++ b/tests/_root/shared/resources/lang/en/validation.php @@ -83,4 +83,4 @@ 'internal-empty-response' => 'The captcha response is required.', 'replay-attack' => 'Potential replay attack detected.', ], -]; \ No newline at end of file +]; diff --git a/tests/_root/shared/resources/lang/es/common.php b/tests/_root/shared/resources/lang/es/common.php index 90998b9..91c57ef 100644 --- a/tests/_root/shared/resources/lang/es/common.php +++ b/tests/_root/shared/resources/lang/es/common.php @@ -101,4 +101,4 @@ // ───── Languages ────────────────────────────────────────── 'en' => 'Inglés', 'es' => 'Español', -]; \ No newline at end of file +]; diff --git a/tests/_root/shared/resources/lang/es/validation.php b/tests/_root/shared/resources/lang/es/validation.php index 9d399bc..9b2f390 100644 --- a/tests/_root/shared/resources/lang/es/validation.php +++ b/tests/_root/shared/resources/lang/es/validation.php @@ -83,4 +83,4 @@ 'internal-empty-response' => 'La respuesta del captcha es obligatoria.', 'replay-attack' => 'Se detectó un posible ataque de repetición.', ], -]; \ No newline at end of file +]; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 7c42f51..14705b8 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,9 +4,13 @@ error_reporting(E_ALL | E_STRICT); -if (!defined('DS')) define('DS', DIRECTORY_SEPARATOR); +if (!defined('DS')) { + define('DS', DIRECTORY_SEPARATOR); +} -if (!defined('PROJECT_ROOT')) define("PROJECT_ROOT", __DIR__ . DS . '_root'); +if (!defined('PROJECT_ROOT')) { + define('PROJECT_ROOT', __DIR__ . DS . '_root'); +} require_once dirname(__DIR__) . DS . 'vendor' . DS . 'autoload.php'; @@ -29,5 +33,3 @@ removeModule(); dbCleanUp(); }); - -