File tree Expand file tree Collapse file tree 6 files changed +113
-0
lines changed Expand file tree Collapse file tree 6 files changed +113
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <[email protected] >
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Bundle \FrameworkBundle \Tests \Functional \Bundle \TestBundle \Controller ;
13
+
14
+ use Symfony \Component \HttpFoundation \Request ;
15
+ use Symfony \Component \HttpFoundation \Response ;
16
+ use Symfony \Component \DependencyInjection \ContainerAware ;
17
+
18
+ class FragmentController extends ContainerAware
19
+ {
20
+ public function indexAction ()
21
+ {
22
+ $ actions = $ this ->container ->get ('templating ' )->get ('actions ' );
23
+
24
+ return new Response ($ actions ->render ($ actions ->controller ('TestBundle:Fragment:inlined ' , array (
25
+ 'options ' => array (
26
+ 'bar ' => new Bar (),
27
+ 'eleven ' => 11 ,
28
+ ),
29
+ ))));
30
+ }
31
+
32
+ public function inlinedAction ($ options , $ _format )
33
+ {
34
+ return new Response ($ options ['bar ' ]->getBar ().' ' .$ _format );
35
+ }
36
+ }
37
+
38
+ class Bar
39
+ {
40
+ private $ bar = 'bar ' ;
41
+
42
+ public function getBar ()
43
+ {
44
+ return $ this ->bar ;
45
+ }
46
+ }
Original file line number Diff line number Diff line change @@ -21,3 +21,11 @@ session_showflash:
21
21
profiler :
22
22
path : /profiler
23
23
defaults : { _controller: TestBundle:Profiler:index }
24
+
25
+ fragment_home :
26
+ path : /fragment_home
27
+ defaults : { _controller: TestBundle:Fragment:index, _format: txt }
28
+
29
+ fragment_inlined :
30
+ path : /fragment_inlined
31
+ defaults : { _controller: TestBundle:Fragment:inlined }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <[email protected] >
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Bundle \FrameworkBundle \Tests \Functional ;
13
+
14
+ /**
15
+ * @group functional
16
+ */
17
+ class FragmentTest extends WebTestCase
18
+ {
19
+ /**
20
+ * @dataProvider getConfigs
21
+ */
22
+ public function testFragment ($ insulate )
23
+ {
24
+ $ client = $ this ->createClient (array ('test_case ' => 'Fragment ' , 'root_config ' => 'config.yml ' ));
25
+ if ($ insulate ) {
26
+ $ client ->insulate ();
27
+ }
28
+
29
+ $ client ->request ('GET ' , '/fragment_home ' );
30
+
31
+ $ this ->assertEquals ('bar txt ' , $ client ->getResponse ()->getContent ());
32
+ }
33
+
34
+ public function getConfigs ()
35
+ {
36
+ return array (
37
+ array (false ),
38
+ array (true ),
39
+ );
40
+ }
41
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Symfony \Bundle \FrameworkBundle \Tests \Functional \Bundle \TestBundle \TestBundle ;
4
+ use Symfony \Bundle \FrameworkBundle \FrameworkBundle ;
5
+
6
+ return array (
7
+ new FrameworkBundle (),
8
+ new TestBundle (),
9
+ );
Original file line number Diff line number Diff line change
1
+ imports :
2
+ - { resource: ../config/default.yml }
3
+
4
+ framework :
5
+ fragments : ~
6
+ templating :
7
+ engines : ['php']
Original file line number Diff line number Diff line change
1
+ _fragmenttest_bundle :
2
+ resource : @TestBundle/Resources/config/routing.yml
You can’t perform that action at this time.
0 commit comments