@@ -373,6 +373,58 @@ public function testSaveAndClose()
373
373
$ this ->assertSame ($ this ->resultRedirect , $ this ->saveController ->execute ());
374
374
}
375
375
376
+ public function testSaveActionWithMarginalSpace ()
377
+ {
378
+ $ postData = [
379
+ 'title ' => 'unique_title_123 ' ,
380
+ 'identifier ' => ' unique_title_123 ' ,
381
+ 'stores ' => ['0 ' ],
382
+ 'is_active ' => true ,
383
+ 'content ' => '' ,
384
+ 'back ' => 'continue '
385
+ ];
386
+
387
+ $ this ->requestMock ->expects ($ this ->any ())->method ('getPostValue ' )->willReturn ($ postData );
388
+ $ this ->requestMock ->expects ($ this ->atLeastOnce ())
389
+ ->method ('getParam ' )
390
+ ->willReturnMap (
391
+ [
392
+ ['block_id ' , null , 1 ],
393
+ ['back ' , null , true ],
394
+ ]
395
+ );
396
+
397
+ $ this ->blockFactory ->expects ($ this ->atLeastOnce ())
398
+ ->method ('create ' )
399
+ ->willReturn ($ this ->blockMock );
400
+
401
+ $ this ->blockRepository ->expects ($ this ->once ())
402
+ ->method ('getById ' )
403
+ ->with ($ this ->blockId )
404
+ ->willReturn ($ this ->blockMock );
405
+
406
+ $ this ->blockMock ->expects ($ this ->once ())->method ('setData ' );
407
+ $ this ->blockRepository ->expects ($ this ->once ())->method ('save ' )
408
+ ->with ($ this ->blockMock )
409
+ ->willThrowException (new \Exception ('No marginal white space please. ' ));
410
+
411
+ $ this ->messageManagerMock ->expects ($ this ->never ())
412
+ ->method ('addSuccessMessage ' );
413
+ $ this ->messageManagerMock ->expects ($ this ->once ())
414
+ ->method ('addExceptionMessage ' );
415
+
416
+ $ this ->dataPersistorMock ->expects ($ this ->any ())
417
+ ->method ('set ' )
418
+ ->with ('cms_block ' , array_merge ($ postData , ['block_id ' => null ]));
419
+
420
+ $ this ->resultRedirect ->expects ($ this ->atLeastOnce ())
421
+ ->method ('setPath ' )
422
+ ->with ('*/*/edit ' , ['block_id ' => $ this ->blockId ])
423
+ ->willReturnSelf ();
424
+
425
+ $ this ->assertSame ($ this ->resultRedirect , $ this ->saveController ->execute ());
426
+ }
427
+
376
428
public function testSaveActionThrowsException ()
377
429
{
378
430
$ postData = [
0 commit comments