@@ -420,6 +420,60 @@ public function testAnnotateWithFollowingInline() {
420420 $ this ->assertTextContains (' -> 1 annotation added. ' , $ output );
421421 }
422422
423+ /**
424+ * Tests that a docblock with arrays in different types, e.g. shape.
425+ *
426+ * @return void
427+ */
428+ public function testAnnotateWithShapedArray () {
429+ $ annotator = $ this ->_getAnnotatorMock ([]);
430+
431+ $ expectedContent = str_replace ("\r\n" , "\n" , file_get_contents (TEST_FILES . 'templates/array.php ' ));
432+ $ callback = function ($ value ) use ($ expectedContent ) {
433+ $ value = str_replace (["\r\n" , "\r" ], "\n" , $ value );
434+ if ($ value !== $ expectedContent ) {
435+ $ this ->_displayDiff ($ expectedContent , $ value );
436+ }
437+
438+ return $ value === $ expectedContent ;
439+ };
440+ $ annotator ->expects ($ this ->once ())->method ('storeFile ' )->with ($ this ->anything (), $ this ->callback ($ callback ));
441+
442+ $ path = TEST_ROOT . 'templates/Foos/array.php ' ;
443+ $ annotator ->annotate ($ path );
444+
445+ $ output = $ this ->out ->output ();
446+
447+ $ this ->assertTextContains (' -> 1 annotation added. ' , $ output );
448+ }
449+
450+ /**
451+ * Tests that a multiline array is parsed completly.
452+ *
453+ * @return void
454+ */
455+ public function testAnnotateWithMultilineArray () {
456+ $ annotator = $ this ->_getAnnotatorMock ([]);
457+
458+ $ expectedContent = str_replace ("\r\n" , "\n" , file_get_contents (TEST_FILES . 'templates/multiline.php ' ));
459+ $ callback = function ($ value ) use ($ expectedContent ) {
460+ $ value = str_replace (["\r\n" , "\r" ], "\n" , $ value );
461+ if ($ value !== $ expectedContent ) {
462+ $ this ->_displayDiff ($ expectedContent , $ value );
463+ }
464+
465+ return $ value === $ expectedContent ;
466+ };
467+ $ annotator ->expects ($ this ->once ())->method ('storeFile ' )->with ($ this ->anything (), $ this ->callback ($ callback ));
468+
469+ $ path = TEST_ROOT . 'templates/Foos/multiline.php ' ;
470+ $ annotator ->annotate ($ path );
471+
472+ $ output = $ this ->out ->output ();
473+
474+ $ this ->assertTextContains (' -> 1 annotation added. ' , $ output );
475+ }
476+
423477 /**
424478 * @param array $params
425479 * @return \IdeHelper\Annotator\TemplateAnnotator|\PHPUnit\Framework\MockObject\MockObject
0 commit comments