Permalink
Browse files

[tests] Fix expected exception message on wrong key type.

Redis >= 2.8 returns -WRONGTYPE errors instead of -ERR when executing
operations on wrong key type (such as trying to LPUSH on a string key).

Luckily for us, phpunit's @expectedExceptionMessage annotation actually
does not perform an exact match but works on a substring so we just omit
the initial part of the exception message to make the test work.
  • Loading branch information...
1 parent b26d610 commit 46920c9c77bcb2b044f67c90d0354d7d60325897 @nrk committed Nov 21, 2012
Showing with 78 additions and 78 deletions.
  1. +1 −1 tests/PHPUnit/ConnectionTestCase.php
  2. +2 −2 tests/Predis/ClientTest.php
  3. +1 −1 tests/Predis/Command/HashDeleteTest.php
  4. +1 −1 tests/Predis/Command/HashExistsTest.php
  5. +1 −1 tests/Predis/Command/HashGetAllTest.php
  6. +1 −1 tests/Predis/Command/HashGetMultipleTest.php
  7. +1 −1 tests/Predis/Command/HashGetTest.php
  8. +1 −1 tests/Predis/Command/HashIncrementByFloatTest.php
  9. +1 −1 tests/Predis/Command/HashIncrementByTest.php
  10. +1 −1 tests/Predis/Command/HashKeysTest.php
  11. +1 −1 tests/Predis/Command/HashLengthTest.php
  12. +1 −1 tests/Predis/Command/HashSetMultipleTest.php
  13. +1 −1 tests/Predis/Command/HashSetPreserveTest.php
  14. +1 −1 tests/Predis/Command/HashSetTest.php
  15. +1 −1 tests/Predis/Command/HashValuesTest.php
  16. +1 −1 tests/Predis/Command/KeySortTest.php
  17. +1 −1 tests/Predis/Command/ListIndexTest.php
  18. +1 −1 tests/Predis/Command/ListInsertTest.php
  19. +1 −1 tests/Predis/Command/ListLengthTest.php
  20. +1 −1 tests/Predis/Command/ListPopFirstTest.php
  21. +2 −2 tests/Predis/Command/ListPopLastPushHeadTest.php
  22. +1 −1 tests/Predis/Command/ListPopLastTest.php
  23. +1 −1 tests/Predis/Command/ListPushHeadTest.php
  24. +1 −1 tests/Predis/Command/ListPushHeadXTest.php
  25. +1 −1 tests/Predis/Command/ListPushTailTest.php
  26. +1 −1 tests/Predis/Command/ListPushTailXTest.php
  27. +1 −1 tests/Predis/Command/ListRangeTest.php
  28. +1 −1 tests/Predis/Command/ListRemoveTest.php
  29. +1 −1 tests/Predis/Command/ListSetTest.php
  30. +1 −1 tests/Predis/Command/ListTrimTest.php
  31. +1 −1 tests/Predis/Command/SetAddTest.php
  32. +1 −1 tests/Predis/Command/SetCardinalityTest.php
  33. +1 −1 tests/Predis/Command/SetDifferenceStoreTest.php
  34. +1 −1 tests/Predis/Command/SetDifferenceTest.php
  35. +1 −1 tests/Predis/Command/SetIntersectionStoreTest.php
  36. +1 −1 tests/Predis/Command/SetIntersectionTest.php
  37. +1 −1 tests/Predis/Command/SetIsMemberTest.php
  38. +1 −1 tests/Predis/Command/SetMembersTest.php
  39. +2 −2 tests/Predis/Command/SetMoveTest.php
  40. +1 −1 tests/Predis/Command/SetPopTest.php
  41. +1 −1 tests/Predis/Command/SetRandomMemberTest.php
  42. +1 −1 tests/Predis/Command/SetRemoveTest.php
  43. +1 −1 tests/Predis/Command/SetUnionStoreTest.php
  44. +1 −1 tests/Predis/Command/SetUnionTest.php
  45. +1 −1 tests/Predis/Command/StringAppendTest.php
  46. +1 −1 tests/Predis/Command/StringBitCountTest.php
  47. +1 −1 tests/Predis/Command/StringBitOpTest.php
  48. +1 −1 tests/Predis/Command/StringDecrementByTest.php
  49. +1 −1 tests/Predis/Command/StringDecrementTest.php
  50. +1 −1 tests/Predis/Command/StringGetBitTest.php
  51. +1 −1 tests/Predis/Command/StringGetRangeTest.php
  52. +1 −1 tests/Predis/Command/StringGetSetTest.php
  53. +1 −1 tests/Predis/Command/StringGetTest.php
  54. +1 −1 tests/Predis/Command/StringIncrementByFloatTest.php
  55. +1 −1 tests/Predis/Command/StringIncrementByTest.php
  56. +1 −1 tests/Predis/Command/StringIncrementTest.php
  57. +1 −1 tests/Predis/Command/StringSetBitTest.php
  58. +1 −1 tests/Predis/Command/StringSetRangeTest.php
  59. +1 −1 tests/Predis/Command/StringStrlenTest.php
  60. +1 −1 tests/Predis/Command/ZSetAddTest.php
  61. +1 −1 tests/Predis/Command/ZSetCardinalityTest.php
  62. +1 −1 tests/Predis/Command/ZSetCountTest.php
  63. +1 −1 tests/Predis/Command/ZSetIncrementByTest.php
  64. +1 −1 tests/Predis/Command/ZSetIntersectionStoreTest.php
  65. +1 −1 tests/Predis/Command/ZSetRangeByScoreTest.php
  66. +1 −1 tests/Predis/Command/ZSetRangeTest.php
  67. +1 −1 tests/Predis/Command/ZSetRankTest.php
  68. +1 −1 tests/Predis/Command/ZSetRemoveRangeByRankTest.php
  69. +1 −1 tests/Predis/Command/ZSetRemoveRangeByScoreTest.php
  70. +1 −1 tests/Predis/Command/ZSetRemoveTest.php
  71. +1 −1 tests/Predis/Command/ZSetReverseRangeByScoreTest.php
  72. +1 −1 tests/Predis/Command/ZSetReverseRangeTest.php
  73. +1 −1 tests/Predis/Command/ZSetReverseRankTest.php
  74. +1 −1 tests/Predis/Command/ZSetScoreTest.php
  75. +1 −1 tests/Predis/Command/ZSetUnionStoreTest.php
