From 9e8a044589cf2ac998e4f018d5e3af0ed6792426 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Fri, 2 Aug 2024 23:52:58 +0200 Subject: [PATCH] Fix 007.phpt for PHP 8.3 Since the behavior changed as of PHP 8.3.0, we split the test case, so every PHP version can be checked for the expected behavior. While we could use a regex to stick with a single test case, we want to precise about what to expect. --- tests/007.phpt | 5 +++ tests/007_1.phpt | 114 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 tests/007_1.phpt diff --git a/tests/007.phpt b/tests/007.phpt index a195901..bf862f6 100644 --- a/tests/007.phpt +++ b/tests/007.phpt @@ -2,6 +2,11 @@ uopz_get_static --EXTENSIONS-- uopz +--SKIPIF-- += 0) die("skip only for PHP < 8.3.0"); +?> --INI-- uopz.disable=0 --FILE-- diff --git a/tests/007_1.phpt b/tests/007_1.phpt new file mode 100644 index 0000000..b4942cc --- /dev/null +++ b/tests/007_1.phpt @@ -0,0 +1,114 @@ +--TEST-- +uopz_get_static +--EXTENSIONS-- +uopz +--SKIPIF-- += 8.3.0"); +?> +--INI-- +uopz.disable=0 +--FILE-- +method(); + +var_dump(uopz_get_static(Foo::class, "method")); + +try { + uopz_get_static(Foo::class, "none"); +} catch (RuntimeException $ex) { + var_dump($ex->getMessage()); +} + +try { + uopz_get_static("none"); +} catch (RuntimeException $ex) { + var_dump($ex->getMessage()); +} + +try { + uopz_get_static(DateTime::class, "__construct"); +} catch(RuntimeException $ex) { + var_dump($ex->getMessage()); +} + +try { + uopz_get_static("phpversion"); +} catch(RuntimeException $ex) { + var_dump($ex->getMessage()); +} + +try { + uopz_get_static(Foo::class, "nostatics"); +} catch(RuntimeException $ex) { + var_dump($ex->getMessage()); +} + +try { + uopz_get_static("nostatics"); +} catch(RuntimeException $ex) { + var_dump($ex->getMessage()); +} +?> +--EXPECTF-- +array(2) { + ["vars"]=> + array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + } + ["bar"]=> + NULL +} +array(2) { + ["vars"]=> + array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + [5]=> + int(6) + } + ["bar"]=> + string(3) "bar" +} +string(%d) "failed to get statics from method %s::%s, it does not exist" +string(%d) "failed to get statics from function %s, it does not exist" +string(%d) "failed to get statics from internal method %s::%s" +string(%d) "failed to get statics from internal function %s" +string(%d) "failed to set statics in method %s::%s, no statics declared" +string(%d) "failed to set statics in function %s, no statics declared"