@@ -170,6 +170,65 @@ public function testParseKeyWithLengthWithOptions()
170170 );
171171 }
172172
173+ public function testParseKeyWithLengthWithAllOptions ()
174+ {
175+ $ component = Key::parse (
176+ new Parser (),
177+ $ this ->getTokensList (
178+ // This is not a vary plausible example but it runs
179+ // Only ENGINE_ATTRIBUTE gives a not supported error but is still a valid syntax
180+ 'KEY `alias_type_idx` (`alias_type`(10)) '
181+ . ' COMMENT \'my comment \' VISIBLE KEY_BLOCK_SIZE=1 '
182+ . ' INVISIBLE ENGINE_ATTRIBUTE \'foo \' SECONDARY_ENGINE_ATTRIBUTE= \'bar \' USING BTREE, '
183+ )
184+ );
185+ $ this ->assertEquals ('KEY ' , $ component ->type );
186+ $ this ->assertEquals ('alias_type_idx ' , $ component ->name );
187+ $ this ->assertEquals (new OptionsArray (
188+ array (
189+ 1 => array (
190+ 'name ' => 'KEY_BLOCK_SIZE ' ,
191+ 'equals ' => true ,
192+ 'expr ' => '1 ' ,
193+ 'value ' => '1 ' ,
194+ ),
195+ 2 => array (
196+ 'name ' => 'USING ' ,
197+ 'equals ' => false ,
198+ 'expr ' => 'BTREE ' ,
199+ 'value ' => 'BTREE ' ,
200+ ),
201+ 4 => array (
202+ 'name ' => 'COMMENT ' ,
203+ 'equals ' => false ,
204+ 'expr ' => '\'my comment \'' ,
205+ 'value ' => 'my comment ' ,
206+ ),
207+ 5 => array (
208+ 'name ' => 'ENGINE_ATTRIBUTE ' ,
209+ 'equals ' => true ,
210+ 'expr ' => '\'foo \'' ,
211+ 'value ' => 'foo ' ,
212+ ),
213+ 6 => 'VISIBLE ' ,
214+ 12 => 'INVISIBLE ' ,
215+ 13 => array (
216+ 'name ' => 'SECONDARY_ENGINE_ATTRIBUTE ' ,
217+ 'equals ' => true ,
218+ 'expr ' => '\'bar \'' ,
219+ 'value ' => 'bar ' ,
220+ ),
221+ )
222+ ), $ component ->options );
223+ $ this ->assertNull ($ component ->expr );
224+ $ this ->assertSame (array (
225+ array (
226+ 'name ' => 'alias_type ' ,
227+ 'length ' => 10 ,
228+ )
229+ ), $ component ->columns );
230+ }
231+
173232 public function testParseKeyExpressionWithoutOptions ()
174233 {
175234 $ component = Key::parse (
0 commit comments