Example #1
0
<?php

namespace Mauricext4fs\Redis;

// Static require, only testing the current module
require_once __DIR__ . "/../src/Mauricext4fs/Redis/RedisController.php";
$objRedis = new RedisController();
printf("Starting new List Test" . PHP_EOL);
// Adding duplicate ascii element to a set
$strListName = uniqid();
$arrList = array("test1", "test2", "test3", "test3", "test4");
foreach ($arrList as $strValue) {
    $objRedis->addValueToList($strListName, $strValue);
}
// getting the List back
$arrListFromRedis = $objRedis->getList($strListName);
// Check that all value from the orginal value exist in Redis
printf("Check value from original List from Redis.......         ");
$boolFail = false;
foreach ($arrList as $strKey => $strValue) {
    if (!in_array($strValue, $arrListFromRedis)) {
        printf("Fail! %s", PHP_EOL);
        $boolFail = true;
        break;
    }
}
if ($boolFail === false) {
    printf("OK!%s", PHP_EOL);
}
// Check that all value from Redis List exist in the orginal value
printf("Check value from Redis List in original List.......      ");