Skip to content

Commit

Permalink
MDL-63127 cachestore_redis: cover combinations without compressor
Browse files Browse the repository at this point in the history
To verify that, internally, everything is stored as expected
and there aren't hidden regressions
  • Loading branch information
stronk7 authored and mdjnelson committed Oct 7, 2019
1 parent 182a069 commit f232409
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions cache/stores/redis/tests/compressor_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,30 @@ public function test_it_works_with_different_types_for_many() {
*/
public function provider_for_test_it_can_use_serializers() {
$data = [
['none', Redis::SERIALIZER_NONE, gzencode('value1'), gzencode('value2')],
['php', Redis::SERIALIZER_PHP, gzencode(serialize('value1')), gzencode(serialize('value2'))],
['none, none',
Redis::SERIALIZER_NONE, cachestore_redis::COMPRESSOR_NONE,
'value1', 'value2'],
['none, gzip',
Redis::SERIALIZER_NONE, cachestore_redis::COMPRESSOR_PHP_GZIP,
gzencode('value1'), gzencode('value2')],
['php, none',
Redis::SERIALIZER_PHP, cachestore_redis::COMPRESSOR_NONE,
serialize('value1'), serialize('value2')],
['php, gzip',
Redis::SERIALIZER_PHP, cachestore_redis::COMPRESSOR_PHP_GZIP,
gzencode(serialize('value1')), gzencode(serialize('value2'))],
];

if (defined('Redis::SERIALIZER_IGBINARY')) {
$data[] = [
'igbinary',
Redis::SERIALIZER_IGBINARY,
gzencode(igbinary_serialize('value1')),
gzencode(igbinary_serialize('value2')),
'igbinary, none',
Redis::SERIALIZER_IGBINARY, cachestore_redis::COMPRESSOR_NONE,
igbinary_serialize('value1'), igbinary_serialize('value2'),
];
$data[] = [
'igbinary, gzip',
Redis::SERIALIZER_IGBINARY, cachestore_redis::COMPRESSOR_PHP_GZIP,
gzencode(igbinary_serialize('value1')), gzencode(igbinary_serialize('value2')),
];
}

Expand All @@ -194,12 +208,13 @@ public function provider_for_test_it_can_use_serializers() {
* @dataProvider provider_for_test_it_can_use_serializers
* @param string $name
* @param int $serializer
* @param int $compressor
* @param string $rawexpected1
* @param string $rawexpected2
*/
public function test_it_can_use_serializers_getset($name, $serializer, $rawexpected1, $rawexpected2) {
public function test_it_can_use_serializers_getset($name, $serializer, $compressor, $rawexpected1, $rawexpected2) {
// Create a connection with the desired serialisation.
$store = $this->create_store(cachestore_redis::COMPRESSOR_PHP_GZIP, $serializer);
$store = $this->create_store($compressor, $serializer);
$store->set('key', 'value1');

// Disable compressor and serializer to check the actual stored value.
Expand All @@ -217,10 +232,11 @@ public function test_it_can_use_serializers_getset($name, $serializer, $rawexpec
* @dataProvider provider_for_test_it_can_use_serializers
* @param string $name
* @param int $serializer
* @param int $compressor
* @param string $rawexpected1
* @param string $rawexpected2
*/
public function test_it_can_use_serializers_getsetmany($name, $serializer, $rawexpected1, $rawexpected2) {
public function test_it_can_use_serializers_getsetmany($name, $serializer, $compressor, $rawexpected1, $rawexpected2) {
$many = [
['key' => 'key1', 'value' => 'value1'],
['key' => 'key2', 'value' => 'value2'],
Expand All @@ -230,7 +246,7 @@ public function test_it_can_use_serializers_getsetmany($name, $serializer, $rawe
$rawexpectations = ['key1' => $rawexpected1, 'key2' => $rawexpected2];

// Create a connection with the desired serialisation.
$store = $this->create_store(cachestore_redis::COMPRESSOR_PHP_GZIP, $serializer);
$store = $this->create_store($compressor, $serializer);
$store->set_many($many);

// Disable compressor and serializer to check the actual stored value.
Expand Down

0 comments on commit f232409

Please sign in to comment.