callInitialize() публичный Метод

Invokes initialize method for each plugin registered.
public callInitialize ( )
Пример #1
0
 public function testCallInitialize()
 {
     $pm = new PluginManager(new EventDispatcher());
     $plugin1 = $this->getMockBuilder('\\Yosymfony\\Spress\\Core\\Plugin\\PluginInterface')->getMock();
     $plugin2 = $this->getMockBuilder('\\Yosymfony\\Spress\\Core\\Plugin\\PluginInterface')->getMock();
     $plugin1->expects($this->once())->method('initialize');
     $plugin2->expects($this->once())->method('initialize');
     $pluginCollection = $pm->getPluginCollection();
     $pluginCollection->add('plugin1', $plugin1);
     $pluginCollection->add('plugin2', $plugin2);
     $pm->callInitialize();
 }
Пример #2
0
 public function testPluginManager()
 {
     $pm = new PluginManager(new EventDispatcher());
     $plugin1 = $this->getMockBuilder('\\Yosymfony\\Spress\\Core\\Plugin\\PluginInterface')->getMock();
     $plugin2 = $this->getMockBuilder('\\Yosymfony\\Spress\\Core\\Plugin\\PluginInterface')->getMock();
     $plugin1->expects($this->once())->method('initialize');
     $plugin2->expects($this->once())->method('initialize');
     $pm->addPlugin('plugin1', $plugin1);
     $pm->setPlugin('plugin2', $plugin2);
     $this->assertEquals(2, $pm->countPlugins());
     $this->assertCount(2, $pm->getPlugins());
     $this->assertContainsOnlyInstancesOf('\\Yosymfony\\Spress\\Core\\Plugin\\PluginInterface', $pm->getPlugins());
     $this->assertTrue($pm->hasPlugin('plugin1'));
     $this->assertFalse($pm->hasPlugin('plugin3'));
     $this->assertInstanceOf('\\Yosymfony\\Spress\\Core\\Plugin\\PluginInterface', $pm->getPlugin('plugin1'));
     $pm->callInitialize();
     $pm->removePlugin('plugin1');
     $this->assertEquals(1, $pm->countPlugins());
     $pm->clearPlugin();
     $this->assertEquals(0, $pm->countPlugins());
 }