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
This commit is contained in:
parent
c1ca48765e
commit
d9be1b4cc4
2
phpunit
2
phpunit
@ -11,7 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Please update when phpunit needs to be reinstalled with fresh deps:
|
// Please update when phpunit needs to be reinstalled with fresh deps:
|
||||||
// Cache-Id-Version: 2016-03-23 14:50 UTC
|
// Cache-Id-Version: 2016-03-25 09:45 UTC
|
||||||
|
|
||||||
use Symfony\Component\Process\ProcessUtils;
|
use Symfony\Component\Process\ProcessUtils;
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Form\Tests\Extension\Validator;
|
namespace Symfony\Component\Form\Tests\Extension\Validator;
|
||||||
|
|
||||||
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
|
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
|
||||||
|
use Symfony\Component\Validator\ValidatorInterface;
|
||||||
|
|
||||||
class ValidatorExtensionTest extends \PHPUnit_Framework_TestCase
|
class ValidatorExtensionTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
@ -38,9 +39,11 @@ class ValidatorExtensionTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('addPropertyConstraint')
|
->method('addPropertyConstraint')
|
||||||
->with('children', $this->isInstanceOf('Symfony\Component\Validator\Constraints\Valid'));
|
->with('children', $this->isInstanceOf('Symfony\Component\Validator\Constraints\Valid'));
|
||||||
|
|
||||||
|
if ($validator instanceof ValidatorInterface) {
|
||||||
$validator
|
$validator
|
||||||
->expects($this->never())
|
->expects($this->never())
|
||||||
->method('getMetadataFactory');
|
->method('getMetadataFactory');
|
||||||
|
}
|
||||||
|
|
||||||
$extension = new ValidatorExtension($validator);
|
$extension = new ValidatorExtension($validator);
|
||||||
$guesser = $extension->loadTypeGuesser();
|
$guesser = $extension->loadTypeGuesser();
|
||||||
|
@ -55,7 +55,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue(null));
|
$this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue(null));
|
||||||
|
|
||||||
$this->event->expects($this->never())->method('setResponse');
|
$this->event->expects($this->never())->method('setResponse');
|
||||||
$this->securityContext->expects($this->never())->method('setToken');
|
$this->tokenStorage->expects($this->never())->method('setToken');
|
||||||
|
|
||||||
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
|
||||||
$listener->handle($this->event);
|
$listener->handle($this->event);
|
||||||
|
@ -66,10 +66,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testStreamRequiresStreamingEngine()
|
public function testStreamRequiresStreamingEngine()
|
||||||
{
|
{
|
||||||
$engine = $this->getEngineMock('template.php', true);
|
$delegatingEngine = new DelegatingEngine(array(new TestEngine()));
|
||||||
$engine->expects($this->never())->method('stream');
|
|
||||||
|
|
||||||
$delegatingEngine = new DelegatingEngine(array($engine));
|
|
||||||
$delegatingEngine->stream('template.php', array('foo' => 'bar'));
|
$delegatingEngine->stream('template.php', array('foo' => 'bar'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,3 +152,23 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
|
|||||||
interface MyStreamingEngine extends StreamingEngineInterface, EngineInterface
|
interface MyStreamingEngine extends StreamingEngineInterface, EngineInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TestEngine implements EngineInterface
|
||||||
|
{
|
||||||
|
public function render($name, array $parameters = array())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function exists($name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function supports($name)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stream()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user