@@ -377,14 +377,46 @@ public function removeLastSemicolonWithSemicolonAfterLastRuleDisabledRemovesLast
377377 self ::assertSame ($ expected , $ result );
378378 }
379379
380+ /**
381+ * @test
382+ */
383+ public function commentsWithEmptyCommentableAndRenderCommentsDisabledDoesNotReturnSpaceBetweenBlocks (): void
384+ {
385+ $ this ->outputFormat ->setRenderComments (false );
386+ $ spaceBetweenBlocks = ' between-space ' ;
387+ $ this ->outputFormat ->setSpaceBetweenBlocks ($ spaceBetweenBlocks );
388+
389+ $ commentable = $ this ->createMock (Commentable::class);
390+ $ commentable ->method ('getComments ' )->willReturn ([]);
391+
392+ $ result = $ this ->subject ->comments ($ commentable );
393+
394+ self ::assertStringNotContainsString ($ spaceBetweenBlocks , $ result );
395+ }
396+
397+ /**
398+ * @test
399+ */
400+ public function commentsWithEmptyCommentableAndRenderCommentsDisabledDoesNotReturnSpaceAfterBlocks (): void
401+ {
402+ $ this ->outputFormat ->setRenderComments (false );
403+ $ spaceAfterBlocks = ' after-space ' ;
404+ $ this ->outputFormat ->setSpaceAfterBlocks ($ spaceAfterBlocks );
405+
406+ $ commentable = $ this ->createMock (Commentable::class);
407+ $ commentable ->method ('getComments ' )->willReturn ([]);
408+
409+ $ result = $ this ->subject ->comments ($ commentable );
410+
411+ self ::assertStringNotContainsString ($ spaceAfterBlocks , $ result );
412+ }
413+
380414 /**
381415 * @test
382416 */
383417 public function commentsWithEmptyCommentableAndRenderCommentsDisabledReturnsEmptyString (): void
384418 {
385419 $ this ->outputFormat ->setRenderComments (false );
386- $ this ->outputFormat ->setSpaceBetweenBlocks (' between-space ' );
387- $ this ->outputFormat ->setSpaceAfterBlocks (' after-space ' );
388420
389421 $ commentable = $ this ->createMock (Commentable::class);
390422 $ commentable ->method ('getComments ' )->willReturn ([]);
@@ -394,14 +426,46 @@ public function commentsWithEmptyCommentableAndRenderCommentsDisabledReturnsEmpt
394426 self ::assertSame ('' , $ result );
395427 }
396428
429+ /**
430+ * @test
431+ */
432+ public function commentsWithEmptyCommentableAndRenderCommentsEnabledDoesNotReturnSpaceBetweenBlocks (): void
433+ {
434+ $ this ->outputFormat ->setRenderComments (true );
435+ $ spaceBetweenBlocks = ' between-space ' ;
436+ $ this ->outputFormat ->setSpaceBetweenBlocks ($ spaceBetweenBlocks );
437+
438+ $ commentable = $ this ->createMock (Commentable::class);
439+ $ commentable ->method ('getComments ' )->willReturn ([]);
440+
441+ $ result = $ this ->subject ->comments ($ commentable );
442+
443+ self ::assertStringNotContainsString ($ spaceBetweenBlocks , $ result );
444+ }
445+
446+ /**
447+ * @test
448+ */
449+ public function commentsWithEmptyCommentableAndRenderCommentsEnabledDoesNotReturnSpaceAfterBlocks (): void
450+ {
451+ $ this ->outputFormat ->setRenderComments (true );
452+ $ spaceAfterBlocks = ' after-space ' ;
453+ $ this ->outputFormat ->setSpaceAfterBlocks ($ spaceAfterBlocks );
454+
455+ $ commentable = $ this ->createMock (Commentable::class);
456+ $ commentable ->method ('getComments ' )->willReturn ([]);
457+
458+ $ result = $ this ->subject ->comments ($ commentable );
459+
460+ self ::assertStringNotContainsString ($ spaceAfterBlocks , $ result );
461+ }
462+
397463 /**
398464 * @test
399465 */
400466 public function commentsWithEmptyCommentableAndRenderCommentsEnabledReturnsEmptyString (): void
401467 {
402468 $ this ->outputFormat ->setRenderComments (true );
403- $ this ->outputFormat ->setSpaceBetweenBlocks (' between-space ' );
404- $ this ->outputFormat ->setSpaceAfterBlocks (' after-space ' );
405469
406470 $ commentable = $ this ->createMock (Commentable::class);
407471 $ commentable ->method ('getComments ' )->willReturn ([]);
@@ -417,8 +481,6 @@ public function commentsWithEmptyCommentableAndRenderCommentsEnabledReturnsEmpty
417481 public function commentsWithCommentableWithOneCommentAndRenderCommentsDisabledReturnsEmptyString (): void
418482 {
419483 $ this ->outputFormat ->setRenderComments (false );
420- $ this ->outputFormat ->setSpaceBetweenBlocks (' between-space ' );
421- $ this ->outputFormat ->setSpaceAfterBlocks (' after-space ' );
422484
423485 $ commentText = 'I am a teapot. ' ;
424486 $ comment = new Comment ($ commentText );
0 commit comments