Skip to content

Commit

Permalink
Merge branch '4.4'
Browse files Browse the repository at this point in the history
* 4.4:
  cs fix
  Replace calls to setExpectedException by Pollyfill
  • Loading branch information
nicolas-grekas committed Aug 1, 2019
2 parents 719bc73 + 11d5653 commit 9c42162
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Tests/ConstraintTest.php
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Validator\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Tests\Fixtures\ClassConstraint;
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
Expand All @@ -22,6 +23,8 @@

class ConstraintTest extends TestCase
{
use ForwardCompatTestTrait;

public function testSetProperties()
{
$constraint = new ConstraintA([
Expand Down
11 changes: 5 additions & 6 deletions Tests/Constraints/AbstractComparisonValidatorTestCase.php
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Validator\Tests\Constraints;

use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Intl\Util\IntlTestHelper;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
Expand Down Expand Up @@ -41,6 +42,8 @@ public function getValue()
*/
abstract class AbstractComparisonValidatorTestCase extends ConstraintValidatorTestCase
{
use ForwardCompatTestTrait;

protected static function addPhp5Dot5Comparisons(array $comparisons)
{
$result = $comparisons;
Expand Down Expand Up @@ -163,12 +166,8 @@ public function testInvalidValuePath()
{
$constraint = $this->createConstraint(['propertyPath' => 'foo']);

if (method_exists($this, 'expectException')) {
$this->expectException(ConstraintDefinitionException::class);
$this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));
} else {
$this->setExpectedException(ConstraintDefinitionException::class, sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));
}
$this->expectException(ConstraintDefinitionException::class);
$this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));

$object = new ComparisonTest_Class(5);

Expand Down
8 changes: 2 additions & 6 deletions Tests/Constraints/BicValidatorTest.php
Expand Up @@ -119,12 +119,8 @@ public function testInvalidValuePath()
{
$constraint = new Bic(['ibanPropertyPath' => 'foo']);

if (method_exists($this, 'expectException')) {
$this->expectException(ConstraintDefinitionException::class);
$this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));
} else {
$this->setExpectedException(ConstraintDefinitionException::class, sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));
}
$this->expectException(ConstraintDefinitionException::class);
$this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));

$object = new BicComparisonTestClass(5);

Expand Down
3 changes: 3 additions & 0 deletions Tests/Mapping/GetterMetadataTest.php
Expand Up @@ -12,11 +12,14 @@
namespace Symfony\Component\Validator\Tests\Mapping;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Mapping\GetterMetadata;
use Symfony\Component\Validator\Tests\Fixtures\Entity;

class GetterMetadataTest extends TestCase
{
use ForwardCompatTestTrait;

const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';

public function testInvalidPropertyName()
Expand Down
3 changes: 3 additions & 0 deletions Tests/Mapping/Loader/XmlFileLoaderTest.php
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Validator\Tests\Mapping\Loader;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\All;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Constraints\Choice;
Expand All @@ -29,6 +30,8 @@

class XmlFileLoaderTest extends TestCase
{
use ForwardCompatTestTrait;

public function testLoadClassMetadataReturnsTrueIfSuccessful()
{
$loader = new XmlFileLoader(__DIR__.'/constraint-mapping.xml');
Expand Down
3 changes: 3 additions & 0 deletions Tests/Mapping/Loader/YamlFileLoaderTest.php
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Validator\Tests\Mapping\Loader;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\All;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Constraints\Choice;
Expand All @@ -26,6 +27,8 @@

class YamlFileLoaderTest extends TestCase
{
use ForwardCompatTestTrait;

public function testLoadClassMetadataReturnsFalseIfEmpty()
{
$loader = new YamlFileLoader(__DIR__.'/empty-mapping.yml');
Expand Down
3 changes: 3 additions & 0 deletions Tests/Mapping/PropertyMetadataTest.php
Expand Up @@ -12,11 +12,14 @@
namespace Symfony\Component\Validator\Tests\Mapping;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Mapping\PropertyMetadata;
use Symfony\Component\Validator\Tests\Fixtures\Entity;

class PropertyMetadataTest extends TestCase
{
use ForwardCompatTestTrait;

const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';

Expand Down

0 comments on commit 9c42162

Please sign in to comment.