public function testPluginRegistry() { $this->_storage = $this->getMockForAbstractAdapter(); $plugin = new \ZendTest\Cache\Storage\TestAsset\MockPlugin(); // no plugin registered $this->assertFalse($this->_storage->hasPlugin($plugin)); $this->assertEquals(0, count($this->_storage->getPlugins())); $this->assertEquals(0, count($plugin->getHandles())); // register a plugin $this->assertSame($this->_storage, $this->_storage->addPlugin($plugin)); $this->assertTrue($this->_storage->hasPlugin($plugin)); $this->assertEquals(1, count($this->_storage->getPlugins())); // test registered callback handles $handles = $plugin->getHandles(); $this->assertEquals(1, count($handles)); $this->assertEquals(count($plugin->getEventCallbacks()), count(current($handles))); // test unregister a plugin $this->assertSame($this->_storage, $this->_storage->removePlugin($plugin)); $this->assertFalse($this->_storage->hasPlugin($plugin)); $this->assertEquals(0, count($this->_storage->getPlugins())); $this->assertEquals(0, count($plugin->getHandles())); }
public function testPluginRegistry() { $plugin = new \ZendTest\Cache\Storage\TestAsset\MockPlugin(); // no plugin registered $this->assertFalse($this->_storage->hasPlugin($plugin)); $this->assertEquals(0, count($this->_storage->getPlugins())); $this->assertEquals(0, count($plugin->getHandles())); // register a plugin $this->assertSame($this->_storage, $this->_storage->addPlugin($plugin)); $this->assertTrue($this->_storage->hasPlugin($plugin)); $this->assertEquals(1, count($this->_storage->getPlugins())); // test registered callback handles $handles = $plugin->getHandles(); $this->assertEquals(1, count($handles)); $this->assertEquals(count($plugin->getEventCallbacks()), count(current($handles))); // test unregister a plugin $this->assertSame($this->_storage, $this->_storage->removePlugin($plugin)); $this->assertFalse($this->_storage->hasPlugin($plugin)); $this->assertEquals(0, count($this->_storage->getPlugins())); $this->assertEquals(0, count($plugin->getHandles())); // test plugin already unregistered $this->setExpectedException('Zend\\Cache\\Exception\\LogicException'); $this->_storage->removePlugin($plugin); }