11package fr .adrienbrault .idea .symfony2plugin .tests .util .yaml ;
22
3+ import com .intellij .openapi .application .ApplicationInfo ;
34import com .intellij .psi .PsiElement ;
45import com .intellij .util .Function ;
56import com .intellij .util .containers .ContainerUtil ;
1617import org .jetbrains .yaml .psi .YAMLFile ;
1718import org .jetbrains .yaml .psi .YAMLKeyValue ;
1819import org .jetbrains .yaml .psi .YAMLScalar ;
19- import org .jetbrains .yaml .psi .impl .YAMLArrayImpl ;
2020import org .jetbrains .yaml .psi .impl .YAMLHashImpl ;
2121
22- import java .io .File ;
2322import java .util .ArrayList ;
2423import java .util .Collection ;
2524import java .util .List ;
@@ -338,16 +337,31 @@ public void testInsertKeyWithArrayValue() {
338337
339338 YamlHelper .insertKeyIntoFile (yamlFile , yamlKeyValue , "services" );
340339
341- assertEquals ("" +
342- "services:\n " +
343- " foo:\n " +
344- " car: test\n " +
345- " my_service:\n " +
346- " class: foo\n " +
347- " tag:\n " +
348- " - foo" ,
349- yamlFile .getText ()
350- );
340+ ApplicationInfo instance = ApplicationInfo .getInstance ();
341+ String minorVersion = instance .getMinorVersion ();
342+ if ((instance .getMajorVersion ().equals ("2018" ) && Integer .valueOf (minorVersion ) >= 2 )) {
343+ assertEquals ("" +
344+ "services:\n " +
345+ " foo:\n " +
346+ " car: test\n " +
347+ " my_service:\n " +
348+ " class: foo\n " +
349+ " tag:\n " +
350+ " - foo" ,
351+ yamlFile .getText ()
352+ );
353+ } else {
354+ assertEquals ("" +
355+ "services:\n " +
356+ " foo:\n " +
357+ " car: test\n " +
358+ " my_service:\n " +
359+ " class: foo\n " +
360+ " tag:\n " +
361+ " - foo" ,
362+ yamlFile .getText ()
363+ );
364+ }
351365 }
352366
353367 /**
@@ -366,14 +380,27 @@ public void testInsertKeyValueWithMissingMainKeyInRoot() {
366380
367381 YamlHelper .insertKeyIntoFile (yamlFile , yamlKeyValue , "services" );
368382
369- assertEquals ("" +
370- "foo: foo\n " +
371- "services:\n " +
372- " my_service:\n " +
373- " class: foo\n " +
374- " tag: foo" ,
375- yamlFile .getText ()
376- );
383+ ApplicationInfo instance = ApplicationInfo .getInstance ();
384+ String minorVersion = instance .getMinorVersion ();
385+ if ((instance .getMajorVersion ().equals ("2018" ) && Integer .valueOf (minorVersion ) >= 2 )) {
386+ assertEquals ("" +
387+ "foo: foo\n " +
388+ "services:\n " +
389+ " my_service:\n " +
390+ " class: foo\n " +
391+ " tag: foo" ,
392+ yamlFile .getText ()
393+ );
394+ }else {
395+ assertEquals ("" +
396+ "foo: foo\n " +
397+ "services:\n " +
398+ " my_service:\n " +
399+ " class: foo\n " +
400+ " tag: foo" ,
401+ yamlFile .getText ()
402+ );
403+ }
377404 }
378405
379406 /**
0 commit comments