Skip to content

Commit

Permalink
Updates (#8)
Browse files Browse the repository at this point in the history
- Updates CI
- Drops PHP 7 support
- Ensures PHP 8.1 support
- Drop PHPUnit 7, 8 support
  • Loading branch information
sixlive authored Nov 15, 2021
1 parent 8fe8695 commit c13a1a0
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 34 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check & fix styling

on: [push]

jobs:
php-cs-fixer:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php-cs-fixer.dist.php --allow-risky=yes

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling
30 changes: 14 additions & 16 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
name: run-tests
name: Tests

on:
push:
pull_request:
on: [push, pull_request]

jobs:
test:
runs-on: [ubuntu-latest]
runs-on: ubuntu-latest
strategy:
fail-fast: false
fail-fast: true
matrix:
php: [8.0, 7.4, 7.3, 7.2, 7.1]
dependency-version: [prefer-lowest, prefer-stable]
php: [8.0, 8.1]
stability: [prefer-lowest, prefer-stable]

name: P${{ matrix.php }} ${{ matrix.dependency-version }}
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}

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

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- 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: none

- 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 update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Execute tests
run: vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ docs
vendor
coverage
phpunit.xml
.php-cs-fixer.cache
40 changes: 40 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

$finder = Symfony\Component\Finder\Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method' => 'one',
],
],
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
])
->setFinder($finder);
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
}
],
"require": {
"php": "^7.1|^8.0"
"php": "^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.2",
"larapack/dd": "^1.0",
"phpunit/phpunit": "^7.0|^8.0|^9.0"
"phpunit/phpunit": "^9.0"
},
"autoload": {
"psr-4": {
Expand All @@ -33,6 +34,9 @@
"sixlive\\DotenvEditor\\Tests\\": "tests"
}
},
"scripts": {
"cs": "vendor/bin/php-cs-fixer fix --config=./.php-cs-fixer.dist.php"
},
"config": {
"sort-packages": true
}
Expand Down
32 changes: 16 additions & 16 deletions tests/DotenvEditorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function tearDown(): void
/** @test */
public function a_config_value_can_be_set()
{
$editor = new DotenvEditor;
$editor = new DotenvEditor();

$editor->set('EXAMPLE_CONFIG', 'foo');

Expand All @@ -38,7 +38,7 @@ public function a_config_value_can_be_set()
/** @test */
public function a_config_value_can_be_unset()
{
$editor = new DotenvEditor;
$editor = new DotenvEditor();

$editor->set('EXAMPLE_CONFIG', 'foo');

Expand All @@ -52,7 +52,7 @@ public function a_config_value_can_be_unset()
/** @test */
public function all_config_values_can_be_retrieved()
{
$editor = new DotenvEditor;
$editor = new DotenvEditor();

$editor->set('EXAMPLE_CONFIG', 'foo');
$editor->set('EXAMPLE_CONFIG_2', 'bar');
Expand All @@ -68,7 +68,7 @@ public function all_config_values_can_be_retrieved()
/** @test */
public function config_values_can_be_saved()
{
$editor = new DotenvEditor;
$editor = new DotenvEditor();

$editor->load($this->path);
$editor->set('EXAMPLE_CONFIG', 'foo');
Expand All @@ -81,7 +81,7 @@ public function config_values_can_be_saved()
public function config_values_can_be_saved_to_a_new_path()
{
$newPath = __DIR__.'/tmp/env-new';
$editor = new DotenvEditor;
$editor = new DotenvEditor();

$editor->load($this->path);
$editor->set('EXAMPLE_CONFIG', 'foo');
Expand All @@ -93,7 +93,7 @@ public function config_values_can_be_saved_to_a_new_path()
/** @test */
public function multiple_config_values_can_be_saved()
{
$editor = new DotenvEditor;
$editor = new DotenvEditor();

$editor->load($this->path);
$editor->set('EXAMPLE_CONFIG', 'foo');
Expand All @@ -111,7 +111,7 @@ public function multiple_config_values_can_be_saved()
/** @test */
public function line_breaks_can_be_added()
{
$editor = new DotenvEditor;
$editor = new DotenvEditor();

$editor->load($this->path);
$editor->set('EXAMPLE_CONFIG', 'foo');
Expand All @@ -128,7 +128,7 @@ public function line_breaks_can_be_added()
/** @test */
public function headings_can_be_added()
{
$editor = new DotenvEditor;
$editor = new DotenvEditor();

$editor->load($this->path);
$editor->heading('Examples');
Expand All @@ -144,7 +144,7 @@ public function headings_can_be_added()
/** @test */
public function headings_get_added_with_a_new_line_after_a_non_blank_entry()
{
$editor = new DotenvEditor;
$editor = new DotenvEditor();

$editor->load($this->path);
$editor->set('APP_KEY', 'bar');
Expand All @@ -163,7 +163,7 @@ public function headings_get_added_with_a_new_line_after_a_non_blank_entry()
/** @test */
public function values_from_files_are_imported_on_load()
{
$editor = new DotenvEditor;
$editor = new DotenvEditor();

$editor->load(__DIR__.'/Fixtures/env-example');

Expand All @@ -180,7 +180,7 @@ public function values_from_files_are_imported_on_load()
/** @test */
public function keys_can_be_checked_for()
{
$editor = new DotenvEditor;
$editor = new DotenvEditor();
$editor->load(__DIR__.'/Fixtures/env-example');

$this->assertTrue($editor->has('EXAMPLE_2'));
Expand All @@ -190,7 +190,7 @@ public function keys_can_be_checked_for()
public function configuration_values_can_be_merge_with_an_existing_config()
{
copy(__DIR__.'/Fixtures/env-example', $this->path);
$editor = new DotenvEditor;
$editor = new DotenvEditor();
$editor->load($this->path);

$editor->heading('Foo');
Expand All @@ -210,7 +210,7 @@ public function leaves_blank_settings_as_they_were()
$fixturePath = __DIR__.'/Fixtures/env-laravel';
copy($fixturePath, $this->path);

$editor = new DotenvEditor;
$editor = new DotenvEditor();
$editor->load($this->path);

$editor->set('FOO', 'bar');
Expand All @@ -227,7 +227,7 @@ public function an_exception_is_thrown_if_the_file_does_not_exist()
{
$this->expectException(InvalidArgumentException::class);

$editor = new DotenvEditor;
$editor = new DotenvEditor();
$editor->load(__DIR__.'/.env');
}

Expand All @@ -237,7 +237,7 @@ public function returns_true_if_file_is_written()
$fixturePath = __DIR__.'/Fixtures/env-laravel';
copy($fixturePath, $this->path);

$editor = new DotenvEditor;
$editor = new DotenvEditor();
$editor->load($this->path);

$this->assertTrue($editor->save());
Expand All @@ -248,7 +248,7 @@ public function does_not_modify_app_key()
{
$fixturePath = __DIR__.'/Fixtures/env-laravel';

$editor = new DotenvEditor;
$editor = new DotenvEditor();
$editor->load($fixturePath);
$this->assertEquals(
'base64:LPqcjIZ3/T2pO4yrL7vgb6W/+hgyau002onyOKHvzfo=',
Expand Down

0 comments on commit c13a1a0

Please sign in to comment.