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

Version 0.2.0 #19

Merged
merged 20 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2df1431
Tag version 0.1.0 in the changelog
stevegrunwell Sep 25, 2020
47fc361
Introduce a Runkit support class
stevegrunwell Oct 26, 2020
9739fb3
Add type-hints, autoload the PHPUnit Bridge-installed version of PHPU…
stevegrunwell Oct 26, 2020
350b678
Print the PHPUnit version before running static code analysis
stevegrunwell Oct 26, 2020
0e214b4
Fix error message, unavailable => available
stevegrunwell Oct 26, 2020
582f8db
Merge pull request #15 from assertwell/feature/runkit-proxy
stevegrunwell Oct 26, 2020
a14f08b
Simplify the resetting of state properties in each trait
stevegrunwell Oct 29, 2020
d139bd0
Clean up some risky test warnings on PHPUnit 5.x
stevegrunwell Oct 29, 2020
d1a4e6e
Use the Symfony\Bridge\PhpUnit\SetUpTearDownTrait trait to avoid conf…
stevegrunwell Oct 29, 2020
e8a9571
Merge pull request #16 from assertwell/fix/track-initialization-of-fi…
stevegrunwell Oct 29, 2020
b38ecb3
Define the Functions trait
stevegrunwell Oct 31, 2020
6453c48
To avoid users from having to deal with conflict resolution, do away …
stevegrunwell Oct 31, 2020
510b10e
Update Composer dependencies
stevegrunwell Nov 22, 2020
fd0476c
Merge pull request #17 from assertwell/feature/functions-trait
stevegrunwell Nov 22, 2020
0334650
Clean up language in the "Functions" trait's docs + testdox
stevegrunwell Nov 24, 2020
cabfb31
Changelog update for v0.2.0
stevegrunwell Nov 24, 2020
8f78e91
Install different versions of Runkit(7) based on the PHP version
stevegrunwell Nov 24, 2020
699b889
Allow PHP 7.0 to be skipped with regards to runkit7
stevegrunwell Nov 24, 2020
8a1c8ed
Merge pull request #20 from assertwell/fix/runkit-install-on-older-php7
stevegrunwell Nov 24, 2020
859d3d3
Merge branch 'develop' into release/v0.2.0
stevegrunwell Nov 24, 2020
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
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