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

Clean tests files for latest dependencies #59

Merged
merged 17 commits into from
Aug 14, 2023
Merged
57 changes: 57 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Tests

on: [push, pull_request]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.0, 8.1, 8.2]
laravel: [^8.83.27, ^9.51.0, ^10.0.0]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: ^10.0.0
testbench: ^8.0.0
- laravel: ^9.51.0
testbench: ^7.22.0
- laravel: ^8.83.27
testbench: ^6.25.1
exclude:
- php: 8.0
laravel: ^10.0.0
- php: 8.1
laravel: ^8.83.27


name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: xdebug

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
composer require nesbot/carbon:^2.68.1

- name: List Installed Dependencies
run: composer show -D

- name: Execute test
run: composer test -- --ci
20 changes: 15 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
}
],
"require": {
"php": "^7.3|^8.0",
"laravel/framework": "~5.4.0|~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0"
"php": "^8.0",
"illuminate/contracts": "^8.83.27|^9.51.0|^10.0.0",
"spatie/laravel-package-tools": "^1.12"
},
"require-dev": {
"orchestra/testbench": "~3.8|^4.0|^5.0|^7.0|^8.0",
"orchestra/testbench": "^6.25.1|^7.22.0|^8.0.0",
"mockery/mockery": "^0.9.4 || ~1.0",
"phpunit/phpunit": "~8.5|^9.0"
"pestphp/pest": "^1.23.1|^2.11",
"pestphp/pest-plugin-laravel": "^1.4|^2.1",
"laravel/pint": "^1.5"
},
"autoload": {
"psr-4": {
Expand All @@ -51,6 +54,13 @@
}
},
"scripts": {
"test": "vendor/bin/phpunit"
"test": "vendor/bin/pest",
"format": "vendor/bin/pint",
"format-dryrun": "vendor/bin/pint --test"
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
}
}
}
4 changes: 3 additions & 1 deletion src/config/gamify.php → config/gamify.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

return [
// Model which will be having points, generally it will be User
'payee_model' => '\App\User',
Expand Down Expand Up @@ -33,5 +35,5 @@
],

// Default level
'badge_default_level' => 1
'badge_default_level' => 1,
];
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
<?php

declare(strict_types=1);

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddReputationFieldOnUserTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
Schema::table(app(config('gamify.payee_model'))->getTable(), function (Blueprint $table) {
$table->unsignedInteger('reputation')->default(0)->after('remember_token');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
Schema::table(app(config('gamify.payee_model'))->getTable(), function (Blueprint $table) {
$table->dropColumn('reputation');
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
<?php

declare(strict_types=1);

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGamifyTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
// reputations table
Schema::create('reputations', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
Expand All @@ -25,7 +21,6 @@ class CreateGamifyTables extends Migration
$table->timestamps();
});

// badges table
Schema::create('badges', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
Expand All @@ -35,7 +30,6 @@ class CreateGamifyTables extends Migration
$table->timestamps();
});

// user_badges pivot
Schema::create('user_badges', function (Blueprint $table) {
$table->primary(['user_id', 'badge_id']);
$table->unsignedInteger('user_id');
Expand All @@ -44,12 +38,7 @@ class CreateGamifyTables extends Migration
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('user_badges');
Schema::dropIfExists('badges');
Expand Down
27 changes: 13 additions & 14 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>

<php>
<env name="APP_KEY" value="AckfSECs434SFXIvnK5r28GVIWUAxmbBSjTsmF"/>
</php>
<testsuites>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_KEY" value="AckfSECs434SFXIvnK5r28GVIWUAxmbBSjTsmF"/>
</php>
</phpunit>
92 changes: 92 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"preset": "psr12",
"exclude": [
"src"
],
"notPath": [
".phpunit.result.cache"
],
"rules": {
"align_multiline_comment": true,
"array_indentation": true,
"array_syntax": true,
"assign_null_coalescing_to_coalesce_equal": true,
"binary_operator_spaces": true,
"blank_line_before_statement": {
"statements": [
"break",
"continue",
"declare",
"return",
"throw",
"try"
]
},
"cast_spaces": true,
"class_attributes_separation": {
"elements": {
"method": "one"
}
},
"clean_namespace": true,
"combine_consecutive_issets": true,
"combine_consecutive_unsets": true,
"declare_strict_types": true,
"doctrine_annotation_indentation": true,
"doctrine_annotation_spaces": true,
"fully_qualified_strict_types": true,
"function_typehint_space": true,
"global_namespace_import": true,
"heredoc_indentation": true,
"include": true,
"lambda_not_used_import": true,
"linebreak_after_opening_tag": true,
"list_syntax": true,
"magic_constant_casing": true,
"magic_method_casing": true,
"method_argument_space": {
"on_multiline": "ensure_fully_multiline",
"keep_multiple_spaces_after_comma": true
},
"method_chaining_indentation": true,
"multiline_comment_opening_closing": true,
"multiline_whitespace_before_semicolons": true,
"native_function_casing": true,
"native_function_type_declaration_casing": true,
"no_alias_language_construct_call": true,
"no_alternative_syntax": true,
"no_empty_comment": true,
"no_empty_statement": true,
"no_extra_blank_lines": true,
"no_leading_namespace_whitespace": true,
"no_mixed_echo_print": true,
"no_multiline_whitespace_around_double_arrow": true,
"no_multiple_statements_per_line": true,
"no_singleline_whitespace_before_semicolons": true,
"no_spaces_around_offset": true,
"no_unneeded_import_alias": true,
"no_unused_imports": true,
"no_whitespace_before_comma_in_array": true,
"no_whitespace_in_blank_line": true,
"not_operator_with_space": true,
"not_operator_with_successor_space": true,
"php_unit_fqcn_annotation": true,
"phpdoc_line_span": {
"const": "single",
"method": "single",
"property": "single"
},
"phpdoc_scalar": true,
"phpdoc_single_line_var_spacing": true,
"phpdoc_var_without_name": true,
"simple_to_complex_string_variable": true,
"simplified_if_return": true,
"single_quote": true,
"standardize_not_equals": true,
"trailing_comma_in_multiline": true,
"trim_array_spaces": true,
"types_spaces": true,
"unary_operator_spaces": true,
"whitespace_after_comma_in_array": true
}
}
Loading