+
+ /**
+ * @dataProvider validKeyProvider
+ * @covers MemcachedBagOStuff::validateKeyEncoding
+ */
+ public function testValidateKeyEncoding( $key ) {
+ $this->assertSame( $key, $this->cache->validateKeyEncoding( $key ) );
+ }
+
+ public function validKeyProvider() {
+ return [
+ 'empty' => [ '' ],
+ 'digits' => [ '09' ],
+ 'letters' => [ 'AZaz' ],
+ 'ASCII special characters' => [ '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' ],
+ ];
+ }
+
+ /**
+ * @dataProvider invalidKeyProvider
+ * @covers MemcachedBagOStuff::validateKeyEncoding
+ */
+ public function testValidateKeyEncodingThrowsException( $key ) {
+ $this->setExpectedException( 'Exception' );
+ $this->cache->validateKeyEncoding( $key );
+ }
+
+ public function invalidKeyProvider() {
+ return [
+ [ "\x00" ],
+ [ ' ' ],
+ [ "\x1F" ],
+ [ "\x7F" ],
+ [ "\x80" ],
+ [ "\xFF" ],
+ ];
+ }