10000 fix mocks · symfony/symfony@d9be1b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit d9be1b4

Browse files
committed
fix mocks
* check for existance of `setMetadataFactory()` method (this is needed for tests run with deps=high as the method was removed in Symfony 3.0) * fix mock testing the `EngineInterface` as the `stream()` method cannot be mocked when it is does not exist in the mocked interface
1 parent c1ca487 commit d9be1b4

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

phpunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
// Please update when phpunit needs to be reinstalled with fresh deps:
14-
// Cache-Id-Version: 2016-03-23 14:50 UTC
14+
// Cache-Id-Version: 2016-03-25 09:45 UTC
1515

1616
use Symfony\Component\Process\ProcessUtils;
1717

src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Validator;
1313

1414
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
15+
use Symfony\Component\Validator\ValidatorInterface;
1516

1617
class ValidatorExtensionTest extends \PHPUnit_Framework_TestCase
1718
{
@@ -38,9 +39,11 @@ public function test2Dot5ValidationApi()
3839
->method('addPropertyConstraint')
3940
->with('children', $this->isInstanceOf('Symfony\Component\Validator\Constraints\Valid'));
4041

41-
$validator
42-
->expects($this->never())
43-
->method('getMetadataFactory');
42+
if ($validator instanceof ValidatorInterface) {
43+
$validator
44+
->expects($this->never())
45+
->method('getMetadataFactory');
46+
}
4447

4548
$extension = new ValidatorExtension($validator);
4649
$guesser = $extension->loadTypeGuesser();

src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testEventIsIgnoredIfUsernameIsNotPassedWithTheRequest()
5555
$this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnV 10000 alue(null));
5656

5757
$this->event->expects($this->never())->method('setResponse');
58-
$this->securityContext->expects($this->never())->method('setToken');
58+
$this->tokenStorage->expects($this->never())->method('setToken');
5959

6060
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
6161
$listener->handle($this->event);

src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ public function testStreamDelegatesToSupportedEngine()
6666
*/
6767
public function testStreamRequiresStreamingEngine()
6868
{
69-
$engine = $this->getEngineMock('template.php', true);
70-
$engine->expects($this->never())->method('stream');
71-
72-
$delegatingEngine = new DelegatingEngine(array($engine));
69+
$delegatingEngine = new DelegatingEngine(array(new TestEngine()));
7370
$delegatingEngine->stream('template.php', array('foo' => 'bar'));
7471
}
7572

@@ -155,3 +152,23 @@ private function getStreamingEngineMock($template, $supports)
155152
interface MyStreamingEngine extends StreamingEngineInterface, EngineInterface
156153
{
157154
}
155+
156+
class TestEngine implements EngineInterface
157+
{
158+
public function render($name, array $parameters = array())
159+
{
160+
}
161+
162+
public function exists($name)
163+
{
164+
}
165+
166+
public function supports($name)
167+
{
168+
return true;
169+
}
170+
171+
public function stream()
172+
{
173+
}
174+
}

0 commit comments

Comments
 (0)
0