@@ -61,7 +61,11 @@ public function testCastMemcachedWithCustomOptions()
61
61
$ var = new \Memcached ();
62
62
$ var ->addServer ('127.0.0.1 ' , 11211 );
63
63
$ var ->addServer ('127.0.0.2 ' , 11212 );
64
- $ var ->setOptions ($ this ->getCustomOptions ());
64
+
65
+ // set a subset of non default options to test boolean, string and integer output
66
+ $ var ->setOption (\Memcached::OPT_COMPRESSION , false );
67
+ $ var ->setOption (\Memcached::OPT_PREFIX_KEY , 'pre ' );
68
+ $ var ->setOption (\Memcached::OPT_DISTRIBUTION , \Memcached::DISTRIBUTION_CONSISTENT );
65
69
66
70
$ expected = <<<'EOTXT'
67
71
Memcached {
@@ -78,75 +82,13 @@ public function testCastMemcachedWithCustomOptions()
78
82
]
79
83
]
80
84
options: {
81
- OPT_COMPRESSION: %s
82
- OPT_PREFIX_KEY: "%s"
83
- OPT_USER_FLAGS: %i
84
- OPT_STORE_RETRY_COUNT: %i
85
- OPT_HASH: %i
86
- OPT_DISTRIBUTION: %i
87
- OPT_LIBKETAMA_COMPATIBLE: %i
88
- OPT_LIBKETAMA_HASH: %i
89
- OPT_TCP_KEEPALIVE: %i
90
- OPT_BINARY_PROTOCOL: %i
91
- OPT_NO_BLOCK: %i
92
- OPT_TCP_NODELAY: %i
93
- OPT_SOCKET_SEND_SIZE: %i
94
- OPT_SOCKET_RECV_SIZE: %i
95
- OPT_CONNECT_TIMEOUT: %i
96
- OPT_RETRY_TIMEOUT: %i
97
- OPT_DEAD_TIMEOUT: %i
98
- OPT_SEND_TIMEOUT: %i
99
- OPT_RECV_TIMEOUT: %i
100
- OPT_POLL_TIMEOUT: %i
101
- OPT_SERVER_FAILURE_LIMIT: %i
102
- OPT_AUTO_EJECT_HOSTS: %i
103
- OPT_HASH_WITH_PREFIX_KEY: %i
104
- OPT_NOREPLY: %i
105
- OPT_SORT_HOSTS: %i
106
- OPT_USE_UDP: %i
107
- OPT_NUMBER_OF_REPLICAS: %i
108
- OPT_RANDOMIZE_REPLICA_READ: %i
109
- OPT_REMOVE_FAILED_SERVERS: %i
110
- OPT_SERVER_TIMEOUT_LIMIT: %i
85
+ OPT_COMPRESSION: false
86
+ OPT_PREFIX_KEY: "pre"
87
+ OPT_DISTRIBUTION: 1
111
88
}
112
89
}
113
90
EOTXT;
114
91
115
- $ this ->assertDumpMatchesFormat ($ expected , $ var );
116
- }
117
-
118
- private function getCustomOptions ()
119
- {
120
- $ optionsToIgnore = array (
121
- \Memcached::OPT_SERIALIZER , // trying to set this option to something else then default throws Memcached::setOptions(): invalid serializer provided
122
- \Memcached::OPT_CACHE_LOOKUPS , // option is deprecated
123
- \Memcached::OPT_VERIFY_KEY , // trying to set this option throws Memcached::setOption(): error setting memcached option: INVALID ARGUMENTS
124
- );
125
-
126
- $ optionConstants = MemcachedCaster::getMemcachedOptionConstants ();
127
- $ defaultOptions = MemcachedCaster::discoverDefaultMemcachedOptions ();
128
- $ customOptions = array ();
129
-
130
- foreach ($ optionConstants as $ optionConstantKey => $ optionConstantValue ) {
131
- if (\in_array ($ optionConstantValue , $ optionsToIgnore , true )) {
132
- continue ;
133
- }
134
-
135
- $ defaultOptionValue = $ defaultOptions [$ optionConstantKey ];
136
-
137
- if (\is_bool ($ defaultOptionValue )) {
138
- $ customOptions [$ optionConstants [$ optionConstantKey ]] = !$ defaultOptionValue ;
139
- }
140
-
141
- if (\is_string ($ defaultOptionValue )) {
142
- $ customOptions [$ optionConstants [$ optionConstantKey ]] = 'custom ' ;
143
- }
144
-
145
- if (\is_int ($ defaultOptionValue )) {
146
- $ customOptions [$ optionConstants [$ optionConstantKey ]] = $ defaultOptionValue + 1 ;
147
- }
148
- }
149
-
150
- return $ customOptions ;
92
+ $ this ->assertDumpEquals ($ expected , $ var );
151
93
}
152
94
}
0 commit comments