Skip to content
This repository was archived by the owner on Feb 14, 2021. It is now read-only.

Commit 5056ee7

Browse files
committed
Fixed another example.
1 parent a40c623 commit 5056ee7

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

features/bootstrap/PhpSpecContext.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ public function iWroteSpecInThe($file, PyStringNode $string)
8484
mkdir(dirname($file), 0777, true);
8585

8686
file_put_contents($file, $string->getRaw());
87+
88+
require_once($file);
8789
}
8890

8991
/**

features/describing_a_controller.feature

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,13 @@ Feature: Describing a controller
7575
7676
"""
7777

78-
@wip
7978
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":
8180
"""
8281
<?php
8382
8483
namespace spec\Acme\Bundle\DemoBundle\Controller;
8584
86-
use Doctrine\ORM\EntityRepository;
8785
use PhpSpec\Symfony2Extension\Specification\ControllerBehavior;
8886
use Prophecy\Argument;
8987
@@ -105,6 +103,7 @@ Feature: Describing a controller
105103
namespace Acme\Bundle\DemoBundle\Controller;
106104
107105
use Symfony\Component\DependencyInjection\ContainerAware;
106+
use Symfony\Component\HttpFoundation\Response;
108107
109108
class UserController extends ContainerAware
110109
{
@@ -116,7 +115,7 @@ Feature: Describing a controller
116115
117116
"""
118117
When I run phpspec
119-
Then I should see "1 example (1 passed)"
118+
Then I should see "2 examples (2 passed)"
120119

121120
@wip
122121
Scenario: Executing a controller spec with service expectations
@@ -126,26 +125,22 @@ Feature: Describing a controller
126125
127126
namespace spec\Acme\Bundle\DemoBundle\Controller;
128127
129-
use Doctrine\Bundle\DoctrineBundle\Registry;
130-
use Doctrine\ORM\EntityRepository;
131128
use PhpSpec\Symfony2Extension\Specification\ControllerBehavior;
132129
use Prophecy\Argument;
133130
use Symfony\Component\Templating\EngineInterface;
131+
use Symfony\Component\DependencyInjection\ContainerInterface;
134132
135133
class UserControllerSpec extends ControllerBehavior
136134
{
137-
function let(Registry $doctrine, EntityRepository $repository, EngineInterface $templating)
135+
function let(ContainerInterface $container, EngineInterface $templating)
138136
{
139-
$doctrine->getManager()->willReturn($repository);
140-
$this->container->get('doctrine')->willReturn($doctrine);
137+
$this->setContainer($container);
141138
$this->container->get('templating')->willReturn($templating);
142139
}
143140
144-
function it_should_render_list_of_users(EntityRepository $repository)
141+
function it_should_render_list_of_users()
145142
{
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()))
149144
->duringAction('list');
150145
}
151146
}
@@ -163,14 +158,12 @@ Feature: Describing a controller
163158
{
164159
public function listAction()
165160
{
166-
$repository = $this->get('doctrine')->getManager();
167-
168161
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())
170163
);
171164
}
172165
}
173166
174167
"""
175168
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

Comments
 (0)