diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 58fe6aa..2c7477c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,84 +1,70 @@ -name: Test Laravel Github action +# GithHub Actions Workflow generated with Ghygen +# Original configuration: https://ghygen.hi-folks.dev?code=bb85a1693f8aa341b4c92d07cea283be +name: Test Laravel Package on: - push: - branches: - - main - - master - - develop - - features/** + push: + branches: + - main + - master + - develop + - features/** + - feature/** jobs: - laravel-tests: - runs-on: ubuntu-latest - - strategy: - matrix: - operating-system: [ubuntu-latest] - php-versions: [ '8.0','7.4' ] - dependency-stability: [ prefer-stable ] - - laravel: [ '8.*','7.*' ] - include: - - laravel: 8.* - testbench: 6.* - - laravel: 7.* - testbench: 5.* - - name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}} - - steps: - - uses: actions/checkout@v2 - - - name: Cache Node.js modules - uses: actions/cache@v2 - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.OS }}-node- - ${{ runner.OS }}- - - - name: Install PHP versions - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - - name: Get Composer Cache Directory 2 - id: composer-cache - run: | - echo "::set-output name=dir::$(composer config cache-files-dir)" - - uses: actions/cache@v2 - id: actions-cache - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - name: Cache PHP dependencies - uses: actions/cache@v2 - id: vendor-cache - with: - path: vendor - key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} - - name: Copy .env - run: php -r "file_exists('.env') || copy('.env.example', '.env');" - - name: Install Laravel Dependencies - run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest - - - - - name: Create Database - run: | - mkdir -p database - touch database/database.sqlite - - - - - name: Execute tests (Unit and Feature tests) via PHPUnit -# Set environment - env: - SESSION_DRIVER: array - - run: vendor/bin/phpunit --testdox + laravel-tests: + runs-on: ubuntu-latest + + strategy: + matrix: + operating-system: [ubuntu-latest] + php-versions: [ '8.0','7.4','7.3' ] + dependency-stability: [ prefer-stable ] + + name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}} + + steps: + - uses: actions/checkout@v2 + - name: Install PHP versions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + - name: Get Composer Cache Directory 2 + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + - uses: actions/cache@v2 + id: actions-cache + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + + + + - name: Show dir + run: pwd + - name: PHP Version + run: php --version + + - name: Execute tests (Unit and Feature tests) via PHPUnit + # Set environment + env: + SESSION_DRIVER: array + + run: vendor/bin/phpunit --testdox + + - name: Execute Code Sniffer via phpcs + run: | + vendor/bin/phpcs --standard=PSR12 src + - name: Execute Code Static Generator via phpstan + run: | + vendor/bin/phpstan analyse src -c ./vendor/nunomaduro/larastan/extension.neon --level=4 --no-progress + + + + + diff --git a/Makefile b/Makefile index f1af603..3329d69 100644 --- a/Makefile +++ b/Makefile @@ -3,17 +3,18 @@ help: ## Show this help. @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' phpstan: ## Execute phpstan - phpstan analyse src --level=1 + vendor/bin/phpstan analyse src -c ./vendor/nunomaduro/larastan/extension.neon --level=4 --no-progress + test: ## Execute phpunit - vendor/bin/phpunit + vendor/bin/phpunit --testdox coverage: ## Execute the coverage test vendor/bin/phpunit --coverage-text phpcs: ## execute phpcs - phpcs src + vendor/bin/phpcs --standard=PSR12 src -allcheck: phpcs phpstan ## all check +allcheck: phpcs phpstan test ## all check diff --git a/composer.json b/composer.json index 2a1baca..dc65599 100755 --- a/composer.json +++ b/composer.json @@ -28,8 +28,10 @@ "ext-json": "*" }, "require-dev": { + "nunomaduro/larastan": "^0.7.2", "orchestra/testbench": "4.*|5.*|6.*", - "phpunit/phpunit": "^8.0|^9.3" + "phpunit/phpunit": "^8.0|^9.3", + "squizlabs/php_codesniffer": "^3.5" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2ad2830..c4fdcc3 100755 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,32 +1,24 @@ - - - - tests - - - - - src/ - - - - - - - - - - - - + + + + src/ + + + + + + + + + + tests + + + + + + + + diff --git a/phpunit.xml.dist.bak b/phpunit.xml.dist.bak new file mode 100644 index 0000000..2ad2830 --- /dev/null +++ b/phpunit.xml.dist.bak @@ -0,0 +1,32 @@ + + + + + tests + + + + + src/ + + + + + + + + + + + + + diff --git a/src/Console/LaraLensCommand.php b/src/Console/LaraLensCommand.php index c6c91db..187765a 100644 --- a/src/Console/LaraLensCommand.php +++ b/src/Console/LaraLensCommand.php @@ -22,8 +22,8 @@ class LaraLensCommand extends Command {--show=* : show (all|config|runtime|connection|database|migration|php-ext|php-ini)} {--width-label=' . self::DEFAULT_WIDTH . ' : width of column for label} {--width-value=' . self::DEFAULT_WIDTH . ' : width of column for value} - {--style=' . self::DEFAULT_STYLE . ' : style of the output table (' . self::TABLE_STYLES . ')} - {--skip-database : skip database check like connection and migration (if your laravel app doesn\'t need Database)} + {--style=' . self::DEFAULT_STYLE . ' : style for output table (' . self::TABLE_STYLES . ')} + {--skip-database : skip database check (if your laravel app doesn\'t need Database)} '; protected $description = 'Show some application configurations.'; @@ -198,11 +198,11 @@ private function overview($checkTable = "users", $columnSorting = "created_at", } } if ($show & self::OPTION_SHOW_PHPEXTENSIONS) { - $output = $ll->getPhpExtensions($checkTable, $columnSorting); + $output = $ll->getPhpExtensions(); $this->printOutput(["PHP Extensions"], $output->toArray()); } if ($show & self::OPTION_SHOW_PHPINIVALUES) { - $output = $ll->getPhpIniValues($checkTable, $columnSorting); + $output = $ll->getPhpIniValues(); $this->printOutput(["PHP ini config", "Values"], $output->toArray()); } $this->printChecks($ll->checksBag->toArray()); diff --git a/src/Lens/Traits/DatabaseLens.php b/src/Lens/Traits/DatabaseLens.php index 8f7e301..3dc10df 100644 --- a/src/Lens/Traits/DatabaseLens.php +++ b/src/Lens/Traits/DatabaseLens.php @@ -3,6 +3,7 @@ namespace HiFolks\LaraLens\Lens\Traits; use Illuminate\Database\ConnectionInterface; +use Illuminate\Database\Connection; use Illuminate\Database\QueryException; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; @@ -37,7 +38,7 @@ public function getTablesListSqlite() * Try to establish a db connection. * If it fails, return FALSE and fill checksBag. * - * @return false|\Illuminate\Database\ConnectionInterface + * @return false|\Illuminate\Database\Connection */ public function dbConnection() { @@ -56,7 +57,7 @@ public function dbConnection() } public function getDatabaseConnectionInfos( - ConnectionInterface $dbConnection, + Connection $dbConnection, ResultLens $results, $checkTable, $columnSorting diff --git a/src/Lens/Traits/FilesystemLens.php b/src/Lens/Traits/FilesystemLens.php index 6613fd1..8fb9e8e 100644 --- a/src/Lens/Traits/FilesystemLens.php +++ b/src/Lens/Traits/FilesystemLens.php @@ -68,7 +68,7 @@ public function checkFiles() $this->checksBag->addWarningAndHint( "Check storage target link", $this->stripPrefixDir($dir) . " it doesn't exist.", - "Create directory target (for storage link) : ".$dir + "Create directory target (for storage link) : " . $dir ); }