Fix tests

This commit is contained in:
Jérémy Derussé 2019-08-02 01:19:44 +02:00
parent 3a626e8778
commit a22a9c453f
No known key found for this signature in database
GPG Key ID: 2083FA5758C473D2
11 changed files with 13 additions and 22 deletions

View File

@ -15,7 +15,7 @@ class RegisterMappingsPassTest extends TestCase
public function testNoDriverParmeterException() public function testNoDriverParmeterException()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException('InvalidArgumentException');
$this->getExpectedExceptionMessage('Could not find the manager name parameter in the container. Tried the following parameter names: "manager.param.one", "manager.param.two"'); $this->expectExceptionMessage('Could not find the manager name parameter in the container. Tried the following parameter names: "manager.param.one", "manager.param.two"');
$container = $this->createBuilder(); $container = $this->createBuilder();
$this->process($container, [ $this->process($container, [
'manager.param.one', 'manager.param.one',

View File

@ -68,7 +68,7 @@ class ResolveBindingsPassTest extends TestCase
public function testMissingParent() public function testMissingParent()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
$this->expectExceptionMessageRegExp('Unused binding "$quz" in service [\s\S]+ Invalid service ".*\\ParentNotExists": class NotExists not found\.'); $this->expectExceptionMessageRegExp('/Unused binding "\$quz" in service [\s\S]+/');
if (\PHP_VERSION_ID >= 70400) { if (\PHP_VERSION_ID >= 70400) {
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.'); throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
} }

View File

@ -311,7 +311,7 @@ class YamlFileLoaderTest extends TestCase
public function testTagWithNonStringNameThrowsException() public function testTagWithNonStringNameThrowsException()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
$this->expectExceptionMessageRegExp('The tag name for service "\.+" must be a non-empty string'); $this->expectExceptionMessageRegExp('/The tag name for service ".+" in .+ must be a non-empty string/');
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('tag_name_no_string.yml'); $loader->load('tag_name_no_string.yml');
} }

View File

@ -20,8 +20,6 @@ use Symfony\Component\PropertyAccess\PropertyPath;
class FormTest_AuthorWithoutRefSetter class FormTest_AuthorWithoutRefSetter
{ {
use ForwardCompatTestTrait;
protected $reference; protected $reference;
protected $referenceCopy; protected $referenceCopy;
@ -54,6 +52,8 @@ class FormTest_AuthorWithoutRefSetter
class FormTypeTest extends BaseTypeTest class FormTypeTest extends BaseTypeTest
{ {
use ForwardCompatTestTrait;
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\FormType'; const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\FormType';
public function testCreateFormInstances() public function testCreateFormInstances()

View File

@ -12,19 +12,16 @@
namespace Symfony\Component\Form\Tests\Resources; namespace Symfony\Component\Form\Tests\Resources;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
class TranslationFilesTest extends TestCase class TranslationFilesTest extends TestCase
{ {
use ForwardCompatTestTrait;
/** /**
* @dataProvider provideTranslationFiles * @dataProvider provideTranslationFiles
*/ */
public function testTranslationFileIsValid($filePath) public function testTranslationFileIsValid($filePath)
{ {
if (class_exists('PHPUnit_Util_XML')) { if (class_exists('PHPUnit_Util_XML')) {
\PHPUnit\Util\XML::loadfile($filePath, false, false, true); \PHPUnit_Util_XML::loadfile($filePath, false, false, true);
} else { } else {
\PHPUnit\Util\XML::loadfile($filePath, false, false, true); \PHPUnit\Util\XML::loadfile($filePath, false, false, true);
} }

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Lock\Tests\Store; namespace Symfony\Component\Lock\Tests\Store;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Lock\Store\RedisStore; use Symfony\Component\Lock\Store\RedisStore;
/** /**
@ -18,6 +19,7 @@ use Symfony\Component\Lock\Store\RedisStore;
*/ */
abstract class AbstractRedisStoreTest extends AbstractStoreTest abstract class AbstractRedisStoreTest extends AbstractStoreTest
{ {
use ForwardCompatTestTrait;
use ExpiringStoreTestTrait; use ExpiringStoreTestTrait;
/** /**

View File

@ -21,8 +21,6 @@ use Symfony\Component\Lock\StoreInterface;
*/ */
trait ExpiringStoreTestTrait trait ExpiringStoreTestTrait
{ {
use ForwardCompatTestTrait;
/** /**
* Amount of microseconds used as a delay to test expiration. Should be * Amount of microseconds used as a delay to test expiration. Should be
* small enough not to slow the test suite too much, and high enough not to * small enough not to slow the test suite too much, and high enough not to

View File

@ -191,8 +191,8 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
public function testSetValueFailsIfAdderAndRemoverExistButValueIsNotTraversable() public function testSetValueFailsIfAdderAndRemoverExistButValueIsNotTraversable()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
expectedExceptionMessageRegExp /The property "axes" in class "Mock_PropertyAccessorCollectionTest_Car[^"]*" can be defined with the methods "addAxis()", "removeAxis()" but the new value must be an array or an instance of \Traversable, "string" given./'); $this->expectExceptionMessage('Could not determine access type for property "axes" in class "Symfony\Component\PropertyAccess\Tests\PropertyAccessorCollectionTest_Car".');
$car = new PropertyAccessorCollectionTest_Car(); $car = new PropertyAccessorCollectionTest_Car();
$this->propertyAccessor->setValue($car, 'axes', 'Not an array or Traversable'); $this->propertyAccessor->setValue($car, 'axes', 'Not an array or Traversable');

View File

@ -339,7 +339,7 @@ class UrlMatcherTest extends TestCase
public function testSchemeRequirement() public function testSchemeRequirement()
{ {
$this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); $this->getExpectedException() ?: $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$coll = new RouteCollection(); $coll = new RouteCollection();
$coll->add('foo', new Route('/foo', [], [], [], '', ['https'])); $coll->add('foo', new Route('/foo', [], [], [], '', ['https']));
$matcher = $this->getUrlMatcher($coll); $matcher = $this->getUrlMatcher($coll);

View File

@ -12,19 +12,16 @@
namespace Symfony\Component\Security\Core\Tests\Resources; namespace Symfony\Component\Security\Core\Tests\Resources;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
class TranslationFilesTest extends TestCase class TranslationFilesTest extends TestCase
{ {
use ForwardCompatTestTrait;
/** /**
* @dataProvider provideTranslationFiles * @dataProvider provideTranslationFiles
*/ */
public function testTranslationFileIsValid($filePath) public function testTranslationFileIsValid($filePath)
{ {
if (class_exists('PHPUnit_Util_XML')) { if (class_exists('PHPUnit_Util_XML')) {
\PHPUnit\Util\XML::loadfile($filePath, false, false, true); \PHPUnit_Util_XML::loadfile($filePath, false, false, true);
} else { } else {
\PHPUnit\Util\XML::loadfile($filePath, false, false, true); \PHPUnit\Util\XML::loadfile($filePath, false, false, true);
} }

View File

@ -12,19 +12,16 @@
namespace Symfony\Component\Validator\Tests\Resources; namespace Symfony\Component\Validator\Tests\Resources;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
class TranslationFilesTest extends TestCase class TranslationFilesTest extends TestCase
{ {
use ForwardCompatTestTrait;
/** /**
* @dataProvider provideTranslationFiles * @dataProvider provideTranslationFiles
*/ */
public function testTranslationFileIsValid($filePath) public function testTranslationFileIsValid($filePath)
{ {
if (class_exists('PHPUnit_Util_XML')) { if (class_exists('PHPUnit_Util_XML')) {
\PHPUnit\Util\XML::loadfile($filePath, false, false, true); \PHPUnit_Util_XML::loadfile($filePath, false, false, true);
} else { } else {
\PHPUnit\Util\XML::loadfile($filePath, false, false, true); \PHPUnit\Util\XML::loadfile($filePath, false, false, true);
} }