Skip to content
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
29 changes: 29 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Coding standards

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-node-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run coding standards checks
run: composer test:standards
33 changes: 33 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Unit tests

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php: [7.0, 7.1, 7.2, 7.3, 7.4]
fail-fast: true

steps:
- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-node-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run test suite
run: composer test:unit
22 changes: 22 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<ruleset name="assertwell/phpunit-global-state">
<description>Coding standards for assertwell/phpunit-global-state.</description>

<arg value="sp" />
<arg name="basepath" value="./" />
<arg name="colors" />
<arg name="extensions" value="php" />
<arg name="parallel" value="8" />

<!-- Only scan PHP files that belong to the app. -->
<file>src</file>
<file>tests</file>

<!-- Use PSR-12 as a base. -->
<rule ref="PSR12" />

<!-- Test methods may use snake_case. -->
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<exclude-pattern>tests</exclude-pattern>
</rule>
</ruleset>
23 changes: 19 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "assertwell/phpunit-global-state",
"description": "Tools for safely manipulating global state in tests",
"description": "Tools for testing applications that depend on global state with PHPUnit",
"keywords": [
"env",
"environment variables",
Expand All @@ -24,7 +24,12 @@
"php": ">=7.0"
},
"require-dev": {
"phpunit/phpunit": "^8.3"
"phpunit/phpunit": "^8.3",
"squizlabs/php_codesniffer": "^3.5",
"stevegrunwell/runkit7-installer": "^1.1"
},
"suggest": {
"stevegrunwell/runkit7-installer": "Streamline installation of Runkit7"
},
"autoload": {
"psr-4": {
Expand All @@ -42,11 +47,21 @@
"optimize-autoloader": true
},
"scripts": {
"code-coverage": [
"test": [
"@test:unit"
],
"test:coverage": [
"phpdbg -qrr -d memory_limit=-1 ./vendor/bin/phpunit --colors=always --testdox --coverage-html=tests/coverage"
],
"test:standards": [
"phpcs"
],
"test:unit": [
"phpunit --testdox --colors=always"
]
},
"scripts-descriptions": {
"code-coverage": "Generate HTML code coverage reports in tests/coverage/."
"test:coverage": "Generate HTML code coverage reports in tests/coverage/.",
"test:unit": "Run unit tests for the library."
}
}
Loading