From: jenkins-bot Date: Thu, 12 May 2016 22:58:57 +0000 (+0000) Subject: Merge "Follow-up cdc93a62bf: add serialize/unserialize tests for RedisBagOStuff" X-Git-Tag: 1.31.0-rc.0~6990 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=c3294b2d7142987c0ae93ce71737fdb02550e28e;hp=20abb707ba23e0649a48a3ab0153c765e21b4ccf;p=lhc%2Fweb%2Fwiklou.git Merge "Follow-up cdc93a62bf: add serialize/unserialize tests for RedisBagOStuff" --- diff --git a/tests/phpunit/includes/objectcache/RedisBagOStuffTest.php b/tests/phpunit/includes/objectcache/RedisBagOStuffTest.php new file mode 100644 index 0000000000..cf87a98098 --- /dev/null +++ b/tests/phpunit/includes/objectcache/RedisBagOStuffTest.php @@ -0,0 +1,101 @@ +cache = TestingAccessWrapper::newFromObject( new RedisBagOStuff( [ 'servers' => [] ] ) ); + } + + /** + * @covers RedisBagOStuff::unserialize + * @dataProvider unserializeProvider + */ + public function testUnserialize( $expected, $input, $message ) { + $actual = $this->cache->unserialize( $input ); + $this->assertSame( $expected, $actual, $message ); + } + + public function unserializeProvider() { + return [ + [ + -1, + '-1', + 'String representation of \'-1\'', + ], + [ + 0, + '0', + 'String representation of \'0\'', + ], + [ + 1, + '1', + 'String representation of \'1\'', + ], + [ + -1.0, + 'd:-1;', + 'Serialized negative double', + ], + [ + 'foo', + 's:3:"foo";', + 'Serialized string', + ] + ]; + } + + /** + * @covers RedisBagOStuff::serialize + * @dataProvider serializeProvider + */ + public function testSerialize( $expected, $input, $message ) { + $actual = $this->cache->serialize( $input ); + $this->assertSame( $expected, $actual, $message ); + } + + public function serializeProvider() { + return [ + [ + -1, + -1, + '-1 as integer', + ], + [ + 0, + 0, + '0 as integer', + ], + [ + 1, + 1, + '1 as integer', + ], + [ + 'd:-1;', + -1.0, + 'Negative double', + ], + [ + 's:3:"2.1";', + '2.1', + 'Decimal string', + ], + [ + 's:1:"1";', + '1', + 'String representation of 1', + ], + [ + 's:3:"foo";', + 'foo', + 'String', + ], + ]; + } +}