Skip to content

Commit

Permalink
#872 full correction of TWeakCallableCollectionTest
Browse files Browse the repository at this point in the history
  • Loading branch information
belisoful authored and ctrlaltca committed Apr 18, 2023
1 parent 0d9c55d commit 04e4429
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/unit/Collections/TWeakCallableCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Prado\Exceptions\TInvalidDataTypeException;
use Prado\Exceptions\TInvalidDataValueException;
use Prado\Exceptions\TInvalidOperationException;
use Prado\Exceptions\TPhpErrorException;

class CallableListItem
{
Expand Down Expand Up @@ -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
Expand All @@ -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');
Expand All @@ -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);

}

Expand Down

0 comments on commit 04e4429

Please sign in to comment.