Skip to content

Commit

Permalink
Merge pull request #26 from assertwell/release/v0.2.1
Browse files Browse the repository at this point in the history
Version 0.2.1
  • Loading branch information
stevegrunwell authored Apr 15, 2021
2 parents 6e847f2 + a28c743 commit 6377723
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ 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).

## [Version 0.2.1] — 2021-04-15

* Mark tests that use `defineFunction()` or `deleteFunction()` as skipped if Runkit is unavailable ([#25])
* Fix coding standards, remove unused namespace imports ([#22], props [@peter279k](https://github.com/peter279k))


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

* Introduce a [new `AssertWell\PHPUnitGlobalState\Functions` trait](docs/Functions.md) ([#17])
Expand All @@ -22,7 +28,10 @@ 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
[Version 0.2.0]: https://github.com/assertwell/phpunit-global-state/tag/v0.2.0
[Version 0.2.1]: https://github.com/assertwell/phpunit-global-state/tag/v0.2.1
[#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
[#22]: https://github.com/assertwell/phpunit-global-state/pull/22
[#25]: https://github.com/assertwell/phpunit-global-state/pull/25
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ parameters:

# Strings are a valid callable type.
-
message: '#Parameter \#1 \$function of function call_user_func_array expects callable\(\): mixed, string given\.#'
message: '#Parameter \#1 \S+ of function call_user_func_array expects callable\(\): mixed, string given\.#'
path: src/Support/Runkit.php

# Dynamically-defined functions.
Expand Down
8 changes: 8 additions & 0 deletions src/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ protected function restoreFunctions()
*/
protected function defineFunction($name, \Closure $closure)
{
if (! Runkit::isAvailable()) {
$this->markTestSkipped('defineFunction() requires Runkit be available, skipping.');
}

if (function_exists($name)) {
throw new FunctionExistsException(sprintf(
'Function %1$s() already exists. You may redefine it using %2$s::redefineFunction() instead.',
Expand Down Expand Up @@ -130,6 +134,10 @@ protected function deleteFunction($name)
return $this;
}

if (! Runkit::isAvailable()) {
$this->markTestSkipped('deleteFunction() requires Runkit be available, skipping.');
}

$namespaced = Runkit::makeNamespaced($name);

if (! Runkit::function_rename($name, $namespaced)) {
Expand Down
1 change: 0 additions & 1 deletion tests/ConstantsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use AssertWell\PHPUnitGlobalState\Exceptions\RedefineException;
use AssertWell\PHPUnitGlobalState\Support\Runkit;
use PHPUnit\Framework\SkippedTestError;

/**
* @covers AssertWell\PHPUnitGlobalState\Constants
Expand Down
5 changes: 3 additions & 2 deletions tests/FixtureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Tests;

use AssertWell\PHPUnitGlobalState\Exceptions\RedefineException;
use PHPUnit\Framework\SkippedTestError;
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;

/**
Expand All @@ -15,6 +13,9 @@ class FixtureTest extends TestCase
{
use SetUpTearDownTrait;

/**
* @var array<string>
*/
protected $backupGlobalsBlacklist = [
'FIXTURE_BEFORE_GLOBAL',
'FIXTURE_SETUP_GLOBAL',
Expand Down
3 changes: 3 additions & 0 deletions tests/GlobalVariablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*/
class GlobalVariablesTest extends TestCase
{
/**
* @var array<string>
*/
protected $backupGlobalsBlacklist = [
'setGlobalVariable',
];
Expand Down

0 comments on commit 6377723

Please sign in to comment.