/** * @return string */ public function actionShow() { $model = new RedisModel(); $model->restoreFilter(); $dataProvider = $model->search(\Yii::$app->request->getQueryParams()); Url::remember(\Yii::$app->request->getUrl(), 'show'); return $this->render('show', ['model' => $model, 'dataProvider' => $dataProvider]); }
public function testSearchByTypes() { $this->module->greedySearch = true; $this->module->searchMethod = 'SCAN'; $model = new RedisModel(); $model->setAttributes(['pattern' => 'testfxt:*', 'type' => ['string'], 'perpage' => 10]); $dp = $model->search(['page' => 1]); $models = $dp->getModels(); $this->assertTrue(count($models) == 3); foreach ($models as $m) { $this->assertTrue($m['type'] == 'string'); } $model->setAttributes(['pattern' => 'testfxt:*', 'type' => ['list'], 'perpage' => 10]); $dp = $model->search(['page' => 1]); $models = $dp->getModels(); $this->assertTrue(count($models) == 3); foreach ($models as $m) { $this->assertTrue($m['type'] == 'list'); } $model->setAttributes(['pattern' => 'testfxt:*', 'type' => ['hash'], 'perpage' => 10]); $dp = $model->search(['page' => 1]); $models = $dp->getModels(); $this->assertTrue(count($models) == 3); foreach ($models as $m) { $this->assertTrue($m['type'] == 'hash'); } $model->setAttributes(['pattern' => 'testfxt:*', 'type' => ['set'], 'perpage' => 10]); $dp = $model->search(['page' => 1]); $models = $dp->getModels(); $this->assertTrue(count($models) == 3); foreach ($models as $m) { $this->assertTrue($m['type'] == 'set'); } $model->setAttributes(['pattern' => 'testfxt:*', 'type' => ['zset'], 'perpage' => 10]); $dp = $model->search(['page' => 1]); $models = $dp->getModels(); $this->assertTrue(count($models) == 3); foreach ($models as $m) { $this->assertTrue($m['type'] == 'zset'); } $model->setAttributes(['pattern' => 'testfxt:*', 'type' => ['zset', 'set'], 'perpage' => 10]); $dp = $model->search(['page' => 1]); $models = $dp->getModels(); $this->assertTrue(count($models) == 6); $model->setAttributes(['pattern' => 'testfxt:*', 'type' => ['zset', 'set', 'list', 'hash'], 'perpage' => 15]); $dp = $model->search(['page' => 1]); $models = $dp->getModels(); $this->assertTrue(count($models) == 12); foreach ($models as $m) { $this->assertTrue($m['type'] != 'string'); } }