mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-01 11:39:41 +08:00
Fixes #16377: Fixed yii\base\Event:off() undefined index error when event handler does not match
This commit is contained in:
committed by
Alexander Makarov
parent
858d3531ed
commit
ca3c8da503
@ -91,6 +91,14 @@ class EventTest extends TestCase
|
||||
$this->assertTrue(Event::hasHandlers('yiiunit\framework\base\SomeInterface', SomeInterface::EVENT_SUPER_EVENT));
|
||||
}
|
||||
|
||||
public function testOffUnmatchedHandler()
|
||||
{
|
||||
$this->assertFalse(Event::hasHandlers(Post::className(), 'afterSave'));
|
||||
Event::on(Post::className(), 'afterSave', [$this, 'bla-bla']);
|
||||
$this->assertFalse(Event::off(Post::className(), 'afterSave', [$this, 'bla-bla-bla']));
|
||||
$this->assertTrue(Event::off(Post::className(), 'afterSave', [$this, 'bla-bla']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testOn
|
||||
* @depends testHasHandlers
|
||||
|
||||
Reference in New Issue
Block a user