From 04e4429d3027a1deee4bdf9da7edf912dc3efdde Mon Sep 17 00:00:00 2001 From: Belisoful Date: Mon, 17 Apr 2023 15:07:39 -0700 Subject: [PATCH] #872 full correction of TWeakCallableCollectionTest --- .../unit/Collections/TWeakCallableCollectionTest.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/unit/Collections/TWeakCallableCollectionTest.php b/tests/unit/Collections/TWeakCallableCollectionTest.php index 3ccae6369..169399703 100644 --- a/tests/unit/Collections/TWeakCallableCollectionTest.php +++ b/tests/unit/Collections/TWeakCallableCollectionTest.php @@ -4,6 +4,7 @@ use Prado\Exceptions\TInvalidDataTypeException; use Prado\Exceptions\TInvalidDataValueException; use Prado\Exceptions\TInvalidOperationException; +use Prado\Exceptions\TPhpErrorException; class CallableListItem { @@ -72,6 +73,11 @@ public function testToPriorityArrayWeakTWeakCallableCollection() $item2 = $list[] = ['CallableListItem', 'staticHandler']; $item3 = $list[] = [$this->item1, 'eventHandler']; $item4 = $list[] = 'CallableListItem::staticHandler'; + try { + $item5 = $list[] = ['CallableListItemChild','parent::staticHandler']; + } catch (TPhpErrorException $e) { + $item5 = $list[] = ['CallableListItemChild','staticHandler']; + } $item6 = $list[] = $this->item2; // Check that callables that have proper syntax but do not exist @@ -95,7 +101,8 @@ public function testToPriorityArrayWeakTWeakCallableCollection() try { $list[] = ['CallableListItemChild','parent::noMethod']; $this->fail('TInvalidDataValueException string of [valid static object, \'parent::nostaticmethod\'] that is not a method did not throw error'); - } catch(TInvalidDataValueException $e){} + } catch(TInvalidDataValueException $e) {// Catch PHP 8.1 + } catch(TPhpErrorException $e) {} // Catch PHP 8.2+ try { $list[] = $component; $this->fail('TInvalidDataValueException object without __invocke did not throw error'); @@ -117,7 +124,7 @@ public function testToPriorityArrayWeakTWeakCallableCollection() $this->assertEquals($p[$priority][2][0]->get(), $this->item1); $this->assertEquals($p[$priority][2][1], 'eventHandler'); $this->assertEquals($p[$priority][3], 'CallableListItem::staticHandler'); - $this->assertEquals($p[$priority][4]->get(), $this->item2); + $this->assertEquals($p[$priority][5]->get(), $this->item2); }