当前位置: 首页>>代码示例>>PHP>>正文


PHP EventManager::matchingListeners方法代码示例

本文整理汇总了PHP中Cake\Event\EventManager::matchingListeners方法的典型用法代码示例。如果您正苦于以下问题:PHP EventManager::matchingListeners方法的具体用法?PHP EventManager::matchingListeners怎么用?PHP EventManager::matchingListeners使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Event\EventManager的用法示例。


在下文中一共展示了EventManager::matchingListeners方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testMatchingListeners

 /**
  * Tests attached event listeners for matching key pattern
  *
  * @return void
  */
 public function testMatchingListeners()
 {
     $manager = new EventManager();
     $manager->attach('fakeFunction1', 'fake.event');
     $manager->attach('fakeFunction2', 'real.event');
     $manager->attach('fakeFunction3', 'test.event');
     $manager->attach('fakeFunction4', 'event.test');
     $this->assertArrayHasKey('fake.event', $manager->matchingListeners('fake.event'));
     $this->assertArrayHasKey('real.event', $manager->matchingListeners('real.event'));
     $this->assertArrayHasKey('test.event', $manager->matchingListeners('test.event'));
     $this->assertArrayHasKey('event.test', $manager->matchingListeners('event.test'));
     $this->assertArrayHasKey('fake.event', $manager->matchingListeners('fake'));
     $this->assertArrayHasKey('real.event', $manager->matchingListeners('real'));
     $this->assertArrayHasKey('test.event', $manager->matchingListeners('test'));
     $this->assertArrayHasKey('event.test', $manager->matchingListeners('test'));
     $this->assertArrayHasKey('fake.event', $manager->matchingListeners('event'));
     $this->assertArrayHasKey('real.event', $manager->matchingListeners('event'));
     $this->assertArrayHasKey('test.event', $manager->matchingListeners('event'));
     $this->assertArrayHasKey('event.test', $manager->matchingListeners('event'));
     $this->assertArrayHasKey('fake.event', $manager->matchingListeners('.event'));
     $this->assertArrayHasKey('real.event', $manager->matchingListeners('.event'));
     $this->assertArrayHasKey('test.event', $manager->matchingListeners('.event'));
     $this->assertArrayHasKey('test.event', $manager->matchingListeners('test.'));
     $this->assertArrayHasKey('event.test', $manager->matchingListeners('.test'));
     $this->assertEmpty($manager->matchingListeners('/test'));
     $this->assertEmpty($manager->matchingListeners('test/'));
     $this->assertEmpty($manager->matchingListeners('/test/'));
     $this->assertEmpty($manager->matchingListeners('test$'));
     $this->assertEmpty($manager->matchingListeners('ev.nt'));
     $this->assertEmpty($manager->matchingListeners('^test'));
     $this->assertEmpty($manager->matchingListeners('^event'));
     $this->assertEmpty($manager->matchingListeners('*event'));
     $this->assertEmpty($manager->matchingListeners('event*'));
     $this->assertEmpty($manager->matchingListeners('foo'));
     $expected = ['fake.event', 'real.event', 'test.event', 'event.test'];
     $result = $manager->matchingListeners('event');
     $this->assertNotEmpty($result);
     $this->assertSame($expected, array_keys($result));
     $expected = ['fake.event', 'real.event', 'test.event'];
     $result = $manager->matchingListeners('.event');
     $this->assertNotEmpty($result);
     $this->assertSame($expected, array_keys($result));
     $expected = ['test.event', 'event.test'];
     $result = $manager->matchingListeners('test');
     $this->assertNotEmpty($result);
     $this->assertSame($expected, array_keys($result));
     $expected = ['test.event'];
     $result = $manager->matchingListeners('test.');
     $this->assertNotEmpty($result);
     $this->assertSame($expected, array_keys($result));
     $expected = ['event.test'];
     $result = $manager->matchingListeners('.test');
     $this->assertNotEmpty($result);
     $this->assertSame($expected, array_keys($result));
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:60,代码来源:EventManagerTest.php


注:本文中的Cake\Event\EventManager::matchingListeners方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。