@@ -60,7 +60,7 @@ public function testForward()
60
60
public function testGetUser ()
61
61
{
62
62
$ user = new User ('user ' , 'pass ' );
63
- $ token = new UsernamePasswordToken ($ user , 'pass ' , 'default ' , array ( 'ROLE_USER ' ) );
63
+ $ token = new UsernamePasswordToken ($ user , 'pass ' , 'default ' , [ 'ROLE_USER ' ] );
64
64
65
65
$ controller = $ this ->createController ();
66
66
$ controller ->setContainer ($ this ->getContainerWithTokenStorage ($ token ));
@@ -122,7 +122,7 @@ public function testJson()
122
122
$ controller = $ this ->createController ();
123
123
$ controller ->setContainer (new Container ());
124
124
125
- $ response = $ controller ->json (array () );
125
+ $ response = $ controller ->json ([] );
126
126
$ this ->assertInstanceOf (JsonResponse::class, $ response );
127
127
$ this ->assertEquals ('[] ' , $ response ->getContent ());
128
128
}
@@ -135,15 +135,15 @@ public function testJsonWithSerializer()
135
135
$ serializer
136
136
->expects ($ this ->once ())
137
137
->method ('serialize ' )
138
- ->with (array () , 'json ' , array ( 'json_encode_options ' => JsonResponse::DEFAULT_ENCODING_OPTIONS ) )
138
+ ->with ([] , 'json ' , [ 'json_encode_options ' => JsonResponse::DEFAULT_ENCODING_OPTIONS ] )
139
139
->will ($ this ->returnValue ('[] ' ));
140
140
141
141
$ container ->set ('serializer ' , $ serializer );
142
142
143
143
$ controller = $ this ->createController ();
144
144
$ controller ->setContainer ($ container );
145
145
146
- $ response = $ controller ->json (array () );
146
+ $ response = $ controller ->json ([] );
147
147
$ this ->assertInstanceOf (JsonResponse::class, $ response );
148
148
$ this ->assertEquals ('[] ' , $ response ->getContent ());
149
149
}
@@ -156,15 +156,15 @@ public function testJsonWithSerializerContextOverride()
156
156
$ serializer
157
157
->expects ($ this ->once ())
158
158
->method ('serialize ' )
159
- ->with (array () , 'json ' , array ( 'json_encode_options ' => 0 , 'other ' => 'context ' ) )
159
+ ->with ([] , 'json ' , [ 'json_encode_options ' => 0 , 'other ' => 'context ' ] )
160
160
->will ($ this ->returnValue ('[] ' ));
161
161
162
162
$ container ->set ('serializer ' , $ serializer );
163
163
164
164
$ controller = $ this ->createController ();
165
165
$ controller ->setContainer ($ container );
166
166
167
- $ response = $ controller ->json (array () , 200 , array (), array ( 'json_encode_options ' => 0 , 'other ' => 'context ' ) );
167
+ $ response = $ controller ->json ([] , 200 , [], [ 'json_encode_options ' => 0 , 'other ' => 'context ' ] );
168
168
$ this ->assertInstanceOf (JsonResponse::class, $ response );
169
169
$ this ->assertEquals ('[] ' , $ response ->getContent ());
170
170
$ response ->setEncodingOptions (JSON_FORCE_OBJECT );
@@ -389,7 +389,7 @@ public function testAddFlash()
389
389
$ controller ->setContainer ($ container );
390
390
$ controller ->addFlash ('foo ' , 'bar ' );
391
391
392
- $ this ->assertSame (array ( 'bar ' ) , $ flashBag ->get ('foo ' ));
392
+ $ this ->assertSame ([ 'bar ' ] , $ flashBag ->get ('foo ' ));
393
393
}
394
394
395
395
public function testCreateAccessDeniedException ()
@@ -517,117 +517,6 @@ public function testCreateFormBuilder()
517
517
$ this ->assertEquals ($ formBuilder , $ controller ->createFormBuilder ('foo ' ));
518
518
}
519
519
520
- /**
521
- * @expectedException \LogicException
522
- * @expectedExceptionMessage The form is already submitted, use $form->isValid() directly.
523
- */
524
- public function testIsFormValidWhenAlreadySubmitted ()
525
- {
526
- $ requestStack = new RequestStack ();
527
- $ requestStack ->push ($ request = new Request ());
528
-
529
- $ container = new Container ();
530
- $ container ->set ('request_stack ' , $ requestStack );
531
-
532
- $ controller = $ this ->createController ();
533
- $ controller ->setContainer ($ container );
534
-
535
- $ form = $ this ->getMockBuilder ('Symfony\Component\Form\FormInterface ' )->getMock ();
536
- $ form
537
- ->expects ($ this ->once ())
538
- ->method ('isSubmitted ' )
539
- ->willReturn (true )
540
- ;
541
-
542
- $ controller ->isFormValid ($ form );
543
- }
544
-
545
- public function testIsFormValidWhenInvalid ()
546
- {
547
- $ requestStack = new RequestStack ();
548
- $ requestStack ->push ($ request = new Request ());
549
-
550
- $ container = new Container ();
551
- $ container ->set ('request_stack ' , $ requestStack );
552
-
553
- $ controller = $ this ->createController ();
554
- $ controller ->setContainer ($ container );
555
-
556
- $ form = $ this ->getMockBuilder ('Symfony\Component\Form\FormInterface ' )->getMock ();
557
- $ form
558
- ->expects ($ this ->at (0 ))
559
- ->method ('isSubmitted ' )
560
- ->willReturn (false )
561
- ;
562
- $ form
563
- ->expects ($ this ->once ())
564
- ->method ('handleRequest ' )
565
- ->with ($ request )
566
- ->willReturn ($ form )
567
- ;
568
- $ form
569
- ->expects ($ this ->at (2 ))
570
- ->method ('isSubmitted ' )
571
- ->willReturn (false )
572
- ;
573
-
574
- $ this ->assertFalse ($ controller ->isFormValid ($ form ));
575
- }
576
-
577
- public function testIsFormValidWhenValid ()
578
- {
579
- $ requestStack = new RequestStack ();
580
- $ requestStack ->push ($ request = new Request ());
581
-
582
- $ container = new Container ();
583
- $ container ->set ('request_stack ' , $ requestStack );
584
-
585
- $ controller = $ this ->createController ();
586
- $ controller ->setContainer ($ container );
587
-
588
- $ form = $ this ->getMockBuilder ('Symfony\Component\Form\FormInterface ' )->getMock ();
589
- $ form
590
- ->expects ($ this ->at (0 ))
591
- ->method ('isSubmitted ' )
592
- ->willReturn (false )
593
- ;
594
- $ form
595
- ->expects ($ this ->once ())
596
- ->method ('handleRequest ' )
597
- ->with ($ request )
598
- ->willReturn ($ form )
599
- ;
600
- $ form
601
- ->expects ($ this ->at (2 ))
602
- ->method ('isSubmitted ' )
603
- ->willReturn (true )
604
- ;
605
- $ form
606
- ->expects ($ this ->once ())
607
- ->method ('isValid ' )
608
- ->willReturn (true )
609
- ;
610
-
611
- $ this ->assertTrue ($ controller ->isFormValid ($ form ));
612
- }
613
-
614
- /**
615
- * @expectedException \LogicException
616
- * @expectedExceptionMessage You must pass a request as second argument because the request stack is empty.
617
- */
618
- public function testIsFormValidWhenRequestStackIsEmpty ()
619
- {
620
- $ container = new Container ();
621
- $ container ->set ('request_stack ' , new RequestStack ());
622
-
623
- $ controller = $ this ->createController ();
624
- $ controller ->setContainer ($ container );
625
-
626
- $ form = $ this ->getMockBuilder ('Symfony\Component\Form\FormInterface ' )->getMock ();
627
-
628
- $ this ->assertTrue ($ controller ->isFormValid ($ form ));
629
- }
630
-
631
520
public function testGetDoctrine ()
632
521
{
633
522
$ doctrine = $ this ->getMockBuilder ('Doctrine\Common\Persistence\ManagerRegistry ' )->getMock ();
0 commit comments