Skip to content

Commit

Permalink
Merge pull request #19 from assertwell/release/v0.2.0
Browse files Browse the repository at this point in the history
Version 0.2.0
  • Loading branch information
stevegrunwell authored Nov 24, 2020
2 parents 8775a0f + 859d3d3 commit 6e847f2
Show file tree
Hide file tree
Showing 25 changed files with 1,160 additions and 204 deletions.
35 changes: 34 additions & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,43 @@ jobs:

- name: Configure PHP environment
uses: shivammathur/setup-php@v2
if: ${{ matrix.php >= '7.2' }}
with:
php-version: ${{ matrix.php }}
tools: pecl
extensions: runkit, runkit7-alpha
extensions: runkit7-alpha
env:
fail-fast: true

- name: Configure PHP environment (PHP 7.1 only)
uses: shivammathur/setup-php@v2
if: ${{ matrix.php == '7.1' }}
with:
php-version: ${{ matrix.php }}
tools: pecl
extensions: runkit7-3.1.0a1
env:
fail-fast: true

# Version 2.x of runkit7 dropped PHP 7.0 support, but older releases are not available via PECL.
# https://pecl.php.net/package/runkit7
- name: Configure PHP environment (PHP 7.0 only)
uses: shivammathur/setup-php@v2
if: ${{ matrix.php == '7.0' }}
with:
php-version: ${{ matrix.php }}
tools: pecl
extensions: runkit7-1.0.11

- name: Configure PHP environment (PHP 5.x only)
uses: shivammathur/setup-php@v2
if: ${{ matrix.php <= '5.6' }}
with:
php-version: ${{ matrix.php }}
tools: pecl
extensions: runkit
env:
fail-fast: true

- name: Validate composer.json and composer.lock
run: composer validate
Expand Down
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [Version 0.2.0] — 2020-11-23

* Introduce a [new `AssertWell\PHPUnitGlobalState\Functions` trait](docs/Functions.md) ([#17])
* Introduce an `AssertWell\PHPUnitGlobalState\Support\Runkit` support class ([#15])
* Simplify the cleanup between tests of of the private properties that hold changes ([#16])


## [Version 0.1.0] — 2020-09-25

Initial public release of the package, with the following traits:

Expand All @@ -14,3 +21,8 @@ Initial public release of the package, with the following traits:


[Unreleased]: https://github.com/assertwell/phpunit-global-state/compare/master...develop
[Version 0.1.0]: https://github.com/assertwell/phpunit-global-state/tag/v0.1.0
[Version 0.2.0]: https://github.com/assertwell/phpunit-global-state/tag/v0.1.0
[#15]: https://github.com/assertwell/phpunit-global-state/pull/15
[#16]: https://github.com/assertwell/phpunit-global-state/pull/16
[#17]: https://github.com/assertwell/phpunit-global-state/pull/17
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MyTestClass extends TestCase

### Introduction to Runkit

Some of the traits will rely on [Runkit7](https://www.php.net/runkit7), a port of PHP's runkit designed to work in PHP 7.x, to rewrite code at runtime (a.k.a. "monkey-patching").
Some of the traits will rely on [Runkit7], a port of PHP's runkit designed to work in PHP 7.x, to rewrite code at runtime (a.k.a. "monkey-patching").

For example, once a PHP constant is defined, it will normally have that value until the PHP process ends. Under normal circumstances, that's great: it prevents the value from being accidentally overwritten and/or tampered with.

Expand All @@ -46,7 +46,7 @@ var_dump(SOME_CONSTANT)
#=> string(10) "some value"

// Now, re-define the constant.
runkit_constant_redefine('SOME_CONSTANT', 'some other value');
runkit7_constant_redefine('SOME_CONSTANT', 'some other value');
var_dump(SOME_CONSTANT)
#=> string(16) "some other value"
```
Expand All @@ -57,11 +57,14 @@ Of course, we might want a constant's original value to be restored after our te

The library offers a number of traits, based on the type of global state that might need to be manipulated.

* [Constants](docs/Constants.md) (requires Runkit7)
* [Constants](docs/Constants.md) (requires [Runkit7])
* [Environment Variables](docs/EnvironmentVariables.md)
* [Functions](docs/Functions.md) (requires [Runkit7])
* [Global Variables](docs/GlobalVariables.md)


## Contributing

If you're interested in contributing to the library, [please review our contributing guidelines](.github/CONTRIBUTING.md).

[Runkit7]: docs/Runkit.md
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/phpstan": "^0.12",
"squizlabs/php_codesniffer": "^3.5",
"stevegrunwell/runkit7-installer": "^1.1",
"stevegrunwell/runkit7-installer": "^1.2",
"symfony/phpunit-bridge": "^5.1"
},
"suggest": {
Expand All @@ -42,7 +42,10 @@
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"files": [
"tests/stubs/functions.php"
]
},
"config": {
"preferred-install": "dist",
Expand All @@ -56,7 +59,8 @@
"@test:analysis"
],
"test:analysis": [
"phpstan analyse"
"simple-phpunit --version",
"phpstan analyse -c phpstan.neon.dist"
],
"test:coverage": [
"phpdbg -qrr -d memory_limit=-1 ./vendor/bin/simple-phpunit --colors=always --testdox --coverage-html=tests/coverage"
Expand Down
81 changes: 50 additions & 31 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions docs/Constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@

Some applications — especially WordPress — will use [PHP constants](https://www.php.net/manual/en/language.constants.php) for configuration that should not be edited directly through the <abbr title="User Interface">UI</abbr>.

Normally, a constant cannot be redefined or removed once defined; however, [the runkit7 extension](https://www.php.net/manual/en/book.runkit7) exposes functions to modify normally immutable constructs.
Normally, a constant cannot be redefined or removed once defined; however, [the runkit7 extension](Runkit.md) exposes functions to modify normally immutable constructs.

If runkit functions are unavailable, the `Constants` trait will automatically skip tests that rely on this functionality.

In order to install runkit7 in your development and CI environments, you may use [the installer bundled with this repo](https://github.com/stevegrunwell/runkit7-installer):

```sh
$ sudo ./vendor/bin/install-runkit.sh
```

## Methods

Expand Down
Loading

0 comments on commit 6e847f2

Please sign in to comment.