public function testGetValue() { $this->assertEquals('local', $this->module->getCurrentConn()); $this->assertNotInstanceOf('insolita\\redisman\\components\\PhpredisConnection', $this->module->getConnection()); $model = new RedisItem(); $model->setAttributes(['key' => 'tfx_string', 'type' => 'string']); $this->assertTrue($model->validate()); $val = $model->getValue(); $this->assertEquals('somestringval', $val); $model = new RedisItem(); $model->setAttributes(['key' => 'tfx_list', 'type' => 'list']); $this->assertTrue($model->validate()); $val = $model->getValue(); $this->assertTrue(is_array($val)); $this->assertEquals(['someval1', 'someval2', 'someval3'], $val); $model = new RedisItem(); $model->setAttributes(['key' => 'tfx_set', 'type' => 'set']); $this->assertTrue($model->validate()); $val = $model->getValue(); $this->assertTrue(is_array($val)); $this->assertTrue(in_array('someval4', $val)); $this->assertTrue(in_array('someval1', $val)); $this->assertTrue(in_array('someval2', $val)); $this->assertTrue(in_array('someval3', $val)); $model = new RedisItem(); $model->setAttributes(['key' => 'testfxt:3:hash']); $this->assertTrue($model->validate()); $val = $model->getValue(); Debug::debug($model->getAttributes()); Debug::debug($val); Debug::debug($model->findValue()->getAttributes()); Debug::debug($this->module->executeCommand('HGETALL', ['testfxt:3:hash'])); $this->assertTrue(is_array($val)); $this->assertEquals($this->module->executeCommand('HGETALL', ['testfxt:3:hash']), $val); $model = new RedisItem(); $model->setAttributes(['key' => 'tfx_zset', 'type' => 'zset']); $this->assertTrue($model->validate()); $val = $model->getValue(); $this->assertTrue(is_array($val)); $this->assertEquals(['someval2', 3, 'someval1', 4, 'someval3', 8], $val); }
/** * @return \yii\web\Response */ public function actionRemfield() { $model = new RedisItem(); $model->scenario = 'remfield'; if ($model->load(\Yii::$app->request->get()) && $model->validate()) { $model->remfield(); } $model->findValue(); return $model->type ? $this->renderAjax('form_' . $model->type, compact('model')) : $this->redirect(['view', 'key' => urldecode($model->key)]); }