@@ -75,15 +75,13 @@ Feature: Describing a controller
75
75
76
76
"""
77
77
78
- @wip
79
78
Scenario : Executing a controller spec with response inspection
80
- Given I wrote a spec in the "spec/Acme/Bundle/DemoBundle/Controller/UserController " :
79
+ Given I wrote a spec in the "spec/Acme/Bundle/DemoBundle/Controller/UserControllerSpec.php " :
81
80
"""
82
81
<?php
83
82
84
83
namespace spec\Acme\Bundle\DemoBundle\Controller;
85
84
86
- use Doctrine\ORM\EntityRepository;
87
85
use PhpSpec\Symfony2Extension\Specification\ControllerBehavior;
88
86
use Prophecy\Argument;
89
87
@@ -105,6 +103,7 @@ Feature: Describing a controller
105
103
namespace Acme\Bundle\DemoBundle\Controller;
106
104
107
105
use Symfony\Component\DependencyInjection\ContainerAware;
106
+ use Symfony\Component\HttpFoundation\Response;
108
107
109
108
class UserController extends ContainerAware
110
109
{
@@ -116,7 +115,7 @@ Feature: Describing a controller
116
115
117
116
"""
118
117
When I run phpspec
119
- Then I should see "1 example (1 passed)"
118
+ Then I should see "2 examples (2 passed)"
120
119
121
120
@wip
122
121
Scenario : Executing a controller spec with service expectations
@@ -126,26 +125,22 @@ Feature: Describing a controller
126
125
127
126
namespace spec\Acme\Bundle\DemoBundle\Controller;
128
127
129
- use Doctrine\Bundle\DoctrineBundle\Registry;
130
- use Doctrine\ORM\EntityRepository;
131
128
use PhpSpec\Symfony2Extension\Specification\ControllerBehavior;
132
129
use Prophecy\Argument;
133
130
use Symfony\Component\Templating\EngineInterface;
131
+ use Symfony\Component\DependencyInjection\ContainerInterface;
134
132
135
133
class UserControllerSpec extends ControllerBehavior
136
134
{
137
- function let(Registry $doctrine, EntityRepository $repository , EngineInterface $templating)
135
+ function let(ContainerInterface $container , EngineInterface $templating)
138
136
{
139
- $doctrine->getManager()->willReturn($repository);
140
- $this->container->get('doctrine')->willReturn($doctrine);
137
+ $this->setContainer($container);
141
138
$this->container->get('templating')->willReturn($templating);
142
139
}
143
140
144
- function it_should_render_list_of_users(EntityRepository $repository )
141
+ function it_should_render_list_of_users()
145
142
{
146
- $repository->findAll()->willReturn(array('user1', 'user2'));
147
-
148
- $this->shouldRender('AcmeUserBundle:User:list.html.twig', array('users' => array('user1', 'user2')))
143
+ $this->shouldRender('AcmeUserBundle:User:list.html.twig', array('users' => array()))
149
144
->duringAction('list');
150
145
}
151
146
}
@@ -163,14 +158,12 @@ Feature: Describing a controller
163
158
{
164
159
public function listAction()
165
160
{
166
- $repository = $this->get('doctrine')->getManager();
167
-
168
161
return $this->container->get('templating')->renderResponse(
169
- 'AcmeUserBundle:User:list.html.twig', array('users' => $repository->findAll ())
162
+ 'AcmeUserBundle:User:list.html.twig', array('users' => array ())
170
163
);
171
164
}
172
165
}
173
166
174
167
"""
175
168
When I run phpspec
176
- Then I should see "1 example (1 passed)"
169
+ Then I should see "2 examples (2 passed)"
0 commit comments