minor #18321 [2.8] fix mocks (xabbuh)

This PR was squashed before being merged into the 2.8 branch (closes #18321).

Discussion
----------

[2.8] fix mocks

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

7dff706 [2.8] fix mocks
This commit is contained in:
Nicolas Grekas 2016-03-27 11:27:51 +02:00
commit 6376ea2296
5 changed files with 41 additions and 10 deletions

View File

@ -11,7 +11,7 @@
*/
// 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;

View File

@ -19,6 +19,13 @@ use Symfony\Bundle\TwigBundle\Tests\TestCase;
*/
class LegacyAssetsExtensionTest extends TestCase
{
protected function setUp()
{
if (!class_exists('Symfony\Component\Templating\Helper\CoreAssetsHelper')) {
$this->markTestSkipped('The CoreAssetsHelper class does only exist with symfony/templating < 3.0 installed.');
}
}
/**
* @dataProvider provideGetAssetUrlArguments
*/

View File

@ -21,6 +21,7 @@ use Symfony\Component\Form\SubmitButtonBuilder;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\ExecutionContextInterface;
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
use Symfony\Component\Validator\Validation;
@ -629,8 +630,11 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
$context->expects($this->never())
->method('addViolation');
$context->expects($this->never())
->method('addViolationAt');
if ($context instanceof ExecutionContextInterface) {
$context->expects($this->never())
->method('addViolationAt');
}
$this->validator->initialize($context);
$this->validator->validate($form, new Form());

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Validator;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Validator\ValidatorInterface;
class ValidatorExtensionTest extends \PHPUnit_Framework_TestCase
{
@ -38,9 +39,11 @@ class ValidatorExtensionTest extends \PHPUnit_Framework_TestCase
->method('addPropertyConstraint')
->with('children', $this->isInstanceOf('Symfony\Component\Validator\Constraints\Valid'));
$validator
->expects($this->never())
->method('getMetadataFactory');
if ($validator instanceof ValidatorInterface) {
$validator
->expects($this->never())
->method('getMetadataFactory');
}
$extension = new ValidatorExtension($validator);
$guesser = $extension->loadTypeGuesser();

View File

@ -66,10 +66,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
*/
public function testStreamRequiresStreamingEngine()
{
$engine = $this->getEngineMock('template.php', true);
$engine->expects($this->never())->method('stream');
$delegatingEngine = new DelegatingEngine(array($engine));
$delegatingEngine = new DelegatingEngine(array(new TestEngine()));
$delegatingEngine->stream('template.php', array('foo' => 'bar'));
}
@ -155,3 +152,23 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
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()
{
}
}