@@ -262,7 +262,7 @@ public function testReadsErrorRepliesAsResponseErrorObjects()
$connection->writeCommand($profile->createCommand('rpush', array('foo', 'baz')));
$this->assertInstanceOf('Predis\ResponseError', $error = $connection->read());
- $this->assertSame('ERR Operation against a key holding the wrong kind of value', $error->getMessage());
+ $this->assertRegExp('/[ERR|WRONGTYPE] Operation against a key holding the wrong kind of value/', $error->getMessage());
}
/**
@@ -313,7 +313,7 @@ public function testExecuteCommandReturnsParsedReplies()
/**
* @group disconnected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testExecuteCommandThrowsExceptionOnRedisError()
{
@@ -376,7 +376,7 @@ public function testCallingRedisCommandExecutesInstanceOfCommand()
/**
* @group disconnected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testCallingRedisCommandThrowsExceptionOnServerError()
{
@@ -102,7 +102,7 @@ public function testDeletesSpecifiedFieldsFromHash()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -91,7 +91,7 @@ public function testReturnsExistenceOfSpecifiedField()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -92,7 +92,7 @@ public function testReturnsAllTheFieldsAndTheirValues()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -108,7 +108,7 @@ public function testReturnsValuesOfSpecifiedFields()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -88,7 +88,7 @@ public function testReturnsValueOfSpecifiedField()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -113,7 +113,7 @@ public function testThrowsExceptionOnStringField()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -113,7 +113,7 @@ public function testThrowsExceptionOnStringField()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -92,7 +92,7 @@ public function testReturnsKeysOfHash()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -87,7 +87,7 @@ public function testReturnsLengthOfHash()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -114,7 +114,7 @@ public function testSetsTheSpecifiedFie()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -91,7 +91,7 @@ public function testSetsNewFieldsAndPreserversExistingOnes()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -90,7 +90,7 @@ public function testSetsValueOfSpecifiedField()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -92,7 +92,7 @@ public function testReturnsValuesOfHash()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -258,7 +258,7 @@ public function testSortWithGetModifiers()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -103,7 +103,7 @@ public function testReturnsElementAtNegativeIndex()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -111,7 +111,7 @@ public function testReturnsZeroLengthOnNonExistingList()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -98,7 +98,7 @@ public function testReturnsZeroLengthOnNonExistingList()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -98,7 +98,7 @@ public function testReturnsNullOnEmptyList()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -117,7 +117,7 @@ public function testReturnsNullOnEmptySource()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongTypeOfSourceKey()
{
@@ -130,7 +130,7 @@ public function testThrowsExceptionOnWrongTypeOfSourceKey()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongTypeOfDestinationKey()
{
@@ -98,7 +98,7 @@ public function testReturnsNullOnEmptyList()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -101,7 +101,7 @@ public function testPushesElementsToHeadOfList()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -99,7 +99,7 @@ public function testDoesNotPushElementOnNonExistingKey()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -101,7 +101,7 @@ public function testPushesElementsToHeadOfList()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -99,7 +99,7 @@ public function testDoesNotPushElementOnNonExistingKey()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -142,7 +142,7 @@ public function testReturnsEmptyArrayOnNonExistingList()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -126,7 +126,7 @@ public function testReturnsZeroOnNonMatchingElementsOrEmptyList()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -100,7 +100,7 @@ public function testThrowsExceptionOnIndexOutOfRange()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -132,7 +132,7 @@ public function testHandlesStartAndStopOverflow()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -100,7 +100,7 @@ public function testAddsMembersToSet()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -96,7 +96,7 @@ public function testReturnsZeroOnEmptySet()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -119,7 +119,7 @@ public function testStoresDifferenceOfMultipleSets()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongTypeOfSourceKey()
{
@@ -121,7 +121,7 @@ public function testReturnsMembersFromDifferenceAmongSets()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -132,7 +132,7 @@ public function testStoresIntersectionOfMultipleSets()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongTypeOfSourceKey()
{
@@ -132,7 +132,7 @@ public function testReturnsMembersFromIntersectionAmongSets()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -100,7 +100,7 @@ public function testReturnsFalseOnNonExistingSet()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -92,7 +92,7 @@ public function testReturnsFalseOnNonExistingSet()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -93,7 +93,7 @@ public function testReturnsMemberExistenceInSet()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongTypeOfSourceKey()
{
@@ -107,7 +107,7 @@ public function testThrowsExceptionOnWrongTypeOfSourceKey()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongTypeOfDestinationKey()
{
@@ -89,7 +89,7 @@ public function testPopsRandomMemberFromSet()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
@@ -97,7 +97,7 @@ public function testReturnsNullOnNonExistingSet()
/**
* @group connected
* @expectedException Predis\ServerException
- * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
+ * @expectedExceptionMessage Operation against a key holding the wrong kind of value
*/
public function testThrowsExceptionOnWrongType()
{
Oops, something went wrong.

0 comments on commit 46920c9

Please sign in to comment.