/** * @test Implementation */ public function flushByTagRemovesIdentifiersTaggedWithGivenTagFromTagToIdentifiersSets() { $this->setUpBackend(); $this->setUpRedis(); $identifier = 'identifier' . uniqid(); $this->backend->set($identifier . 'A', 'data', array('tag1', 'tag2')); $this->backend->set($identifier . 'B', 'data', array('tag1', 'tag2')); $this->backend->set($identifier . 'C', 'data', array('tag2')); $this->backend->flushByTag('tag1'); $this->assertSame(array($identifier . 'C'), $this->redis->sMembers('tagIdents:tag2')); }
/** * @test */ public function flushByTagFlushesEntryByTag() { for ($i = 0; $i < 10; $i++) { $this->backend->set('entry_' . $i, 'foo', array('tag1', 'tag2')); } for ($i = 10; $i < 20; $i++) { $this->backend->set('entry_' . $i, 'foo', array('tag2')); } $this->assertCount(10, $this->backend->findIdentifiersByTag('tag1')); $this->assertCount(20, $this->backend->findIdentifiersByTag('tag2')); $count = $this->backend->flushByTag('tag1'); $this->assertEquals(10, $count, 'flushByTag returns amount of flushed entries'); $this->assertCount(0, $this->backend->findIdentifiersByTag('tag1')); $this->assertCount(10, $this->backend->findIdentifiersByTag('tag2')); }