Merge branch '5.2' into 5.x
* 5.2: Use createMock() and use import instead of FQCN
This commit is contained in:
commit
e7966c099b
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Tests\DataCollector;
|
||||
|
||||
use Doctrine\DBAL\Logging\DebugStack;
|
||||
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
||||
use Doctrine\DBAL\Version;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
@ -236,7 +237,7 @@ EOTXT
|
||||
->method('getDatabasePlatform')
|
||||
->willReturn(new MySqlPlatform());
|
||||
|
||||
$registry = $this->getMockBuilder(ManagerRegistry::class)->getMock();
|
||||
$registry = $this->createMock(ManagerRegistry::class);
|
||||
$registry
|
||||
->expects($this->any())
|
||||
->method('getConnectionNames')
|
||||
@ -249,7 +250,7 @@ EOTXT
|
||||
->method('getConnection')
|
||||
->willReturn($connection);
|
||||
|
||||
$logger = $this->getMockBuilder(\Doctrine\DBAL\Logging\DebugStack::class)->getMock();
|
||||
$logger = $this->createMock(DebugStack::class);
|
||||
$logger->queries = $queries;
|
||||
|
||||
$collector = new DoctrineDataCollector($registry);
|
||||
|
@ -14,12 +14,13 @@ namespace Symfony\Bridge\Doctrine\Tests\DataFixtures;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\ContainerAwareFixture;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
class ContainerAwareLoaderTest extends TestCase
|
||||
{
|
||||
public function testShouldSetContainerOnContainerAwareFixture()
|
||||
{
|
||||
$container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
|
||||
$container = $this->createMock(ContainerInterface::class);
|
||||
$loader = new ContainerAwareLoader($container);
|
||||
$fixture = new ContainerAwareFixture();
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
@ -22,7 +23,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
class DoctrineExtensionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension
|
||||
* @var AbstractDoctrineExtension
|
||||
*/
|
||||
private $extension;
|
||||
|
||||
@ -31,7 +32,7 @@ class DoctrineExtensionTest extends TestCase
|
||||
parent::setUp();
|
||||
|
||||
$this->extension = $this
|
||||
->getMockBuilder(\Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension::class)
|
||||
->getMockBuilder(AbstractDoctrineExtension::class)
|
||||
->setMethods([
|
||||
'getMappingResourceConfigDirectory',
|
||||
'getObjectManagerElementName',
|
||||
|
@ -77,19 +77,17 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->factory = $this->getMockBuilder(ChoiceListFactoryInterface::class)->getMock();
|
||||
$this->om = $this->getMockBuilder(ObjectManager::class)->getMock();
|
||||
$this->repository = $this->getMockBuilder(ObjectRepository::class)->getMock();
|
||||
$this->factory = $this->createMock(ChoiceListFactoryInterface::class);
|
||||
$this->om = $this->createMock(ObjectManager::class);
|
||||
$this->repository = $this->createMock(ObjectRepository::class);
|
||||
$this->class = 'stdClass';
|
||||
$this->idReader = $this->getMockBuilder(IdReader::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->idReader = $this->createMock(IdReader::class);
|
||||
$this->idReader->expects($this->any())
|
||||
->method('isSingleId')
|
||||
->willReturn(true)
|
||||
;
|
||||
|
||||
$this->objectLoader = $this->getMockBuilder(EntityLoaderInterface::class)->getMock();
|
||||
$this->objectLoader = $this->createMock(EntityLoaderInterface::class);
|
||||
$this->obj1 = (object) ['name' => 'A'];
|
||||
$this->obj2 = (object) ['name' => 'B'];
|
||||
$this->obj3 = (object) ['name' => 'C'];
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\DataTransformer;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
@ -64,7 +65,7 @@ class CollectionToArrayTransformerTest extends TestCase
|
||||
|
||||
public function testTransformExpectsArrayOrCollection()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
|
||||
$this->expectException(TransformationFailedException::class);
|
||||
$this->transformer->transform('Foo');
|
||||
}
|
||||
|
||||
|
@ -62,21 +62,21 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
||||
$return = [];
|
||||
|
||||
// Simple field, not nullable
|
||||
$classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock();
|
||||
$classMetadata = $this->createMock(ClassMetadata::class);
|
||||
$classMetadata->fieldMappings['field'] = true;
|
||||
$classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(false);
|
||||
|
||||
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
|
||||
|
||||
// Simple field, nullable
|
||||
$classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock();
|
||||
$classMetadata = $this->createMock(ClassMetadata::class);
|
||||
$classMetadata->fieldMappings['field'] = true;
|
||||
$classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(true);
|
||||
|
||||
$return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)];
|
||||
|
||||
// One-to-one, nullable (by default)
|
||||
$classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock();
|
||||
$classMetadata = $this->createMock(ClassMetadata::class);
|
||||
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
|
||||
|
||||
$mapping = ['joinColumns' => [[]]];
|
||||
@ -85,7 +85,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
||||
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
|
||||
|
||||
// One-to-one, nullable (explicit)
|
||||
$classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock();
|
||||
$classMetadata = $this->createMock(ClassMetadata::class);
|
||||
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
|
||||
|
||||
$mapping = ['joinColumns' => [['nullable' => true]]];
|
||||
@ -94,7 +94,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
||||
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
|
||||
|
||||
// One-to-one, not nullable
|
||||
$classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock();
|
||||
$classMetadata = $this->createMock(ClassMetadata::class);
|
||||
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
|
||||
|
||||
$mapping = ['joinColumns' => [['nullable' => false]]];
|
||||
@ -103,7 +103,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
||||
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
|
||||
|
||||
// One-to-many, no clue
|
||||
$classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock();
|
||||
$classMetadata = $this->createMock(ClassMetadata::class);
|
||||
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(false);
|
||||
|
||||
$return[] = [$classMetadata, null];
|
||||
@ -113,10 +113,10 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
||||
|
||||
private function getGuesser(ClassMetadata $classMetadata)
|
||||
{
|
||||
$em = $this->getMockBuilder(ObjectManager::class)->getMock();
|
||||
$em = $this->createMock(ObjectManager::class);
|
||||
$em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->willReturn($classMetadata);
|
||||
|
||||
$registry = $this->getMockBuilder(ManagerRegistry::class)->getMock();
|
||||
$registry = $this->createMock(ManagerRegistry::class);
|
||||
$registry->expects($this->once())->method('getManagers')->willReturn([$em]);
|
||||
|
||||
return new DoctrineOrmTypeGuesser($registry);
|
||||
|
@ -18,6 +18,7 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
|
||||
class MergeDoctrineCollectionListenerTest extends TestCase
|
||||
{
|
||||
@ -32,7 +33,7 @@ class MergeDoctrineCollectionListenerTest extends TestCase
|
||||
{
|
||||
$this->collection = new ArrayCollection(['test']);
|
||||
$this->dispatcher = new EventDispatcher();
|
||||
$this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
|
||||
$this->factory = $this->createMock(FormFactoryInterface::class);
|
||||
$this->form = $this->getBuilder()
|
||||
->getForm();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
||||
|
||||
protected function getExtensions()
|
||||
{
|
||||
$manager = $this->getMockBuilder(ManagerRegistry::class)->getMock();
|
||||
$manager = $this->createMock(ManagerRegistry::class);
|
||||
|
||||
$manager->expects($this->any())
|
||||
->method('getManager')
|
||||
|
@ -29,11 +29,16 @@ use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringCastableIdEntity;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity;
|
||||
use Symfony\Component\Form\ChoiceList\LazyChoiceList;
|
||||
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
|
||||
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
|
||||
use Symfony\Component\Form\Exception\RuntimeException;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Form\Forms;
|
||||
use Symfony\Component\Form\Tests\Extension\Core\Type\BaseTypeTest;
|
||||
use Symfony\Component\Form\Tests\Extension\Core\Type\FormTypeTest;
|
||||
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
|
||||
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException;
|
||||
|
||||
class EntityTypeTest extends BaseTypeTest
|
||||
{
|
||||
@ -118,13 +123,13 @@ class EntityTypeTest extends BaseTypeTest
|
||||
|
||||
public function testClassOptionIsRequired()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\OptionsResolver\Exception\MissingOptionsException::class);
|
||||
$this->expectException(MissingOptionsException::class);
|
||||
$this->factory->createNamed('name', static::TESTED_TYPE);
|
||||
}
|
||||
|
||||
public function testInvalidClassOption()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Form\Exception\RuntimeException::class);
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->factory->createNamed('name', static::TESTED_TYPE, null, [
|
||||
'class' => 'foo',
|
||||
]);
|
||||
@ -219,7 +224,7 @@ class EntityTypeTest extends BaseTypeTest
|
||||
|
||||
public function testConfigureQueryBuilderWithNonQueryBuilderAndNonClosure()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class);
|
||||
$this->expectException(InvalidOptionsException::class);
|
||||
$this->factory->createNamed('name', static::TESTED_TYPE, null, [
|
||||
'em' => 'default',
|
||||
'class' => self::SINGLE_IDENT_CLASS,
|
||||
@ -229,7 +234,7 @@ class EntityTypeTest extends BaseTypeTest
|
||||
|
||||
public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class);
|
||||
$this->expectException(UnexpectedTypeException::class);
|
||||
$field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [
|
||||
'em' => 'default',
|
||||
'class' => self::SINGLE_IDENT_CLASS,
|
||||
@ -1242,7 +1247,7 @@ class EntityTypeTest extends BaseTypeTest
|
||||
$choiceList2 = $form->get('property2')->getConfig()->getAttribute('choice_list');
|
||||
$choiceList3 = $form->get('property3')->getConfig()->getAttribute('choice_list');
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Component\Form\ChoiceList\LazyChoiceList::class, $choiceList1);
|
||||
$this->assertInstanceOf(LazyChoiceList::class, $choiceList1);
|
||||
$this->assertSame($choiceList1, $choiceList2);
|
||||
$this->assertSame($choiceList1, $choiceList3);
|
||||
}
|
||||
@ -1302,14 +1307,14 @@ class EntityTypeTest extends BaseTypeTest
|
||||
$choiceList2 = $form->get('property2')->getConfig()->getAttribute('choice_list');
|
||||
$choiceList3 = $form->get('property3')->getConfig()->getAttribute('choice_list');
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Component\Form\ChoiceList\LazyChoiceList::class, $choiceList1);
|
||||
$this->assertInstanceOf(LazyChoiceList::class, $choiceList1);
|
||||
$this->assertSame($choiceList1, $choiceList2);
|
||||
$this->assertSame($choiceList1, $choiceList3);
|
||||
}
|
||||
|
||||
protected function createRegistryMock($name, $em)
|
||||
{
|
||||
$registry = $this->getMockBuilder(ManagerRegistry::class)->getMock();
|
||||
$registry = $this->createMock(ManagerRegistry::class);
|
||||
$registry->expects($this->any())
|
||||
->method('getManager')
|
||||
->with($this->equalTo($name))
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Bridge\Doctrine\Tests\Logger;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bridge\Doctrine\Logger\DbalLogger;
|
||||
|
||||
class DbalLoggerTest extends TestCase
|
||||
@ -21,7 +22,7 @@ class DbalLoggerTest extends TestCase
|
||||
*/
|
||||
public function testLog($sql, $params, $logParams)
|
||||
{
|
||||
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
$dbalLogger = $this
|
||||
->getMockBuilder(DbalLogger::class)
|
||||
@ -53,7 +54,7 @@ class DbalLoggerTest extends TestCase
|
||||
|
||||
public function testLogNonUtf8()
|
||||
{
|
||||
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
$dbalLogger = $this
|
||||
->getMockBuilder(DbalLogger::class)
|
||||
@ -76,7 +77,7 @@ class DbalLoggerTest extends TestCase
|
||||
|
||||
public function testLogNonUtf8Array()
|
||||
{
|
||||
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
$dbalLogger = $this
|
||||
->getMockBuilder(DbalLogger::class)
|
||||
@ -107,7 +108,7 @@ class DbalLoggerTest extends TestCase
|
||||
|
||||
public function testLogLongString()
|
||||
{
|
||||
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
$dbalLogger = $this
|
||||
->getMockBuilder(DbalLogger::class)
|
||||
@ -135,7 +136,7 @@ class DbalLoggerTest extends TestCase
|
||||
|
||||
public function testLogUTF8LongString()
|
||||
{
|
||||
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
$dbalLogger = $this
|
||||
->getMockBuilder(DbalLogger::class)
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Tests\Security\User;
|
||||
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Tools\SchemaTool;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
@ -20,6 +21,7 @@ use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
|
||||
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
|
||||
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\User;
|
||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
@ -71,9 +73,7 @@ class EntityUserProviderTest extends TestCase
|
||||
->with('user1')
|
||||
->willReturn($user);
|
||||
|
||||
$em = $this->getMockBuilder(\Doctrine\ORM\EntityManager::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$em = $this->createMock(EntityManager::class);
|
||||
$em
|
||||
->expects($this->once())
|
||||
->method('getRepository')
|
||||
@ -125,7 +125,7 @@ class EntityUserProviderTest extends TestCase
|
||||
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
||||
|
||||
$user2 = new User(1, 2, 'user2');
|
||||
$this->expectException(\Symfony\Component\Security\Core\Exception\UsernameNotFoundException::class);
|
||||
$this->expectException(UsernameNotFoundException::class);
|
||||
$this->expectExceptionMessage('User with id {"id1":1,"id2":2} not found');
|
||||
|
||||
$provider->refreshUser($user2);
|
||||
@ -155,7 +155,7 @@ class EntityUserProviderTest extends TestCase
|
||||
->method('loadUserByUsername')
|
||||
->with('name')
|
||||
->willReturn(
|
||||
$this->getMockBuilder(UserInterface::class)->getMock()
|
||||
$this->createMock(UserInterface::class)
|
||||
);
|
||||
|
||||
$provider = new EntityUserProvider(
|
||||
@ -198,7 +198,7 @@ class EntityUserProviderTest extends TestCase
|
||||
|
||||
private function getManager($em, $name = null)
|
||||
{
|
||||
$manager = $this->getMockBuilder(ManagerRegistry::class)->getMock();
|
||||
$manager = $this->createMock(ManagerRegistry::class);
|
||||
$manager->expects($this->any())
|
||||
->method('getManager')
|
||||
->with($this->equalTo($name))
|
||||
|
@ -21,6 +21,7 @@ use Doctrine\Persistence\ObjectRepository;
|
||||
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNullableNameEntity;
|
||||
@ -29,10 +30,13 @@ use Symfony\Bridge\Doctrine\Tests\Fixtures\Person;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdStringWrapperNameEntity;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\Type\StringWrapper;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\Type\StringWrapperType;
|
||||
use Symfony\Bridge\Doctrine\Tests\TestRepositoryFactory;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
|
||||
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
@ -67,7 +71,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
$config->setRepositoryFactory($this->repositoryFactory);
|
||||
|
||||
if (!Type::hasType('string_wrapper')) {
|
||||
Type::addType('string_wrapper', 'Symfony\Bridge\Doctrine\Tests\Fixtures\Type\StringWrapperType');
|
||||
Type::addType('string_wrapper', StringWrapperType::class);
|
||||
}
|
||||
|
||||
$this->em = DoctrineTestHelper::createTestEntityManager($config);
|
||||
@ -79,7 +83,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
protected function createRegistryMock($em = null)
|
||||
{
|
||||
$registry = $this->getMockBuilder(ManagerRegistry::class)->getMock();
|
||||
$registry = $this->createMock(ManagerRegistry::class);
|
||||
$registry->expects($this->any())
|
||||
->method('getManager')
|
||||
->with($this->equalTo(self::EM_NAME))
|
||||
@ -100,15 +104,13 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
protected function createEntityManagerMock($repositoryMock)
|
||||
{
|
||||
$em = $this->getMockBuilder(ObjectManager::class)
|
||||
->getMock()
|
||||
;
|
||||
$em = $this->createMock(ObjectManager::class);
|
||||
$em->expects($this->any())
|
||||
->method('getRepository')
|
||||
->willReturn($repositoryMock)
|
||||
;
|
||||
|
||||
$classMetadata = $this->getMockBuilder(ClassMetadata::class)->getMock();
|
||||
$classMetadata = $this->createMock(ClassMetadata::class);
|
||||
$classMetadata
|
||||
->expects($this->any())
|
||||
->method('hasField')
|
||||
@ -137,17 +139,17 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
$schemaTool = new SchemaTool($em);
|
||||
$schemaTool->createSchema([
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNullableNameEntity'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\Person'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\Employee'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdStringWrapperNameEntity'),
|
||||
$em->getClassMetadata(SingleIntIdEntity::class),
|
||||
$em->getClassMetadata(SingleIntIdNoToStringEntity::class),
|
||||
$em->getClassMetadata(DoubleNameEntity::class),
|
||||
$em->getClassMetadata(DoubleNullableNameEntity::class),
|
||||
$em->getClassMetadata(CompositeIntIdEntity::class),
|
||||
$em->getClassMetadata(AssociationEntity::class),
|
||||
$em->getClassMetadata(AssociationEntity2::class),
|
||||
$em->getClassMetadata(Person::class),
|
||||
$em->getClassMetadata(Employee::class),
|
||||
$em->getClassMetadata(CompositeObjectNoToStringIdEntity::class),
|
||||
$em->getClassMetadata(SingleIntIdStringWrapperNameEntity::class),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -578,7 +580,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
public function testValidateUniquenessWithArrayValue()
|
||||
{
|
||||
$repository = $this->createRepositoryMock();
|
||||
$this->repositoryFactory->setRepository($this->em, 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity', $repository);
|
||||
$this->repositoryFactory->setRepository($this->em, SingleIntIdEntity::class, $repository);
|
||||
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
@ -616,7 +618,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
public function testDedicatedEntityManagerNullObject()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
|
||||
$this->expectException(ConstraintDefinitionException::class);
|
||||
$this->expectExceptionMessage('Object manager "foo" does not exist.');
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
@ -636,7 +638,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
public function testEntityManagerNullObject()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
|
||||
$this->expectException(ConstraintDefinitionException::class);
|
||||
$this->expectExceptionMessage('Unable to find the object manager associated with an entity of class "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity"');
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
@ -688,7 +690,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
'message' => 'myMessage',
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
'entityClass' => 'Symfony\Bridge\Doctrine\Tests\Fixtures\Person',
|
||||
'entityClass' => Person::class,
|
||||
]);
|
||||
|
||||
$entity1 = new Person(1, 'Foo');
|
||||
@ -718,13 +720,13 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
public function testInvalidateRepositoryForInheritance()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
|
||||
$this->expectException(ConstraintDefinitionException::class);
|
||||
$this->expectExceptionMessage('The "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity" entity repository does not support the "Symfony\Bridge\Doctrine\Tests\Fixtures\Person" entity. The entity should be an instance of or extend "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity".');
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
'entityClass' => 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity',
|
||||
'entityClass' => SingleStringIdEntity::class,
|
||||
]);
|
||||
|
||||
$entity = new Person(1, 'Foo');
|
||||
|
@ -13,12 +13,15 @@ namespace Symfony\Bridge\Monolog\Tests\Handler;
|
||||
|
||||
use Monolog\Logger;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter;
|
||||
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\ConsoleEvents;
|
||||
use Symfony\Component\Console\Event\ConsoleCommandEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
|
||||
@ -46,7 +49,7 @@ class ConsoleHandlerTest extends TestCase
|
||||
*/
|
||||
public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = [])
|
||||
{
|
||||
$output = $this->getMockBuilder(OutputInterface::class)->getMock();
|
||||
$output = $this->createMock(OutputInterface::class);
|
||||
$output
|
||||
->expects($this->atLeastOnce())
|
||||
->method('getVerbosity')
|
||||
@ -61,7 +64,7 @@ class ConsoleHandlerTest extends TestCase
|
||||
$levelName = Logger::getLevelName($level);
|
||||
$levelName = sprintf('%-9s', $levelName);
|
||||
|
||||
$realOutput = $this->getMockBuilder(\Symfony\Component\Console\Output\Output::class)->setMethods(['doWrite'])->getMock();
|
||||
$realOutput = $this->getMockBuilder(Output::class)->setMethods(['doWrite'])->getMock();
|
||||
$realOutput->setVerbosity($verbosity);
|
||||
if ($realOutput->isDebug()) {
|
||||
$log = "16:21:54 $levelName [app] My info message\n";
|
||||
@ -110,7 +113,7 @@ class ConsoleHandlerTest extends TestCase
|
||||
|
||||
public function testVerbosityChanged()
|
||||
{
|
||||
$output = $this->getMockBuilder(OutputInterface::class)->getMock();
|
||||
$output = $this->createMock(OutputInterface::class);
|
||||
$output
|
||||
->expects($this->exactly(2))
|
||||
->method('getVerbosity')
|
||||
@ -131,14 +134,15 @@ class ConsoleHandlerTest extends TestCase
|
||||
public function testGetFormatter()
|
||||
{
|
||||
$handler = new ConsoleHandler();
|
||||
$this->assertInstanceOf(\Symfony\Bridge\Monolog\Formatter\ConsoleFormatter::class, $handler->getFormatter(),
|
||||
'-getFormatter returns ConsoleFormatter by default'
|
||||
$this->assertInstanceOf(
|
||||
ConsoleFormatter::class, $handler->getFormatter(),
|
||||
'->getFormatter returns ConsoleFormatter by default'
|
||||
);
|
||||
}
|
||||
|
||||
public function testWritingAndFormatting()
|
||||
{
|
||||
$output = $this->getMockBuilder(OutputInterface::class)->getMock();
|
||||
$output = $this->createMock(OutputInterface::class);
|
||||
$output
|
||||
->expects($this->any())
|
||||
->method('getVerbosity')
|
||||
@ -193,12 +197,12 @@ class ConsoleHandlerTest extends TestCase
|
||||
$logger->info('After terminate message.');
|
||||
});
|
||||
|
||||
$event = new ConsoleCommandEvent(new Command('foo'), $this->getMockBuilder(\Symfony\Component\Console\Input\InputInterface::class)->getMock(), $output);
|
||||
$event = new ConsoleCommandEvent(new Command('foo'), $this->createMock(InputInterface::class), $output);
|
||||
$dispatcher->dispatch($event, ConsoleEvents::COMMAND);
|
||||
$this->assertStringContainsString('Before command message.', $out = $output->fetch());
|
||||
$this->assertStringContainsString('After command message.', $out);
|
||||
|
||||
$event = new ConsoleTerminateEvent(new Command('foo'), $this->getMockBuilder(\Symfony\Component\Console\Input\InputInterface::class)->getMock(), $output, 0);
|
||||
$event = new ConsoleTerminateEvent(new Command('foo'), $this->createMock(InputInterface::class), $output, 0);
|
||||
$dispatcher->dispatch($event, ConsoleEvents::TERMINATE);
|
||||
$this->assertStringContainsString('Before terminate message.', $out = $output->fetch());
|
||||
$this->assertStringContainsString('After terminate message.', $out);
|
||||
|
@ -44,7 +44,7 @@ class ServerLogHandlerTest extends TestCase
|
||||
{
|
||||
$handler = new ServerLogHandler('tcp://127.0.0.1:9999');
|
||||
$this->assertInstanceOf(VarDumperFormatter::class, $handler->getFormatter(),
|
||||
'-getFormatter returns VarDumperFormatter by default'
|
||||
'->getFormatter returns VarDumperFormatter by default'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ class LoggerTest extends TestCase
|
||||
public function testGetLogsWithDebugProcessor3()
|
||||
{
|
||||
$request = new Request();
|
||||
$processor = $this->getMockBuilder(DebugProcessor::class)->getMock();
|
||||
$processor = $this->createMock(DebugProcessor::class);
|
||||
$processor->expects($this->once())->method('getLogs')->with($request);
|
||||
$processor->expects($this->once())->method('countErrors')->with($request);
|
||||
|
||||
|
@ -61,12 +61,12 @@ class ConsoleCommandProcessorTest extends TestCase
|
||||
|
||||
private function getConsoleEvent(): ConsoleEvent
|
||||
{
|
||||
$input = $this->getMockBuilder(InputInterface::class)->getMock();
|
||||
$input = $this->createMock(InputInterface::class);
|
||||
$input->method('getArguments')->willReturn(self::TEST_ARGUMENTS);
|
||||
$input->method('getOptions')->willReturn(self::TEST_OPTIONS);
|
||||
$command = $this->getMockBuilder(Command::class)->disableOriginalConstructor()->getMock();
|
||||
$command = $this->createMock(Command::class);
|
||||
$command->method('getName')->willReturn(self::TEST_NAME);
|
||||
$consoleEvent = $this->getMockBuilder(ConsoleEvent::class)->disableOriginalConstructor()->getMock();
|
||||
$consoleEvent = $this->createMock(ConsoleEvent::class);
|
||||
$consoleEvent->method('getCommand')->willReturn($command);
|
||||
$consoleEvent->method('getInput')->willReturn($input);
|
||||
|
||||
|
@ -149,7 +149,7 @@ class RouteProcessorTest extends TestCase
|
||||
|
||||
private function mockRequest(array $attributes): Request
|
||||
{
|
||||
$request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
|
||||
$request = $this->createMock(Request::class);
|
||||
$request->attributes = new ParameterBag($attributes);
|
||||
|
||||
return $request;
|
||||
|
@ -26,7 +26,7 @@ class TokenProcessorTest extends TestCase
|
||||
public function testProcessor()
|
||||
{
|
||||
$token = new UsernamePasswordToken('user', 'password', 'provider', ['ROLE_USER']);
|
||||
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock();
|
||||
$tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||
$tokenStorage->method('getToken')->willReturn($token);
|
||||
|
||||
$processor = new TokenProcessor($tokenStorage);
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\Dumper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ProxyManager\Proxy\LazyLoadingInterface;
|
||||
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
||||
@ -46,7 +47,7 @@ class PhpDumperTest extends TestCase
|
||||
|
||||
$proxy = $container->get('foo');
|
||||
$this->assertInstanceOf(\stdClass::class, $proxy);
|
||||
$this->assertInstanceOf(\ProxyManager\Proxy\LazyLoadingInterface::class, $proxy);
|
||||
$this->assertInstanceOf(LazyLoadingInterface::class, $proxy);
|
||||
$this->assertSame($proxy, $container->get('foo'));
|
||||
|
||||
$this->assertFalse($proxy->isProxyInitialized());
|
||||
|
@ -12,7 +12,10 @@
|
||||
namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\Instantiator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ProxyManager\Proxy\LazyLoadingInterface;
|
||||
use ProxyManager\Proxy\ValueHolderInterface;
|
||||
use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
/**
|
||||
@ -38,17 +41,17 @@ class RuntimeInstantiatorTest extends TestCase
|
||||
public function testInstantiateProxy()
|
||||
{
|
||||
$instance = new \stdClass();
|
||||
$container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
|
||||
$container = $this->createMock(ContainerInterface::class);
|
||||
$definition = new Definition('stdClass');
|
||||
$instantiator = function () use ($instance) {
|
||||
return $instance;
|
||||
};
|
||||
|
||||
/* @var $proxy \ProxyManager\Proxy\LazyLoadingInterface|\ProxyManager\Proxy\ValueHolderInterface */
|
||||
/* @var $proxy LazyLoadingInterface|ValueHolderInterface */
|
||||
$proxy = $this->instantiator->instantiateProxy($container, $definition, 'foo', $instantiator);
|
||||
|
||||
$this->assertInstanceOf(\ProxyManager\Proxy\LazyLoadingInterface::class, $proxy);
|
||||
$this->assertInstanceOf(\ProxyManager\Proxy\ValueHolderInterface::class, $proxy);
|
||||
$this->assertInstanceOf(LazyLoadingInterface::class, $proxy);
|
||||
$this->assertInstanceOf(ValueHolderInterface::class, $proxy);
|
||||
$this->assertFalse($proxy->isProxyInitialized());
|
||||
|
||||
$proxy->initializeProxy();
|
||||
|
@ -5,8 +5,12 @@ namespace Symfony\Bridge\Twig\Tests;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Twig\AppVariable;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
class AppVariableTest extends TestCase
|
||||
{
|
||||
@ -50,7 +54,7 @@ class AppVariableTest extends TestCase
|
||||
*/
|
||||
public function testGetSession()
|
||||
{
|
||||
$request = $this->getMockBuilder(Request::class)->getMock();
|
||||
$request = $this->createMock(Request::class);
|
||||
$request->method('hasSession')->willReturn(true);
|
||||
$request->method('getSession')->willReturn($session = new Session());
|
||||
|
||||
@ -75,10 +79,10 @@ class AppVariableTest extends TestCase
|
||||
|
||||
public function testGetToken()
|
||||
{
|
||||
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
|
||||
$tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||
$this->appVariable->setTokenStorage($tokenStorage);
|
||||
|
||||
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
|
||||
$token = $this->createMock(TokenInterface::class);
|
||||
$tokenStorage->method('getToken')->willReturn($token);
|
||||
|
||||
$this->assertEquals($token, $this->appVariable->getToken());
|
||||
@ -86,7 +90,7 @@ class AppVariableTest extends TestCase
|
||||
|
||||
public function testGetUser()
|
||||
{
|
||||
$this->setTokenStorage($user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock());
|
||||
$this->setTokenStorage($user = $this->createMock(UserInterface::class));
|
||||
|
||||
$this->assertEquals($user, $this->appVariable->getUser());
|
||||
}
|
||||
@ -100,7 +104,7 @@ class AppVariableTest extends TestCase
|
||||
|
||||
public function testGetTokenWithNoToken()
|
||||
{
|
||||
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
|
||||
$tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||
$this->appVariable->setTokenStorage($tokenStorage);
|
||||
|
||||
$this->assertNull($this->appVariable->getToken());
|
||||
@ -108,7 +112,7 @@ class AppVariableTest extends TestCase
|
||||
|
||||
public function testGetUserWithNoToken()
|
||||
{
|
||||
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
|
||||
$tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||
$this->appVariable->setTokenStorage($tokenStorage);
|
||||
|
||||
$this->assertNull($this->appVariable->getUser());
|
||||
@ -224,7 +228,7 @@ class AppVariableTest extends TestCase
|
||||
|
||||
protected function setRequestStack($request)
|
||||
{
|
||||
$requestStackMock = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
|
||||
$requestStackMock = $this->createMock(RequestStack::class);
|
||||
$requestStackMock->method('getCurrentRequest')->willReturn($request);
|
||||
|
||||
$this->appVariable->setRequestStack($requestStackMock);
|
||||
@ -232,10 +236,10 @@ class AppVariableTest extends TestCase
|
||||
|
||||
protected function setTokenStorage($user)
|
||||
{
|
||||
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
|
||||
$tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||
$this->appVariable->setTokenStorage($tokenStorage);
|
||||
|
||||
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
|
||||
$token = $this->createMock(TokenInterface::class);
|
||||
$tokenStorage->method('getToken')->willReturn($token);
|
||||
|
||||
$token->method('getUser')->willReturn($user);
|
||||
@ -251,11 +255,11 @@ class AppVariableTest extends TestCase
|
||||
$flashBag = new FlashBag();
|
||||
$flashBag->initialize($flashMessages);
|
||||
|
||||
$session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock();
|
||||
$session = $this->createMock(Session::class);
|
||||
$session->method('isStarted')->willReturn($sessionHasStarted);
|
||||
$session->method('getFlashBag')->willReturn($flashBag);
|
||||
|
||||
$request = $this->getMockBuilder(Request::class)->getMock();
|
||||
$request = $this->createMock(Request::class);
|
||||
$request->method('hasSession')->willReturn(true);
|
||||
$request->method('getSession')->willReturn($session);
|
||||
$this->setRequestStack($request);
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bridge\Twig\Tests\Command;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Twig\Command\DebugCommand;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\ChainLoader;
|
||||
@ -65,7 +66,7 @@ class DebugCommandTest extends TestCase
|
||||
|
||||
public function testMalformedTemplateName()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Console\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Malformed namespaced template name "@foo" (expecting "@namespace/template_name").');
|
||||
$this->createCommandTester()->execute(['name' => '@foo']);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ use Symfony\Component\VarDumper\Dumper\HtmlDumper;
|
||||
use Symfony\Component\VarDumper\VarDumper;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\ArrayLoader;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
|
||||
class DumpExtensionTest extends TestCase
|
||||
{
|
||||
@ -67,7 +68,7 @@ class DumpExtensionTest extends TestCase
|
||||
public function testDump($context, $args, $expectedOutput, $debug = true)
|
||||
{
|
||||
$extension = new DumpExtension(new VarCloner());
|
||||
$twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), [
|
||||
$twig = new Environment($this->createMock(LoaderInterface::class), [
|
||||
'debug' => $debug,
|
||||
'cache' => false,
|
||||
'optimizations' => 0,
|
||||
@ -124,7 +125,7 @@ class DumpExtensionTest extends TestCase
|
||||
'</pre><script>Sfdump("%s")</script>'
|
||||
);
|
||||
$extension = new DumpExtension(new VarCloner(), $dumper);
|
||||
$twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), [
|
||||
$twig = new Environment($this->createMock(LoaderInterface::class), [
|
||||
'debug' => true,
|
||||
'cache' => false,
|
||||
'optimizations' => 0,
|
||||
|
@ -17,6 +17,7 @@ use Symfony\Bridge\Twig\Form\TwigRendererEngine;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
@ -50,7 +51,7 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori
|
||||
'bootstrap_3_horizontal_layout.html.twig',
|
||||
'custom_widgets.html.twig',
|
||||
], $environment);
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->createMock(CsrfTokenManagerInterface::class));
|
||||
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ use Symfony\Bridge\Twig\Form\TwigRendererEngine;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
@ -46,7 +47,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
|
||||
'bootstrap_3_layout.html.twig',
|
||||
'custom_widgets.html.twig',
|
||||
], $environment);
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->createMock(CsrfTokenManagerInterface::class));
|
||||
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||
}
|
||||
|
||||
@ -88,7 +89,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
|
||||
'bootstrap_3_layout.html.twig',
|
||||
'custom_widgets.html.twig',
|
||||
], $environment);
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->createMock(CsrfTokenManagerInterface::class));
|
||||
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||
|
||||
$view = $this->factory
|
||||
|
@ -17,6 +17,7 @@ use Symfony\Bridge\Twig\Form\TwigRendererEngine;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
@ -52,7 +53,7 @@ class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4Hori
|
||||
'bootstrap_4_horizontal_layout.html.twig',
|
||||
'custom_widgets.html.twig',
|
||||
], $environment);
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->createMock(CsrfTokenManagerInterface::class));
|
||||
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ use Symfony\Bridge\Twig\Form\TwigRendererEngine;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
@ -50,7 +51,7 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest
|
||||
'bootstrap_4_layout.html.twig',
|
||||
'custom_widgets.html.twig',
|
||||
], $environment);
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->createMock(CsrfTokenManagerInterface::class));
|
||||
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||
}
|
||||
|
||||
@ -92,7 +93,7 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest
|
||||
'bootstrap_4_layout.html.twig',
|
||||
'custom_widgets.html.twig',
|
||||
], $environment);
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->createMock(CsrfTokenManagerInterface::class));
|
||||
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||
|
||||
$view = $this->factory
|
||||
|
@ -19,6 +19,7 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceView;
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\Tests\AbstractDivLayoutTest;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
@ -53,7 +54,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
||||
'form_div_layout.html.twig',
|
||||
'custom_widgets.html.twig',
|
||||
], $environment);
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->createMock(CsrfTokenManagerInterface::class));
|
||||
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||
}
|
||||
|
||||
@ -181,7 +182,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
||||
'form_div_layout.html.twig',
|
||||
'custom_widgets.html.twig',
|
||||
], $environment);
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->createMock(CsrfTokenManagerInterface::class));
|
||||
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||
|
||||
$view = $this->factory
|
||||
|
@ -18,6 +18,7 @@ use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\Tests\AbstractTableLayoutTest;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
@ -50,7 +51,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
||||
'form_table_layout.html.twig',
|
||||
'custom_widgets.html.twig',
|
||||
], $environment);
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->createMock(CsrfTokenManagerInterface::class));
|
||||
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||
}
|
||||
|
||||
|
@ -15,10 +15,13 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Twig\Extension\HttpKernelExtension;
|
||||
use Symfony\Bridge\Twig\Extension\HttpKernelRuntime;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
|
||||
use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\ArrayLoader;
|
||||
use Twig\RuntimeLoader\RuntimeLoaderInterface;
|
||||
|
||||
class HttpKernelExtensionTest extends TestCase
|
||||
{
|
||||
@ -41,10 +44,7 @@ class HttpKernelExtensionTest extends TestCase
|
||||
|
||||
public function testUnknownFragmentRenderer()
|
||||
{
|
||||
$context = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock()
|
||||
;
|
||||
$context = $this->createMock(RequestStack::class);
|
||||
$renderer = new FragmentHandler($context);
|
||||
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
@ -55,14 +55,11 @@ class HttpKernelExtensionTest extends TestCase
|
||||
|
||||
protected function getFragmentHandler($return)
|
||||
{
|
||||
$strategy = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface::class)->getMock();
|
||||
$strategy = $this->createMock(FragmentRendererInterface::class);
|
||||
$strategy->expects($this->once())->method('getName')->willReturn('inline');
|
||||
$strategy->expects($this->once())->method('render')->will($return);
|
||||
|
||||
$context = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock()
|
||||
;
|
||||
$context = $this->createMock(RequestStack::class);
|
||||
|
||||
$context->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/'));
|
||||
|
||||
@ -75,7 +72,7 @@ class HttpKernelExtensionTest extends TestCase
|
||||
$twig = new Environment($loader, ['debug' => true, 'cache' => false]);
|
||||
$twig->addExtension(new HttpKernelExtension());
|
||||
|
||||
$loader = $this->getMockBuilder(\Twig\RuntimeLoader\RuntimeLoaderInterface::class)->getMock();
|
||||
$loader = $this->createMock(RuntimeLoaderInterface::class);
|
||||
$loader->expects($this->any())->method('load')->willReturnMap([
|
||||
['Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)],
|
||||
]);
|
||||
|
@ -13,7 +13,9 @@ namespace Symfony\Bridge\Twig\Tests\Extension;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Twig\Extension\RoutingExtension;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
use Twig\Node\Expression\FilterExpression;
|
||||
use Twig\Source;
|
||||
|
||||
@ -24,8 +26,8 @@ class RoutingExtensionTest extends TestCase
|
||||
*/
|
||||
public function testEscaping($template, $mustBeEscaped)
|
||||
{
|
||||
$twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]);
|
||||
$twig->addExtension(new RoutingExtension($this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock()));
|
||||
$twig = new Environment($this->createMock(LoaderInterface::class), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]);
|
||||
$twig->addExtension(new RoutingExtension($this->createMock(UrlGeneratorInterface::class)));
|
||||
|
||||
$nodes = $twig->parse($twig->tokenize(new Source($template, '')));
|
||||
|
||||
|
@ -13,12 +13,13 @@ namespace Symfony\Bridge\Twig\Tests\Extension;
|
||||
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Twig\Environment;
|
||||
use Twig\RuntimeLoader\RuntimeLoaderInterface;
|
||||
|
||||
trait RuntimeLoaderProvider
|
||||
{
|
||||
protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer)
|
||||
{
|
||||
$loader = $this->getMockBuilder(\Twig\RuntimeLoader\RuntimeLoaderInterface::class)->getMock();
|
||||
$loader = $this->createMock(RuntimeLoaderInterface::class);
|
||||
$loader->expects($this->any())->method('load')->will($this->returnValueMap([
|
||||
['Symfony\Component\Form\FormRenderer', $renderer],
|
||||
]));
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Twig\Extension\StopwatchExtension;
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
use Twig\Environment;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Loader\ArrayLoader;
|
||||
@ -55,7 +56,7 @@ class StopwatchExtensionTest extends TestCase
|
||||
protected function getStopwatch($events = [])
|
||||
{
|
||||
$events = \is_array($events) ? $events : [$events];
|
||||
$stopwatch = $this->getMockBuilder(\Symfony\Component\Stopwatch\Stopwatch::class)->getMock();
|
||||
$stopwatch = $this->createMock(Stopwatch::class);
|
||||
|
||||
$expectedCalls = 0;
|
||||
$expectedStartCalls = [];
|
||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Twig\Node\DumpNode;
|
||||
use Twig\Compiler;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
use Twig\Node\Expression\NameExpression;
|
||||
use Twig\Node\Node;
|
||||
|
||||
@ -24,7 +25,7 @@ class DumpNodeTest extends TestCase
|
||||
{
|
||||
$node = new DumpNode('bar', null, 7);
|
||||
|
||||
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock());
|
||||
$env = new Environment($this->createMock(LoaderInterface::class));
|
||||
$compiler = new Compiler($env);
|
||||
|
||||
$expected = <<<'EOTXT'
|
||||
@ -48,7 +49,7 @@ EOTXT;
|
||||
{
|
||||
$node = new DumpNode('bar', null, 7);
|
||||
|
||||
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock());
|
||||
$env = new Environment($this->createMock(LoaderInterface::class));
|
||||
$compiler = new Compiler($env);
|
||||
|
||||
$expected = <<<'EOTXT'
|
||||
@ -75,7 +76,7 @@ EOTXT;
|
||||
]);
|
||||
$node = new DumpNode('bar', $vars, 7);
|
||||
|
||||
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock());
|
||||
$env = new Environment($this->createMock(LoaderInterface::class));
|
||||
$compiler = new Compiler($env);
|
||||
|
||||
$expected = <<<'EOTXT'
|
||||
@ -99,7 +100,7 @@ EOTXT;
|
||||
]);
|
||||
$node = new DumpNode('bar', $vars, 7);
|
||||
|
||||
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock());
|
||||
$env = new Environment($this->createMock(LoaderInterface::class));
|
||||
$compiler = new Compiler($env);
|
||||
|
||||
$expected = <<<'EOTXT'
|
||||
|
@ -18,6 +18,7 @@ use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Form\FormRendererEngineInterface;
|
||||
use Twig\Compiler;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
use Twig\Node\Expression\NameExpression;
|
||||
@ -54,8 +55,8 @@ class FormThemeTest extends TestCase
|
||||
|
||||
$node = new FormThemeNode($form, $resources, 0);
|
||||
|
||||
$environment = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock());
|
||||
$formRenderer = new FormRenderer($this->getMockBuilder(FormRendererEngineInterface::class)->getMock());
|
||||
$environment = new Environment($this->createMock(LoaderInterface::class));
|
||||
$formRenderer = new FormRenderer($this->createMock(FormRendererEngineInterface::class));
|
||||
$this->registerTwigRuntimeLoader($environment, $formRenderer);
|
||||
$compiler = new Compiler($environment);
|
||||
|
||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode;
|
||||
use Twig\Compiler;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Expression\ConditionalExpression;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
@ -31,7 +32,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
||||
|
||||
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
|
||||
|
||||
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
|
||||
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
|
||||
|
||||
$this->assertEquals(
|
||||
sprintf(
|
||||
@ -54,7 +55,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
||||
|
||||
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
|
||||
|
||||
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
|
||||
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
|
||||
|
||||
$this->assertEquals(
|
||||
sprintf(
|
||||
@ -74,7 +75,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
||||
|
||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
||||
|
||||
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
|
||||
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
|
||||
|
||||
$this->assertEquals(
|
||||
sprintf(
|
||||
@ -94,7 +95,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
||||
|
||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
||||
|
||||
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
|
||||
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
|
||||
|
||||
// "label" => null must not be included in the output!
|
||||
// Otherwise the default label is overwritten with null.
|
||||
@ -116,7 +117,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
||||
|
||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
||||
|
||||
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
|
||||
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
|
||||
|
||||
// "label" => null must not be included in the output!
|
||||
// Otherwise the default label is overwritten with null.
|
||||
@ -137,7 +138,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
||||
|
||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
||||
|
||||
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
|
||||
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
|
||||
|
||||
$this->assertEquals(
|
||||
sprintf(
|
||||
@ -161,7 +162,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
||||
|
||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
||||
|
||||
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
|
||||
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
|
||||
|
||||
// "label" => null must not be included in the output!
|
||||
// Otherwise the default label is overwritten with null.
|
||||
@ -190,7 +191,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
||||
|
||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
||||
|
||||
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
|
||||
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
|
||||
|
||||
$this->assertEquals(
|
||||
sprintf(
|
||||
@ -218,7 +219,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
||||
|
||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
||||
|
||||
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
|
||||
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
|
||||
|
||||
// "label" => null must not be included in the output!
|
||||
// Otherwise the default label is overwritten with null.
|
||||
@ -255,7 +256,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
||||
|
||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
||||
|
||||
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
|
||||
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
|
||||
|
||||
// "label" => null must not be included in the output!
|
||||
// Otherwise the default label is overwritten with null.
|
||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Twig\Node\TransNode;
|
||||
use Twig\Compiler;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
use Twig\Node\Expression\NameExpression;
|
||||
use Twig\Node\TextNode;
|
||||
|
||||
@ -29,7 +30,7 @@ class TransNodeTest extends TestCase
|
||||
$vars = new NameExpression('foo', 0);
|
||||
$node = new TransNode($body, null, null, $vars);
|
||||
|
||||
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['strict_variables' => true]);
|
||||
$env = new Environment($this->createMock(LoaderInterface::class), ['strict_variables' => true]);
|
||||
$compiler = new Compiler($env);
|
||||
|
||||
$this->assertEquals(
|
||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Twig\NodeVisitor\TranslationDefaultDomainNodeVisitor;
|
||||
use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Node;
|
||||
|
||||
@ -26,7 +27,7 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase
|
||||
/** @dataProvider getDefaultDomainAssignmentTestData */
|
||||
public function testDefaultDomainAssignment(Node $node)
|
||||
{
|
||||
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
|
||||
$env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
|
||||
$visitor = new TranslationDefaultDomainNodeVisitor();
|
||||
|
||||
// visit trans_default_domain tag
|
||||
@ -52,7 +53,7 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase
|
||||
/** @dataProvider getDefaultDomainAssignmentTestData */
|
||||
public function testNewModuleWithoutDefaultDomainTag(Node $node)
|
||||
{
|
||||
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
|
||||
$env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
|
||||
$visitor = new TranslationDefaultDomainNodeVisitor();
|
||||
|
||||
// visit trans_default_domain tag
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bridge\Twig\Tests\NodeVisitor;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
use Twig\Node\Expression\FilterExpression;
|
||||
@ -25,7 +26,7 @@ class TranslationNodeVisitorTest extends TestCase
|
||||
/** @dataProvider getMessagesExtractionTestData */
|
||||
public function testMessagesExtraction(Node $node, array $expectedMessages)
|
||||
{
|
||||
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
|
||||
$env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
|
||||
$visitor = new TranslationNodeVisitor();
|
||||
$visitor->enable();
|
||||
$visitor->enterNode($node, $env);
|
||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Twig\Node\FormThemeNode;
|
||||
use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
use Twig\Node\Expression\NameExpression;
|
||||
@ -28,7 +29,7 @@ class FormThemeTokenParserTest extends TestCase
|
||||
*/
|
||||
public function testCompile($source, $expected)
|
||||
{
|
||||
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
|
||||
$env = new Environment($this->createMock(LoaderInterface::class), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
|
||||
$env->addTokenParser(new FormThemeTokenParser());
|
||||
$source = new Source($source, '');
|
||||
$stream = $env->tokenize($source);
|
||||
|
@ -18,6 +18,7 @@ use Symfony\Component\Translation\MessageCatalogue;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\ArrayLoader;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
|
||||
class TwigExtractorTest extends TestCase
|
||||
{
|
||||
@ -26,14 +27,14 @@ class TwigExtractorTest extends TestCase
|
||||
*/
|
||||
public function testExtract($template, $messages)
|
||||
{
|
||||
$loader = $this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock();
|
||||
$loader = $this->createMock(LoaderInterface::class);
|
||||
$twig = new Environment($loader, [
|
||||
'strict_variables' => true,
|
||||
'debug' => true,
|
||||
'cache' => false,
|
||||
'autoescape' => false,
|
||||
]);
|
||||
$twig->addExtension(new TranslationExtension($this->getMockBuilder(TranslatorInterface::class)->getMock()));
|
||||
$twig->addExtension(new TranslationExtension($this->createMock(TranslatorInterface::class)));
|
||||
|
||||
$extractor = new TwigExtractor($twig);
|
||||
$extractor->setPrefix('prefix');
|
||||
@ -91,8 +92,8 @@ class TwigExtractorTest extends TestCase
|
||||
*/
|
||||
public function testExtractSyntaxError($resources, array $messages)
|
||||
{
|
||||
$twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock());
|
||||
$twig->addExtension(new TranslationExtension($this->getMockBuilder(TranslatorInterface::class)->getMock()));
|
||||
$twig = new Environment($this->createMock(LoaderInterface::class));
|
||||
$twig->addExtension(new TranslationExtension($this->createMock(TranslatorInterface::class)));
|
||||
|
||||
$extractor = new TwigExtractor($twig);
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
@ -121,7 +122,7 @@ class TwigExtractorTest extends TestCase
|
||||
'cache' => false,
|
||||
'autoescape' => false,
|
||||
]);
|
||||
$twig->addExtension(new TranslationExtension($this->getMockBuilder(TranslatorInterface::class)->getMock()));
|
||||
$twig->addExtension(new TranslationExtension($this->createMock(TranslatorInterface::class)));
|
||||
|
||||
$extractor = new TwigExtractor($twig);
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
|
@ -125,7 +125,7 @@ class AnnotationsCacheWarmerTest extends TestCase
|
||||
*/
|
||||
private function getReadOnlyReader(): object
|
||||
{
|
||||
$readerMock = $this->getMockBuilder(Reader::class)->getMock();
|
||||
$readerMock = $this->createMock(Reader::class);
|
||||
$readerMock->expects($this->exactly(0))->method('getClassAnnotations');
|
||||
$readerMock->expects($this->exactly(0))->method('getClassAnnotation');
|
||||
$readerMock->expects($this->exactly(0))->method('getMethodAnnotations');
|
||||
|
@ -17,6 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Command\CachePoolDeleteCommand;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
@ -26,8 +27,7 @@ class CachePoolDeleteCommandTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->cachePool = $this->getMockBuilder(CacheItemPoolInterface::class)
|
||||
->getMock();
|
||||
$this->cachePool = $this->createMock(CacheItemPoolInterface::class);
|
||||
}
|
||||
|
||||
public function testCommandWithValidKey()
|
||||
@ -88,14 +88,9 @@ class CachePoolDeleteCommandTest extends TestCase
|
||||
*/
|
||||
private function getKernel(): object
|
||||
{
|
||||
$container = $this
|
||||
->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)
|
||||
->getMock();
|
||||
|
||||
$kernel = $this
|
||||
->getMockBuilder(KernelInterface::class)
|
||||
->getMock();
|
||||
$container = $this->createMock(ContainerInterface::class);
|
||||
|
||||
$kernel = $this->createMock(KernelInterface::class);
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getContainer')
|
||||
|
@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Component\Cache\PruneableInterface;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
class CachePruneCommandTest extends TestCase
|
||||
@ -54,14 +55,9 @@ class CachePruneCommandTest extends TestCase
|
||||
*/
|
||||
private function getKernel(): object
|
||||
{
|
||||
$container = $this
|
||||
->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)
|
||||
->getMock();
|
||||
|
||||
$kernel = $this
|
||||
->getMockBuilder(KernelInterface::class)
|
||||
->getMock();
|
||||
$container = $this->createMock(ContainerInterface::class);
|
||||
|
||||
$kernel = $this->createMock(KernelInterface::class);
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getContainer')
|
||||
@ -80,10 +76,7 @@ class CachePruneCommandTest extends TestCase
|
||||
*/
|
||||
private function getPruneableInterfaceMock(): object
|
||||
{
|
||||
$pruneable = $this
|
||||
->getMockBuilder(PruneableInterface::class)
|
||||
->getMock();
|
||||
|
||||
$pruneable = $this->createMock(PruneableInterface::class);
|
||||
$pruneable
|
||||
->expects($this->atLeastOnce())
|
||||
->method('prune');
|
||||
|
@ -16,10 +16,12 @@ use Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand;
|
||||
use Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
|
||||
class RouterMatchCommandTest extends TestCase
|
||||
{
|
||||
@ -55,7 +57,7 @@ class RouterMatchCommandTest extends TestCase
|
||||
$routeCollection = new RouteCollection();
|
||||
$routeCollection->add('foo', new Route('foo'));
|
||||
$requestContext = new RequestContext();
|
||||
$router = $this->getMockBuilder(\Symfony\Component\Routing\RouterInterface::class)->getMock();
|
||||
$router = $this->createMock(RouterInterface::class);
|
||||
$router
|
||||
->expects($this->any())
|
||||
->method('getRouteCollection')
|
||||
@ -70,7 +72,7 @@ class RouterMatchCommandTest extends TestCase
|
||||
|
||||
private function getKernel()
|
||||
{
|
||||
$container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
|
||||
$container = $this->createMock(ContainerInterface::class);
|
||||
$container
|
||||
->expects($this->atLeastOnce())
|
||||
->method('has')
|
||||
@ -85,7 +87,7 @@ class RouterMatchCommandTest extends TestCase
|
||||
->willReturn($this->getRouter())
|
||||
;
|
||||
|
||||
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
||||
$kernel = $this->createMock(KernelInterface::class);
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getContainer')
|
||||
|
@ -17,6 +17,11 @@ use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Translation\Extractor\ExtractorInterface;
|
||||
use Symfony\Component\Translation\Reader\TranslationReader;
|
||||
use Symfony\Component\Translation\Translator;
|
||||
|
||||
class TranslationDebugCommandTest extends TestCase
|
||||
{
|
||||
@ -92,7 +97,7 @@ class TranslationDebugCommandTest extends TestCase
|
||||
{
|
||||
$this->fs->mkdir($this->translationDir.'/customDir/translations');
|
||||
$this->fs->mkdir($this->translationDir.'/customDir/templates');
|
||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
|
||||
$kernel = $this->createMock(KernelInterface::class);
|
||||
$kernel->expects($this->once())
|
||||
->method('getBundle')
|
||||
->with($this->equalTo($this->translationDir.'/customDir'))
|
||||
@ -111,7 +116,7 @@ class TranslationDebugCommandTest extends TestCase
|
||||
public function testDebugInvalidDirectory()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
|
||||
$kernel = $this->createMock(KernelInterface::class);
|
||||
$kernel->expects($this->once())
|
||||
->method('getBundle')
|
||||
->with($this->equalTo('dir'))
|
||||
@ -136,16 +141,13 @@ class TranslationDebugCommandTest extends TestCase
|
||||
|
||||
private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null, array $transPaths = [], array $viewsPaths = []): CommandTester
|
||||
{
|
||||
$translator = $this->getMockBuilder(\Symfony\Component\Translation\Translator::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$translator = $this->createMock(Translator::class);
|
||||
$translator
|
||||
->expects($this->any())
|
||||
->method('getFallbackLocales')
|
||||
->willReturn(['en']);
|
||||
|
||||
$extractor = $this->getMockBuilder(\Symfony\Component\Translation\Extractor\ExtractorInterface::class)->getMock();
|
||||
$extractor = $this->createMock(ExtractorInterface::class);
|
||||
$extractor
|
||||
->expects($this->any())
|
||||
->method('extract')
|
||||
@ -155,7 +157,7 @@ class TranslationDebugCommandTest extends TestCase
|
||||
}
|
||||
);
|
||||
|
||||
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Reader\TranslationReader::class)->getMock();
|
||||
$loader = $this->createMock(TranslationReader::class);
|
||||
$loader
|
||||
->expects($this->any())
|
||||
->method('read')
|
||||
@ -170,7 +172,7 @@ class TranslationDebugCommandTest extends TestCase
|
||||
['foo', $this->getBundle($this->translationDir)],
|
||||
['test', $this->getBundle('test')],
|
||||
];
|
||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
|
||||
$kernel = $this->createMock(KernelInterface::class);
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundle')
|
||||
@ -198,7 +200,7 @@ class TranslationDebugCommandTest extends TestCase
|
||||
|
||||
private function getBundle($path)
|
||||
{
|
||||
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
|
||||
$bundle = $this->createMock(BundleInterface::class);
|
||||
$bundle
|
||||
->expects($this->any())
|
||||
->method('getPath')
|
||||
|
@ -17,7 +17,12 @@ use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpKernel;
|
||||
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Translation\Extractor\ExtractorInterface;
|
||||
use Symfony\Component\Translation\Reader\TranslationReader;
|
||||
use Symfony\Component\Translation\Translator;
|
||||
use Symfony\Component\Translation\Writer\TranslationWriter;
|
||||
|
||||
class TranslationUpdateCommandTest extends TestCase
|
||||
{
|
||||
@ -143,18 +148,15 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
/**
|
||||
* @return CommandTester
|
||||
*/
|
||||
private function createCommandTester($extractedMessages = [], $loadedMessages = [], HttpKernel\KernelInterface $kernel = null, array $transPaths = [], array $viewsPaths = [])
|
||||
private function createCommandTester($extractedMessages = [], $loadedMessages = [], KernelInterface $kernel = null, array $transPaths = [], array $viewsPaths = [])
|
||||
{
|
||||
$translator = $this->getMockBuilder(\Symfony\Component\Translation\Translator::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$translator = $this->createMock(Translator::class);
|
||||
$translator
|
||||
->expects($this->any())
|
||||
->method('getFallbackLocales')
|
||||
->willReturn(['en']);
|
||||
|
||||
$extractor = $this->getMockBuilder(\Symfony\Component\Translation\Extractor\ExtractorInterface::class)->getMock();
|
||||
$extractor = $this->createMock(ExtractorInterface::class);
|
||||
$extractor
|
||||
->expects($this->any())
|
||||
->method('extract')
|
||||
@ -166,7 +168,7 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
}
|
||||
);
|
||||
|
||||
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Reader\TranslationReader::class)->getMock();
|
||||
$loader = $this->createMock(TranslationReader::class);
|
||||
$loader
|
||||
->expects($this->any())
|
||||
->method('read')
|
||||
@ -176,7 +178,7 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
}
|
||||
);
|
||||
|
||||
$writer = $this->getMockBuilder(\Symfony\Component\Translation\Writer\TranslationWriter::class)->getMock();
|
||||
$writer = $this->createMock(TranslationWriter::class);
|
||||
$writer
|
||||
->expects($this->any())
|
||||
->method('getFormats')
|
||||
@ -189,7 +191,7 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
['foo', $this->getBundle($this->translationDir)],
|
||||
['test', $this->getBundle('test')],
|
||||
];
|
||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
|
||||
$kernel = $this->createMock(KernelInterface::class);
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundle')
|
||||
@ -217,7 +219,7 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
|
||||
private function getBundle($path)
|
||||
{
|
||||
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
|
||||
$bundle = $this->createMock(BundleInterface::class);
|
||||
$bundle
|
||||
->expects($this->any())
|
||||
->method('getPath')
|
||||
|
@ -73,20 +73,14 @@ EOF;
|
||||
|
||||
private function getKernelAwareApplicationMock()
|
||||
{
|
||||
$kernel = $this->getMockBuilder(KernelInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$kernel = $this->createMock(KernelInterface::class);
|
||||
$kernel
|
||||
->expects($this->once())
|
||||
->method('locateResource')
|
||||
->with('@AppBundle/Resources')
|
||||
->willReturn(sys_get_temp_dir().'/xliff-lint-test');
|
||||
|
||||
$application = $this->getMockBuilder(Application::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$application = $this->createMock(Application::class);
|
||||
$application
|
||||
->expects($this->once())
|
||||
->method('getKernel')
|
||||
|
@ -120,20 +120,14 @@ EOF;
|
||||
|
||||
private function getKernelAwareApplicationMock()
|
||||
{
|
||||
$kernel = $this->getMockBuilder(KernelInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$kernel = $this->createMock(KernelInterface::class);
|
||||
$kernel
|
||||
->expects($this->once())
|
||||
->method('locateResource')
|
||||
->with('@AppBundle/Resources')
|
||||
->willReturn(sys_get_temp_dir().'/yml-lint-test');
|
||||
|
||||
$application = $this->getMockBuilder(Application::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$application = $this->createMock(Application::class);
|
||||
$application
|
||||
->expects($this->once())
|
||||
->method('getKernel')
|
||||
|
@ -23,14 +23,18 @@ use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Tester\ApplicationTester;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
class ApplicationTest extends TestCase
|
||||
{
|
||||
public function testBundleInterfaceImplementation()
|
||||
{
|
||||
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
|
||||
$bundle = $this->createMock(BundleInterface::class);
|
||||
|
||||
$kernel = $this->getKernel([$bundle], true);
|
||||
|
||||
@ -126,7 +130,7 @@ class ApplicationTest extends TestCase
|
||||
$container->register(ThrowingCommand::class, ThrowingCommand::class);
|
||||
$container->setParameter('console.command.ids', [ThrowingCommand::class => ThrowingCommand::class]);
|
||||
|
||||
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
||||
$kernel = $this->createMock(KernelInterface::class);
|
||||
$kernel
|
||||
->method('getBundles')
|
||||
->willReturn([$this->createBundleMock(
|
||||
@ -154,7 +158,7 @@ class ApplicationTest extends TestCase
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('event_dispatcher', EventDispatcher::class);
|
||||
|
||||
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
||||
$kernel = $this->createMock(KernelInterface::class);
|
||||
$kernel
|
||||
->method('getBundles')
|
||||
->willReturn([$this->createBundleMock(
|
||||
@ -183,7 +187,7 @@ class ApplicationTest extends TestCase
|
||||
$container->register(ThrowingCommand::class, ThrowingCommand::class);
|
||||
$container->setParameter('console.command.ids', [ThrowingCommand::class => ThrowingCommand::class]);
|
||||
|
||||
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
||||
$kernel = $this->createMock(KernelInterface::class);
|
||||
$kernel->expects($this->once())->method('boot');
|
||||
$kernel
|
||||
->method('getBundles')
|
||||
@ -236,10 +240,10 @@ class ApplicationTest extends TestCase
|
||||
|
||||
private function getKernel(array $bundles, $useDispatcher = false)
|
||||
{
|
||||
$container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
|
||||
$container = $this->createMock(ContainerInterface::class);
|
||||
|
||||
if ($useDispatcher) {
|
||||
$dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
$dispatcher
|
||||
->expects($this->atLeastOnce())
|
||||
->method('dispatch')
|
||||
@ -264,7 +268,7 @@ class ApplicationTest extends TestCase
|
||||
->willReturnOnConsecutiveCalls([], [])
|
||||
;
|
||||
|
||||
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
||||
$kernel = $this->createMock(KernelInterface::class);
|
||||
$kernel->expects($this->once())->method('boot');
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
@ -282,7 +286,7 @@ class ApplicationTest extends TestCase
|
||||
|
||||
private function createBundleMock(array $commands)
|
||||
{
|
||||
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock();
|
||||
$bundle = $this->createMock(Bundle::class);
|
||||
$bundle
|
||||
->expects($this->once())
|
||||
->method('registerCommands')
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBag;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
||||
use Symfony\Component\Form\Form;
|
||||
@ -85,7 +86,7 @@ class AbstractControllerTest extends TestCase
|
||||
|
||||
public function testMissingParameterBag()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class);
|
||||
$this->expectException(ServiceNotFoundException::class);
|
||||
$this->expectExceptionMessage('TestAbstractController::getParameter()" method is missing a parameter bag');
|
||||
$container = new Container();
|
||||
|
||||
|
@ -31,7 +31,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest
|
||||
|
||||
$controller = $resolver->getController($request);
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::class, $controller[0]);
|
||||
$this->assertInstanceOf(ContainerAwareController::class, $controller[0]);
|
||||
$this->assertInstanceOf(ContainerInterface::class, $controller[0]->getContainer());
|
||||
$this->assertSame('testAction', $controller[1]);
|
||||
}
|
||||
@ -44,7 +44,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest
|
||||
|
||||
$controller = $resolver->getController($request);
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::class, $controller);
|
||||
$this->assertInstanceOf(ContainerAwareController::class, $controller);
|
||||
$this->assertInstanceOf(ContainerInterface::class, $controller->getContainer());
|
||||
}
|
||||
|
||||
@ -159,12 +159,12 @@ class ControllerResolverTest extends ContainerControllerResolverTest
|
||||
|
||||
protected function createMockParser()
|
||||
{
|
||||
return $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser::class)->disableOriginalConstructor()->getMock();
|
||||
return $this->createMock(ControllerNameParser::class);
|
||||
}
|
||||
|
||||
protected function createMockContainer()
|
||||
{
|
||||
return $this->getMockBuilder(ContainerInterface::class)->getMock();
|
||||
return $this->createMock(ContainerInterface::class);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class RedirectControllerTest extends TestCase
|
||||
|
||||
$request->attributes = new ParameterBag($attributes);
|
||||
|
||||
$router = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
|
||||
$router = $this->createMock(UrlGeneratorInterface::class);
|
||||
$router
|
||||
->expects($this->exactly(2))
|
||||
->method('generate')
|
||||
@ -304,7 +304,7 @@ class RedirectControllerTest extends TestCase
|
||||
|
||||
$request = $this->createRequestObject($scheme, $host, $port, $baseUrl, 'b.se=zaza&f[%2525][%26][%3D][p.c]=d');
|
||||
$request->attributes = new ParameterBag(['_route_params' => ['base2' => 'zaza']]);
|
||||
$urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
|
||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||
$urlGenerator->expects($this->exactly(2))
|
||||
->method('generate')
|
||||
->willReturn('/test?b.se=zaza&base2=zaza&f[%2525][%26][%3D][p.c]=d')
|
||||
@ -326,7 +326,7 @@ class RedirectControllerTest extends TestCase
|
||||
|
||||
$request = $this->createRequestObject($scheme, $host, $port, $baseUrl, 'b.se=zaza');
|
||||
$request->attributes = new ParameterBag(['_route_params' => ['b.se' => 'zouzou']]);
|
||||
$urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
|
||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||
$urlGenerator->expects($this->exactly(2))->method('generate')->willReturn('/test?b.se=zouzou')->with('/test', ['b.se' => 'zouzou'], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
$controller = new RedirectController($urlGenerator);
|
||||
|
@ -23,7 +23,7 @@ class TemplateControllerTest extends TestCase
|
||||
{
|
||||
public function testTwig()
|
||||
{
|
||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
||||
$twig = $this->createMock(Environment::class);
|
||||
$twig->expects($this->exactly(2))->method('render')->willReturn('bar');
|
||||
|
||||
$controller = new TemplateController($twig);
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\WorkflowGuardListenerPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
||||
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
@ -54,7 +55,7 @@ class WorkflowGuardListenerPassTest extends TestCase
|
||||
|
||||
public function testExceptionIfTheTokenStorageServiceIsNotPresent()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class);
|
||||
$this->expectException(LogicException::class);
|
||||
$this->expectExceptionMessage('The "security.token_storage" service is needed to be able to use the workflow guard listener.');
|
||||
$this->container->setParameter('workflow.has_guard_listeners', true);
|
||||
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);
|
||||
@ -66,7 +67,7 @@ class WorkflowGuardListenerPassTest extends TestCase
|
||||
|
||||
public function testExceptionIfTheAuthorizationCheckerServiceIsNotPresent()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class);
|
||||
$this->expectException(LogicException::class);
|
||||
$this->expectExceptionMessage('The "security.authorization_checker" service is needed to be able to use the workflow guard listener.');
|
||||
$this->container->setParameter('workflow.has_guard_listeners', true);
|
||||
$this->container->register('security.token_storage', TokenStorageInterface::class);
|
||||
@ -78,7 +79,7 @@ class WorkflowGuardListenerPassTest extends TestCase
|
||||
|
||||
public function testExceptionIfTheAuthenticationTrustResolverServiceIsNotPresent()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class);
|
||||
$this->expectException(LogicException::class);
|
||||
$this->expectExceptionMessage('The "security.authentication.trust_resolver" service is needed to be able to use the workflow guard listener.');
|
||||
$this->container->setParameter('workflow.has_guard_listeners', true);
|
||||
$this->container->register('security.token_storage', TokenStorageInterface::class);
|
||||
@ -90,7 +91,7 @@ class WorkflowGuardListenerPassTest extends TestCase
|
||||
|
||||
public function testExceptionIfTheRoleHierarchyServiceIsNotPresent()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class);
|
||||
$this->expectException(LogicException::class);
|
||||
$this->expectExceptionMessage('The "security.role_hierarchy" service is needed to be able to use the workflow guard listener.');
|
||||
$this->container->setParameter('workflow.has_guard_listeners', true);
|
||||
$this->container->register('security.token_storage', TokenStorageInterface::class);
|
||||
|
@ -30,6 +30,7 @@ use Symfony\Component\Cache\Adapter\ProxyAdapter;
|
||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
||||
use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\Compiler\ResolveInstanceofConditionalsPass;
|
||||
@ -41,12 +42,14 @@ use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Form\Form;
|
||||
use Symfony\Component\HttpClient\MockHttpClient;
|
||||
use Symfony\Component\HttpClient\RetryableHttpClient;
|
||||
use Symfony\Component\HttpClient\ScopingHttpClient;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\LoggerPass;
|
||||
use Symfony\Component\Messenger\Transport\TransportFactory;
|
||||
use Symfony\Component\PropertyAccess\PropertyAccessor;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
|
||||
use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
|
||||
@ -60,7 +63,10 @@ use Symfony\Component\Serializer\Serializer;
|
||||
use Symfony\Component\Translation\DependencyInjection\TranslatorPass;
|
||||
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
|
||||
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
|
||||
use Symfony\Component\Validator\Validation;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Symfony\Component\Workflow;
|
||||
use Symfony\Component\Workflow\Exception\InvalidDefinitionException;
|
||||
use Symfony\Component\Workflow\Metadata\InMemoryMetadataStore;
|
||||
use Symfony\Component\Workflow\WorkflowEvents;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
@ -317,21 +323,21 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
|
||||
public function testWorkflowAreValidated()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class);
|
||||
$this->expectException(InvalidDefinitionException::class);
|
||||
$this->expectExceptionMessage('A transition from a place/state must have an unique name. Multiple transitions named "go" from place/state "first" were found on StateMachine "my_workflow".');
|
||||
$this->createContainerFromFile('workflow_not_valid');
|
||||
}
|
||||
|
||||
public function testWorkflowCannotHaveBothSupportsAndSupportStrategy()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('"supports" and "support_strategy" cannot be used together.');
|
||||
$this->createContainerFromFile('workflow_with_support_and_support_strategy');
|
||||
}
|
||||
|
||||
public function testWorkflowShouldHaveOneOfSupportsAndSupportStrategy()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('"supports" or "support_strategy" should be configured.');
|
||||
$this->createContainerFromFile('workflow_without_support_and_support_strategy');
|
||||
}
|
||||
@ -525,7 +531,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
|
||||
public function testRouterRequiresResourceOption()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$container = $this->createContainer();
|
||||
$loader = new FrameworkExtension();
|
||||
$loader->load([['router' => true]], $container);
|
||||
@ -819,19 +825,19 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertSame($container->getParameter('kernel.cache_dir').'/translations', $options['cache_dir']);
|
||||
|
||||
$files = array_map('realpath', $options['resource_files']['en']);
|
||||
$ref = new \ReflectionClass(\Symfony\Component\Validator\Validation::class);
|
||||
$ref = new \ReflectionClass(Validation::class);
|
||||
$this->assertContains(
|
||||
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR),
|
||||
$files,
|
||||
'->registerTranslatorConfiguration() finds Validator translation resources'
|
||||
);
|
||||
$ref = new \ReflectionClass(\Symfony\Component\Form\Form::class);
|
||||
$ref = new \ReflectionClass(Form::class);
|
||||
$this->assertContains(
|
||||
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR),
|
||||
$files,
|
||||
'->registerTranslatorConfiguration() finds Form translation resources'
|
||||
);
|
||||
$ref = new \ReflectionClass(\Symfony\Component\Security\Core\Security::class);
|
||||
$ref = new \ReflectionClass(Security::class);
|
||||
$this->assertContains(
|
||||
strtr(\dirname($ref->getFileName()).'/Resources/translations/security.en.xlf', '/', \DIRECTORY_SEPARATOR),
|
||||
$files,
|
||||
@ -888,7 +894,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$container = $this->createContainerFromFile('full');
|
||||
$projectDir = $container->getParameter('kernel.project_dir');
|
||||
|
||||
$ref = new \ReflectionClass(\Symfony\Component\Form\Form::class);
|
||||
$ref = new \ReflectionClass(Form::class);
|
||||
$xmlMappings = [
|
||||
\dirname($ref->getFileName()).'/Resources/config/validation.xml',
|
||||
strtr($projectDir.'/config/validator/foo.xml', '/', \DIRECTORY_SEPARATOR),
|
||||
@ -922,7 +928,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
{
|
||||
$container = $this->createContainerFromFile('validation_annotations', ['kernel.charset' => 'UTF-8'], false);
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Component\Validator\Validator\ValidatorInterface::class, $container->get('validator.alias'));
|
||||
$this->assertInstanceOf(ValidatorInterface::class, $container->get('validator.alias'));
|
||||
}
|
||||
|
||||
public function testAnnotations()
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||
use Symfony\Component\Workflow\Exception\InvalidDefinitionException;
|
||||
|
||||
class PhpFrameworkExtensionTest extends FrameworkExtensionTest
|
||||
{
|
||||
@ -55,7 +56,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
|
||||
|
||||
public function testWorkflowValidationStateMachine()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class);
|
||||
$this->expectException(InvalidDefinitionException::class);
|
||||
$this->expectExceptionMessage('A transition from a place/state must have an unique name. Multiple transitions named "a_to_b" from place/state "a" were found on StateMachine "article".');
|
||||
$this->createContainerFromClosure(function ($container) {
|
||||
$container->loadFromExtension('framework', [
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||
use Symfony\Component\Finder\SplFileInfo;
|
||||
|
||||
/**
|
||||
@ -69,7 +70,7 @@ class CachePoolClearCommandTest extends AbstractWebTestCase
|
||||
|
||||
public function testClearUnexistingPool()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class);
|
||||
$this->expectException(ServiceNotFoundException::class);
|
||||
$this->expectExceptionMessage('You have requested a non-existent service "unknown_pool"');
|
||||
$this->createCommandTester()
|
||||
->execute(['pools' => ['unknown_pool']], ['decorated' => false]);
|
||||
|
@ -9,6 +9,7 @@ use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\LoaderResolverInterface;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RouteCompiler;
|
||||
|
||||
class DelegatingLoaderTest extends TestCase
|
||||
{
|
||||
@ -20,11 +21,9 @@ class DelegatingLoaderTest extends TestCase
|
||||
|
||||
public function testLoadDefaultOptions()
|
||||
{
|
||||
$loaderResolver = $this->getMockBuilder(LoaderResolverInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$loaderResolver = $this->createMock(LoaderResolverInterface::class);
|
||||
|
||||
$loader = $this->getMockBuilder(LoaderInterface::class)->getMock();
|
||||
$loader = $this->createMock(LoaderInterface::class);
|
||||
|
||||
$loaderResolver->expects($this->once())
|
||||
->method('resolve')
|
||||
@ -44,14 +43,14 @@ class DelegatingLoaderTest extends TestCase
|
||||
$this->assertCount(2, $loadedRouteCollection);
|
||||
|
||||
$expected = [
|
||||
'compiler_class' => 'Symfony\Component\Routing\RouteCompiler',
|
||||
'compiler_class' => RouteCompiler::class,
|
||||
'utf8' => false,
|
||||
];
|
||||
$this->assertSame($expected, $routeCollection->get('foo')->getOptions());
|
||||
$this->assertSame(['_locale' => 'fr|en'], $routeCollection->get('foo')->getRequirements());
|
||||
|
||||
$expected = [
|
||||
'compiler_class' => 'Symfony\Component\Routing\RouteCompiler',
|
||||
'compiler_class' => RouteCompiler::class,
|
||||
'foo' => 123,
|
||||
'utf8' => true,
|
||||
];
|
||||
|
@ -17,6 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Routing\Router;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
||||
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
@ -375,7 +376,7 @@ class RouterTest extends TestCase
|
||||
|
||||
public function testExceptionOnNonExistentParameterWithSfContainer()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException::class);
|
||||
$this->expectException(ParameterNotFoundException::class);
|
||||
$this->expectExceptionMessage('You have requested a non-existent parameter "nope".');
|
||||
$routes = new RouteCollection();
|
||||
|
||||
@ -504,7 +505,7 @@ class RouterTest extends TestCase
|
||||
|
||||
private function getServiceContainer(RouteCollection $routes): Container
|
||||
{
|
||||
$loader = $this->getMockBuilder(LoaderInterface::class)->getMock();
|
||||
$loader = $this->createMock(LoaderInterface::class);
|
||||
|
||||
$loader
|
||||
->expects($this->any())
|
||||
@ -525,7 +526,7 @@ class RouterTest extends TestCase
|
||||
|
||||
private function getPsr11ServiceContainer(RouteCollection $routes): ContainerInterface
|
||||
{
|
||||
$loader = $this->getMockBuilder(LoaderInterface::class)->getMock();
|
||||
$loader = $this->createMock(LoaderInterface::class);
|
||||
|
||||
$loader
|
||||
->expects($this->any())
|
||||
@ -533,7 +534,7 @@ class RouterTest extends TestCase
|
||||
->willReturn($routes)
|
||||
;
|
||||
|
||||
$sc = $this->getMockBuilder(ContainerInterface::class)->getMock();
|
||||
$sc = $this->createMock(ContainerInterface::class);
|
||||
|
||||
$sc
|
||||
->expects($this->once())
|
||||
@ -546,7 +547,7 @@ class RouterTest extends TestCase
|
||||
|
||||
private function getParameterBag(array $params = []): ContainerInterface
|
||||
{
|
||||
$bag = $this->getMockBuilder(ContainerInterface::class)->getMock();
|
||||
$bag = $this->createMock(ContainerInterface::class);
|
||||
$bag
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
|
@ -12,12 +12,14 @@
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Translation;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Translation\Translator;
|
||||
use Symfony\Component\Config\Resource\DirectoryResource;
|
||||
use Symfony\Component\Config\Resource\FileExistenceResource;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Translation\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Translation\Formatter\MessageFormatter;
|
||||
use Symfony\Component\Translation\Loader\LoaderInterface;
|
||||
use Symfony\Component\Translation\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Translation\MessageCatalogue;
|
||||
|
||||
@ -81,7 +83,7 @@ class TranslatorTest extends TestCase
|
||||
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));
|
||||
|
||||
// do it another time as the cache is primed now
|
||||
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
|
||||
$loader = $this->createMock(LoaderInterface::class);
|
||||
$loader->expects($this->never())->method('load');
|
||||
|
||||
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]);
|
||||
@ -101,7 +103,7 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Invalid "invalid locale" locale.');
|
||||
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
|
||||
$loader = $this->createMock(LoaderInterface::class);
|
||||
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', TranslatorWithInvalidLocale::class);
|
||||
|
||||
$translator->trans('foo');
|
||||
@ -124,7 +126,7 @@ class TranslatorTest extends TestCase
|
||||
|
||||
public function testGetDefaultLocale()
|
||||
{
|
||||
$container = $this->getMockBuilder(ContainerInterface::class)->getMock();
|
||||
$container = $this->createMock(\Psr\Container\ContainerInterface::class);
|
||||
$translator = new Translator($container, new MessageFormatter(), 'en');
|
||||
|
||||
$this->assertSame('en', $translator->getLocale());
|
||||
@ -132,9 +134,9 @@ class TranslatorTest extends TestCase
|
||||
|
||||
public function testInvalidOptions()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('The Translator does not support the following options: \'foo\'');
|
||||
$container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
|
||||
$container = $this->createMock(ContainerInterface::class);
|
||||
|
||||
(new Translator($container, new MessageFormatter(), 'en', [], ['foo' => 'bar']));
|
||||
}
|
||||
@ -144,7 +146,7 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$someCatalogue = $this->getCatalogue('some_locale', []);
|
||||
|
||||
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
|
||||
$loader = $this->createMock(LoaderInterface::class);
|
||||
|
||||
$loader->expects($this->exactly(2))
|
||||
->method('load')
|
||||
@ -262,7 +264,7 @@ class TranslatorTest extends TestCase
|
||||
|
||||
protected function getLoader()
|
||||
{
|
||||
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
|
||||
$loader = $this->createMock(LoaderInterface::class);
|
||||
$loader
|
||||
->expects($this->exactly(7))
|
||||
->method('load')
|
||||
@ -298,7 +300,7 @@ class TranslatorTest extends TestCase
|
||||
|
||||
protected function getContainer($loader)
|
||||
{
|
||||
$container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
|
||||
$container = $this->createMock(ContainerInterface::class);
|
||||
$container
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
@ -339,7 +341,7 @@ class TranslatorTest extends TestCase
|
||||
$translator->setFallbackLocales(['fr']);
|
||||
$translator->warmup($this->tmpDir);
|
||||
|
||||
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
|
||||
$loader = $this->createMock(LoaderInterface::class);
|
||||
$loader
|
||||
->expects($this->never())
|
||||
->method('load');
|
||||
|
@ -188,7 +188,7 @@ class SecurityDataCollectorTest extends TestCase
|
||||
public function testGetListeners()
|
||||
{
|
||||
$request = new Request();
|
||||
$event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
$event->setResponse($response = new Response());
|
||||
$listener = function ($e) use ($event, &$listenerCalled) {
|
||||
$listenerCalled += $e === $event;
|
||||
|
@ -29,15 +29,12 @@ class TraceableFirewallListenerTest extends TestCase
|
||||
public function testOnKernelRequestRecordsListeners()
|
||||
{
|
||||
$request = new Request();
|
||||
$event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
$event->setResponse($response = new Response());
|
||||
$listener = function ($e) use ($event, &$listenerCalled) {
|
||||
$listenerCalled += $e === $event;
|
||||
};
|
||||
$firewallMap = $this
|
||||
->getMockBuilder(FirewallMap::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$firewallMap = $this->createMock(FirewallMap::class);
|
||||
$firewallMap
|
||||
->expects($this->once())
|
||||
->method('getFirewallConfig')
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
|
||||
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
@ -597,7 +598,7 @@ abstract class CompleteConfigurationTest extends TestCase
|
||||
|
||||
public function testAccessDecisionManagerServiceAndStrategyCannotBeUsedAtTheSameTime()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('Invalid configuration for path "security.access_decision_manager": "strategy" and "service" cannot be used together.');
|
||||
$this->getContainer('access_decision_manager_service_and_strategy');
|
||||
}
|
||||
@ -615,14 +616,14 @@ abstract class CompleteConfigurationTest extends TestCase
|
||||
|
||||
public function testFirewallUndefinedUserProvider()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('Invalid firewall "main": user provider "undefined" not found.');
|
||||
$this->getContainer('firewall_undefined_provider');
|
||||
}
|
||||
|
||||
public function testFirewallListenerUndefinedProvider()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('Invalid firewall "main": user provider "undefined" not found.');
|
||||
$this->getContainer('listener_undefined_provider');
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\MainConfiguration;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
|
||||
class MainConfigurationTest extends TestCase
|
||||
@ -34,7 +35,7 @@ class MainConfigurationTest extends TestCase
|
||||
|
||||
public function testNoConfigForProvider()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$config = [
|
||||
'providers' => [
|
||||
'stub' => [],
|
||||
@ -48,7 +49,7 @@ class MainConfigurationTest extends TestCase
|
||||
|
||||
public function testManyConfigForProvider()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$config = [
|
||||
'providers' => [
|
||||
'stub' => [
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Security\Factory;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
@ -127,7 +128,7 @@ class AbstractFactoryTest extends TestCase
|
||||
|
||||
protected function callFactory($id, $config, $userProviderId, $defaultEntryPointId)
|
||||
{
|
||||
$factory = $this->getMockForAbstractClass(\Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory::class, []);
|
||||
$factory = $this->getMockForAbstractClass(AbstractFactory::class);
|
||||
|
||||
$factory
|
||||
->expects($this->once())
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Security\Facto
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\GuardAuthenticationFactory;
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
@ -42,7 +43,7 @@ class GuardAuthenticationFactoryTest extends TestCase
|
||||
*/
|
||||
public function testAddInvalidConfiguration(array $inputConfig)
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$factory = new GuardAuthenticationFactory();
|
||||
$nodeDefinition = new ArrayNodeDefinition('guard');
|
||||
$factory->addConfiguration($nodeDefinition);
|
||||
|
@ -44,7 +44,7 @@ class SecurityExtensionTest extends TestCase
|
||||
{
|
||||
public function testInvalidCheckPath()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('The check_path "/some_area/login_check" for login method "form_login" is not matched by the firewall pattern "/secured_area/.*".');
|
||||
$container = $this->getRawContainer();
|
||||
|
||||
@ -68,7 +68,7 @@ class SecurityExtensionTest extends TestCase
|
||||
|
||||
public function testFirewallWithoutAuthenticationListener()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('No authentication listener registered for firewall "some_firewall"');
|
||||
$container = $this->getRawContainer();
|
||||
|
||||
@ -89,7 +89,7 @@ class SecurityExtensionTest extends TestCase
|
||||
|
||||
public function testFirewallWithInvalidUserProvider()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('Unable to create definition for "security.user.provider.concrete.my_foo" user provider');
|
||||
$container = $this->getRawContainer();
|
||||
|
||||
@ -208,7 +208,7 @@ class SecurityExtensionTest extends TestCase
|
||||
|
||||
public function testMissingProviderForListener()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('Not configuring explicitly the provider for the "http_basic" listener on "ambiguous" firewall is ambiguous as there is more than one registered provider.');
|
||||
$container = $this->getRawContainer();
|
||||
$container->loadFromExtension('security', [
|
||||
|
@ -301,7 +301,7 @@ EOTXT
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessage('There are no configured encoders for the "security" extension.');
|
||||
$application = new ConsoleApplication();
|
||||
$application->add(new UserPasswordEncoderCommand($this->getMockBuilder(EncoderFactoryInterface::class)->getMock(), []));
|
||||
$application->add(new UserPasswordEncoderCommand($this->createMock(EncoderFactoryInterface::class), []));
|
||||
|
||||
$passwordEncoderCommand = $application->find('security:encode-password');
|
||||
|
||||
|
@ -30,7 +30,7 @@ class FirewallMapTest extends TestCase
|
||||
$request = new Request();
|
||||
|
||||
$map = [];
|
||||
$container = $this->getMockBuilder(Container::class)->getMock();
|
||||
$container = $this->createMock(Container::class);
|
||||
$container->expects($this->never())->method('get');
|
||||
|
||||
$firewallMap = new FirewallMap($container, $map);
|
||||
@ -46,7 +46,7 @@ class FirewallMapTest extends TestCase
|
||||
$request->attributes->set(self::ATTRIBUTE_FIREWALL_CONTEXT, 'foo');
|
||||
|
||||
$map = [];
|
||||
$container = $this->getMockBuilder(Container::class)->getMock();
|
||||
$container = $this->createMock(Container::class);
|
||||
$container->expects($this->never())->method('get');
|
||||
|
||||
$firewallMap = new FirewallMap($container, $map);
|
||||
@ -60,7 +60,7 @@ class FirewallMapTest extends TestCase
|
||||
{
|
||||
$request = new Request();
|
||||
|
||||
$firewallContext = $this->getMockBuilder(FirewallContext::class)->disableOriginalConstructor()->getMock();
|
||||
$firewallContext = $this->createMock(FirewallContext::class);
|
||||
|
||||
$firewallConfig = new FirewallConfig('main', 'user_checker');
|
||||
$firewallContext->expects($this->once())->method('getConfig')->willReturn($firewallConfig);
|
||||
@ -68,19 +68,19 @@ class FirewallMapTest extends TestCase
|
||||
$listener = function () {};
|
||||
$firewallContext->expects($this->once())->method('getListeners')->willReturn([$listener]);
|
||||
|
||||
$exceptionListener = $this->getMockBuilder(ExceptionListener::class)->disableOriginalConstructor()->getMock();
|
||||
$exceptionListener = $this->createMock(ExceptionListener::class);
|
||||
$firewallContext->expects($this->once())->method('getExceptionListener')->willReturn($exceptionListener);
|
||||
|
||||
$logoutListener = $this->getMockBuilder(LogoutListener::class)->disableOriginalConstructor()->getMock();
|
||||
$logoutListener = $this->createMock(LogoutListener::class);
|
||||
$firewallContext->expects($this->once())->method('getLogoutListener')->willReturn($logoutListener);
|
||||
|
||||
$matcher = $this->getMockBuilder(RequestMatcherInterface::class)->getMock();
|
||||
$matcher = $this->createMock(RequestMatcherInterface::class);
|
||||
$matcher->expects($this->once())
|
||||
->method('matches')
|
||||
->with($request)
|
||||
->willReturn(true);
|
||||
|
||||
$container = $this->getMockBuilder(Container::class)->getMock();
|
||||
$container = $this->createMock(Container::class);
|
||||
$container->expects($this->exactly(2))->method('get')->willReturn($firewallContext);
|
||||
|
||||
$firewallMap = new FirewallMap($container, ['security.firewall.map.context.foo' => $matcher]);
|
||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigLoaderPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
||||
|
||||
class TwigLoaderPassTest extends TestCase
|
||||
{
|
||||
@ -89,7 +90,7 @@ class TwigLoaderPassTest extends TestCase
|
||||
|
||||
public function testMapperPassWithZeroTaggedLoaders()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class);
|
||||
$this->expectException(LogicException::class);
|
||||
$this->pass->process($this->builder);
|
||||
}
|
||||
}
|
||||
|
@ -12,16 +12,18 @@
|
||||
namespace Symfony\Bundle\TwigBundle\Tests;
|
||||
|
||||
use Symfony\Bundle\TwigBundle\TemplateIterator;
|
||||
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
class TemplateIteratorTest extends TestCase
|
||||
{
|
||||
public function testGetIterator()
|
||||
{
|
||||
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
|
||||
$bundle = $this->createMock(BundleInterface::class);
|
||||
$bundle->expects($this->any())->method('getName')->willReturn('BarBundle');
|
||||
$bundle->expects($this->any())->method('getPath')->willReturn(__DIR__.'/Fixtures/templates/BarBundle');
|
||||
|
||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\Kernel::class)->disableOriginalConstructor()->getMock();
|
||||
$kernel = $this->createMock(Kernel::class);
|
||||
$kernel->expects($this->any())->method('getBundles')->willReturn([
|
||||
$bundle,
|
||||
]);
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController;
|
||||
use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler;
|
||||
use Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator;
|
||||
use Symfony\Bundle\WebProfilerBundle\Tests\Functional\WebProfilerBundleKernel;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@ -24,6 +25,7 @@ use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Profiler\Profile;
|
||||
use Symfony\Component\HttpKernel\Profiler\Profiler;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
use Twig\Loader\SourceContextLoaderInterface;
|
||||
@ -35,8 +37,8 @@ class ProfilerControllerTest extends WebTestCase
|
||||
$this->expectException(NotFoundHttpException::class);
|
||||
$this->expectExceptionMessage('The profiler must be enabled.');
|
||||
|
||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||
$twig = $this->createMock(Environment::class);
|
||||
|
||||
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
||||
$controller->homeAction();
|
||||
@ -111,8 +113,8 @@ class ProfilerControllerTest extends WebTestCase
|
||||
$this->expectException(NotFoundHttpException::class);
|
||||
$this->expectExceptionMessage('The profiler must be enabled.');
|
||||
|
||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||
$twig = $this->createMock(Environment::class);
|
||||
|
||||
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
||||
$controller->toolbarAction(Request::create('/_wdt/foo-token'), null);
|
||||
@ -123,12 +125,9 @@ class ProfilerControllerTest extends WebTestCase
|
||||
*/
|
||||
public function testToolbarActionWithEmptyToken($token)
|
||||
{
|
||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
||||
$profiler = $this
|
||||
->getMockBuilder(Profiler::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||
$twig = $this->createMock(Environment::class);
|
||||
$profiler = $this->createMock(Profiler::class);
|
||||
|
||||
$controller = new ProfilerController($urlGenerator, $profiler, $twig, []);
|
||||
|
||||
@ -150,12 +149,9 @@ class ProfilerControllerTest extends WebTestCase
|
||||
*/
|
||||
public function testOpeningDisallowedPaths($path, $isAllowed)
|
||||
{
|
||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
||||
$profiler = $this
|
||||
->getMockBuilder(Profiler::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||
$twig = $this->createMock(Environment::class);
|
||||
$profiler = $this->createMock(Profiler::class);
|
||||
|
||||
$controller = new ProfilerController($urlGenerator, $profiler, $twig, [], null, __DIR__.'/../..');
|
||||
|
||||
@ -186,11 +182,8 @@ class ProfilerControllerTest extends WebTestCase
|
||||
*/
|
||||
public function testReturns404onTokenNotFound($withCsp)
|
||||
{
|
||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
||||
$profiler = $this
|
||||
->getMockBuilder(Profiler::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$twig = $this->createMock(Environment::class);
|
||||
$profiler = $this->createMock(Profiler::class);
|
||||
|
||||
$profiler
|
||||
->expects($this->exactly(2))
|
||||
@ -214,8 +207,8 @@ class ProfilerControllerTest extends WebTestCase
|
||||
$this->expectException(NotFoundHttpException::class);
|
||||
$this->expectExceptionMessage('The profiler must be enabled.');
|
||||
|
||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||
$twig = $this->createMock(Environment::class);
|
||||
|
||||
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
||||
$controller->searchBarAction(Request::create('/_profiler/search_bar'));
|
||||
@ -240,11 +233,8 @@ class ProfilerControllerTest extends WebTestCase
|
||||
*/
|
||||
public function testSearchResultsAction($withCsp)
|
||||
{
|
||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
||||
$profiler = $this
|
||||
->getMockBuilder(Profiler::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$twig = $this->createMock(Environment::class);
|
||||
$profiler = $this->createMock(Profiler::class);
|
||||
|
||||
$controller = $this->createController($profiler, $twig, $withCsp);
|
||||
|
||||
@ -306,8 +296,8 @@ class ProfilerControllerTest extends WebTestCase
|
||||
$this->expectException(NotFoundHttpException::class);
|
||||
$this->expectExceptionMessage('The profiler must be enabled.');
|
||||
|
||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||
$twig = $this->createMock(Environment::class);
|
||||
|
||||
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
||||
$controller->searchBarAction(Request::create('/_profiler/search'));
|
||||
@ -345,8 +335,8 @@ class ProfilerControllerTest extends WebTestCase
|
||||
$this->expectException(NotFoundHttpException::class);
|
||||
$this->expectExceptionMessage('The profiler must be enabled.');
|
||||
|
||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||
$twig = $this->createMock(Environment::class);
|
||||
|
||||
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
||||
$controller->phpinfoAction(Request::create('/_profiler/phpinfo'));
|
||||
@ -464,10 +454,10 @@ class ProfilerControllerTest extends WebTestCase
|
||||
|
||||
private function createController($profiler, $twig, $withCSP, array $templates = []): ProfilerController
|
||||
{
|
||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||
|
||||
if ($withCSP) {
|
||||
$nonceGenerator = $this->getMockBuilder(\Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator::class)->getMock();
|
||||
$nonceGenerator = $this->createMock(NonceGenerator::class);
|
||||
$nonceGenerator->method('generate')->willReturn('dummy_nonce');
|
||||
|
||||
return new ProfilerController($urlGenerator, $profiler, $twig, $templates, new ContentSecurityPolicyHandler($nonceGenerator));
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\Csp;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler;
|
||||
use Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
@ -210,7 +211,7 @@ class ContentSecurityPolicyHandlerTest extends TestCase
|
||||
|
||||
private function mockNonceGenerator($value)
|
||||
{
|
||||
$generator = $this->getMockBuilder(\Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator::class)->getMock();
|
||||
$generator = $this->createMock(NonceGenerator::class);
|
||||
|
||||
$generator->expects($this->any())
|
||||
->method('generate')
|
||||
|
@ -52,7 +52,7 @@ class WebProfilerExtensionTest extends TestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
||||
$this->kernel = $this->createMock(KernelInterface::class);
|
||||
|
||||
$this->container = new ContainerBuilder();
|
||||
$this->container->register('error_handler.error_renderer.html', HtmlErrorRenderer::class)->setPublic(true);
|
||||
|
@ -16,9 +16,12 @@ use Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener;
|
||||
use Symfony\Component\HttpFoundation\HeaderBag;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Twig\Environment;
|
||||
|
||||
class WebDebugToolbarListenerTest extends TestCase
|
||||
{
|
||||
@ -310,7 +313,7 @@ class WebDebugToolbarListenerTest extends TestCase
|
||||
$request->headers = new HeaderBag();
|
||||
|
||||
if ($hasSession) {
|
||||
$session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\Session::class)->disableOriginalConstructor()->getMock();
|
||||
$session = $this->createMock(Session::class);
|
||||
$request->expects($this->any())
|
||||
->method('getSession')
|
||||
->willReturn($session);
|
||||
@ -321,7 +324,7 @@ class WebDebugToolbarListenerTest extends TestCase
|
||||
|
||||
protected function getTwigMock($render = 'WDT')
|
||||
{
|
||||
$templating = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
|
||||
$templating = $this->createMock(Environment::class);
|
||||
$templating->expects($this->any())
|
||||
->method('render')
|
||||
->willReturn($render);
|
||||
@ -331,11 +334,11 @@ class WebDebugToolbarListenerTest extends TestCase
|
||||
|
||||
protected function getUrlGeneratorMock()
|
||||
{
|
||||
return $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
|
||||
return $this->createMock(UrlGeneratorInterface::class);
|
||||
}
|
||||
|
||||
protected function getKernelMock()
|
||||
{
|
||||
return $this->getMockBuilder(\Symfony\Component\HttpKernel\Kernel::class)->disableOriginalConstructor()->getMock();
|
||||
return $this->createMock(Kernel::class);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,9 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\Profiler;
|
||||
|
||||
use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager;
|
||||
use Symfony\Bundle\WebProfilerBundle\Tests\TestCase;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Profiler\Profile;
|
||||
use Symfony\Component\HttpKernel\Profiler\Profiler;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
|
||||
@ -30,7 +32,7 @@ class TemplateManagerTest extends TestCase
|
||||
protected $twigEnvironment;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\HttpKernel\Profiler\Profiler
|
||||
* @var Profiler
|
||||
*/
|
||||
protected $profiler;
|
||||
|
||||
@ -56,7 +58,7 @@ class TemplateManagerTest extends TestCase
|
||||
|
||||
public function testGetNameOfInvalidTemplate()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class);
|
||||
$this->expectException(NotFoundHttpException::class);
|
||||
$this->templateManager->getName(new Profile('token'), 'notexistingpanel');
|
||||
}
|
||||
|
||||
@ -97,12 +99,12 @@ class TemplateManagerTest extends TestCase
|
||||
|
||||
protected function mockProfile()
|
||||
{
|
||||
return $this->getMockBuilder(Profile::class)->disableOriginalConstructor()->getMock();
|
||||
return $this->createMock(Profile::class);
|
||||
}
|
||||
|
||||
protected function mockTwigEnvironment()
|
||||
{
|
||||
$this->twigEnvironment = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
||||
$this->twigEnvironment = $this->createMock(Environment::class);
|
||||
|
||||
$loader = $this->createMock(LoaderInterface::class);
|
||||
$loader
|
||||
@ -117,9 +119,7 @@ class TemplateManagerTest extends TestCase
|
||||
|
||||
protected function mockProfiler()
|
||||
{
|
||||
$this->profiler = $this->getMockBuilder(\Symfony\Component\HttpKernel\Profiler\Profiler::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->profiler = $this->createMock(Profiler::class);
|
||||
|
||||
return $this->profiler;
|
||||
}
|
||||
|
@ -13,12 +13,14 @@ namespace Symfony\Component\Asset\Tests\Context;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Asset\Context\RequestStackContext;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
class RequestStackContextTest extends TestCase
|
||||
{
|
||||
public function testGetBasePathEmpty()
|
||||
{
|
||||
$requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
|
||||
$requestStack = $this->createMock(RequestStack::class);
|
||||
$requestStackContext = new RequestStackContext($requestStack);
|
||||
|
||||
$this->assertEmpty($requestStackContext->getBasePath());
|
||||
@ -28,10 +30,10 @@ class RequestStackContextTest extends TestCase
|
||||
{
|
||||
$testBasePath = 'test-path';
|
||||
|
||||
$request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
|
||||
$request = $this->createMock(Request::class);
|
||||
$request->method('getBasePath')
|
||||
->willReturn($testBasePath);
|
||||
$requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
|
||||
$requestStack = $this->createMock(RequestStack::class);
|
||||
$requestStack->method('getMasterRequest')
|
||||
->willReturn($request);
|
||||
|
||||
@ -42,7 +44,7 @@ class RequestStackContextTest extends TestCase
|
||||
|
||||
public function testIsSecureFalse()
|
||||
{
|
||||
$requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
|
||||
$requestStack = $this->createMock(RequestStack::class);
|
||||
$requestStackContext = new RequestStackContext($requestStack);
|
||||
|
||||
$this->assertFalse($requestStackContext->isSecure());
|
||||
@ -50,10 +52,10 @@ class RequestStackContextTest extends TestCase
|
||||
|
||||
public function testIsSecureTrue()
|
||||
{
|
||||
$request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
|
||||
$request = $this->createMock(Request::class);
|
||||
$request->method('isSecure')
|
||||
->willReturn(true);
|
||||
$requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
|
||||
$requestStack = $this->createMock(RequestStack::class);
|
||||
$requestStack->method('getMasterRequest')
|
||||
->willReturn($request);
|
||||
|
||||
@ -64,7 +66,7 @@ class RequestStackContextTest extends TestCase
|
||||
|
||||
public function testDefaultContext()
|
||||
{
|
||||
$requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
|
||||
$requestStack = $this->createMock(RequestStack::class);
|
||||
$requestStackContext = new RequestStackContext($requestStack, 'default-path', true);
|
||||
|
||||
$this->assertSame('default-path', $requestStackContext->getBasePath());
|
||||
|
@ -12,7 +12,10 @@
|
||||
namespace Symfony\Component\Asset\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Asset\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Asset\Exception\LogicException;
|
||||
use Symfony\Component\Asset\Package;
|
||||
use Symfony\Component\Asset\PackageInterface;
|
||||
use Symfony\Component\Asset\Packages;
|
||||
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
||||
|
||||
@ -21,8 +24,8 @@ class PackagesTest extends TestCase
|
||||
public function testGetterSetters()
|
||||
{
|
||||
$packages = new Packages();
|
||||
$packages->setDefaultPackage($default = $this->getMockBuilder(\Symfony\Component\Asset\PackageInterface::class)->getMock());
|
||||
$packages->addPackage('a', $a = $this->getMockBuilder(\Symfony\Component\Asset\PackageInterface::class)->getMock());
|
||||
$packages->setDefaultPackage($default = $this->createMock(PackageInterface::class));
|
||||
$packages->addPackage('a', $a = $this->createMock(PackageInterface::class));
|
||||
|
||||
$this->assertSame($default, $packages->getPackage());
|
||||
$this->assertSame($a, $packages->getPackage('a'));
|
||||
@ -57,14 +60,14 @@ class PackagesTest extends TestCase
|
||||
|
||||
public function testNoDefaultPackage()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Asset\Exception\LogicException::class);
|
||||
$this->expectException(LogicException::class);
|
||||
$packages = new Packages();
|
||||
$packages->getPackage();
|
||||
}
|
||||
|
||||
public function testUndefinedPackage()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Asset\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$packages = new Packages();
|
||||
$packages->getPackage('a');
|
||||
}
|
||||
|
@ -12,8 +12,10 @@
|
||||
namespace Symfony\Component\Asset\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Asset\Context\ContextInterface;
|
||||
use Symfony\Component\Asset\PathPackage;
|
||||
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
||||
use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;
|
||||
|
||||
class PathPackageTest extends TestCase
|
||||
{
|
||||
@ -77,7 +79,7 @@ class PathPackageTest extends TestCase
|
||||
|
||||
public function testVersionStrategyGivesAbsoluteURL()
|
||||
{
|
||||
$versionStrategy = $this->getMockBuilder(\Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface::class)->getMock();
|
||||
$versionStrategy = $this->createMock(VersionStrategyInterface::class);
|
||||
$versionStrategy->expects($this->any())
|
||||
->method('applyVersion')
|
||||
->willReturn('https://cdn.com/bar/main.css');
|
||||
@ -88,7 +90,7 @@ class PathPackageTest extends TestCase
|
||||
|
||||
private function getContext($basePath)
|
||||
{
|
||||
$context = $this->getMockBuilder(\Symfony\Component\Asset\Context\ContextInterface::class)->getMock();
|
||||
$context = $this->createMock(ContextInterface::class);
|
||||
$context->expects($this->any())->method('getBasePath')->willReturn($basePath);
|
||||
|
||||
return $context;
|
||||
|
@ -12,9 +12,13 @@
|
||||
namespace Symfony\Component\Asset\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Asset\Context\ContextInterface;
|
||||
use Symfony\Component\Asset\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Asset\Exception\LogicException;
|
||||
use Symfony\Component\Asset\UrlPackage;
|
||||
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
|
||||
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
||||
use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;
|
||||
|
||||
class UrlPackageTest extends TestCase
|
||||
{
|
||||
@ -86,7 +90,7 @@ class UrlPackageTest extends TestCase
|
||||
|
||||
public function testVersionStrategyGivesAbsoluteURL()
|
||||
{
|
||||
$versionStrategy = $this->getMockBuilder(\Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface::class)->getMock();
|
||||
$versionStrategy = $this->createMock(VersionStrategyInterface::class);
|
||||
$versionStrategy->expects($this->any())
|
||||
->method('applyVersion')
|
||||
->willReturn('https://cdn.com/bar/main.css');
|
||||
@ -97,7 +101,7 @@ class UrlPackageTest extends TestCase
|
||||
|
||||
public function testNoBaseUrls()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Asset\Exception\LogicException::class);
|
||||
$this->expectException(LogicException::class);
|
||||
new UrlPackage([], new EmptyVersionStrategy());
|
||||
}
|
||||
|
||||
@ -106,7 +110,7 @@ class UrlPackageTest extends TestCase
|
||||
*/
|
||||
public function testWrongBaseUrl($baseUrls)
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Asset\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
new UrlPackage($baseUrls, new EmptyVersionStrategy());
|
||||
}
|
||||
|
||||
@ -120,7 +124,7 @@ class UrlPackageTest extends TestCase
|
||||
|
||||
private function getContext($secure)
|
||||
{
|
||||
$context = $this->getMockBuilder(\Symfony\Component\Asset\Context\ContextInterface::class)->getMock();
|
||||
$context = $this->createMock(ContextInterface::class);
|
||||
$context->expects($this->any())->method('isSecure')->willReturn($secure);
|
||||
|
||||
return $context;
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\BrowserKit\Tests;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\BrowserKit\CookieJar;
|
||||
use Symfony\Component\BrowserKit\History;
|
||||
use Symfony\Component\BrowserKit\Request;
|
||||
use Symfony\Component\BrowserKit\Response;
|
||||
|
||||
class AbstractBrowserTest extends TestCase
|
||||
@ -837,7 +838,7 @@ class AbstractBrowserTest extends TestCase
|
||||
'NEW_SERVER_KEY' => 'new-server-key-value',
|
||||
]);
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Component\BrowserKit\Request::class, $client->getInternalRequest());
|
||||
$this->assertInstanceOf(Request::class, $client->getInternalRequest());
|
||||
}
|
||||
|
||||
public function testInternalRequestNull()
|
||||
|
@ -17,6 +17,7 @@ use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Cache\Adapter\ChainAdapter;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\CacheItem;
|
||||
use Symfony\Component\Cache\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Cache\Tests\Fixtures\ExternalAdapter;
|
||||
use Symfony\Component\Cache\Tests\Fixtures\PrunableAdapter;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
@ -44,14 +45,14 @@ class ChainAdapterTest extends AdapterTestCase
|
||||
|
||||
public function testEmptyAdaptersException()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('At least one adapter must be specified.');
|
||||
new ChainAdapter([]);
|
||||
}
|
||||
|
||||
public function testInvalidAdapterException()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('The class "stdClass" does not implement');
|
||||
new ChainAdapter([new \stdClass()]);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||
use Symfony\Component\Cache\Exception\InvalidArgumentException;
|
||||
|
||||
class MaxIdLengthAdapterTest extends TestCase
|
||||
{
|
||||
@ -68,7 +69,7 @@ class MaxIdLengthAdapterTest extends TestCase
|
||||
|
||||
public function testTooLongNamespace()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Namespace must be 26 chars max, 40 given ("----------------------------------------")');
|
||||
$this->getMockBuilder(MaxIdLengthAdapter::class)
|
||||
->setConstructorArgs([str_repeat('-', 40)])
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
|
||||
use Symfony\Component\Cache\Exception\CacheException;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
@ -106,7 +107,7 @@ class MemcachedAdapterTest extends AdapterTestCase
|
||||
|
||||
public function testOptionSerializer()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Cache\Exception\CacheException::class);
|
||||
$this->expectException(CacheException::class);
|
||||
$this->expectExceptionMessage('MemcachedAdapter: "serializer" option must be "php" or "igbinary".');
|
||||
if (!\Memcached::HAVE_JSON) {
|
||||
$this->markTestSkipped('Memcached::HAVE_JSON required');
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||
use Symfony\Component\Cache\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
@ -36,7 +37,7 @@ class RedisAdapterSentinelTest extends AbstractRedisAdapterTest
|
||||
|
||||
public function testInvalidDSNHasBothClusterAndSentinel()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Cannot use both "redis_cluster" and "redis_sentinel" at the same time:');
|
||||
$dsn = 'redis:?host[redis1]&host[redis2]&host[redis3]&redis_cluster=1&redis_sentinel=mymaster';
|
||||
RedisAdapter::createConnection($dsn);
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||
use Symfony\Component\Cache\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Cache\Traits\RedisProxy;
|
||||
|
||||
/**
|
||||
@ -70,7 +71,7 @@ class RedisAdapterTest extends AbstractRedisAdapterTest
|
||||
*/
|
||||
public function testFailedCreateConnection(string $dsn)
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Redis connection ');
|
||||
RedisAdapter::createConnection($dsn);
|
||||
}
|
||||
@ -89,7 +90,7 @@ class RedisAdapterTest extends AbstractRedisAdapterTest
|
||||
*/
|
||||
public function testInvalidCreateConnection(string $dsn)
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Invalid Redis DSN');
|
||||
RedisAdapter::createConnection($dsn);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||
use Symfony\Component\Cache\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Cache\Traits\RedisClusterProxy;
|
||||
|
||||
/**
|
||||
@ -46,7 +47,7 @@ class RedisClusterAdapterTest extends AbstractRedisAdapterTest
|
||||
*/
|
||||
public function testFailedCreateConnection(string $dsn)
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Redis connection ');
|
||||
RedisAdapter::createConnection($dsn);
|
||||
}
|
||||
|
@ -73,9 +73,7 @@ class TagAwareAdapterTest extends AdapterTestCase
|
||||
public function testKnownTagVersionsTtl()
|
||||
{
|
||||
$itemsPool = new FilesystemAdapter('', 10);
|
||||
$tagsPool = $this
|
||||
->getMockBuilder(AdapterInterface::class)
|
||||
->getMock();
|
||||
$tagsPool = $this->createMock(AdapterInterface::class);
|
||||
|
||||
$pool = new TagAwareAdapter($itemsPool, $tagsPool, 10);
|
||||
|
||||
@ -83,7 +81,7 @@ class TagAwareAdapterTest extends AdapterTestCase
|
||||
$item->tag(['baz']);
|
||||
$item->expiresAfter(100);
|
||||
|
||||
$tag = $this->getMockBuilder(CacheItemInterface::class)->getMock();
|
||||
$tag = $this->createMock(CacheItemInterface::class);
|
||||
$tag->expects(self::exactly(2))->method('get')->willReturn(10);
|
||||
|
||||
$tagsPool->expects(self::exactly(2))->method('getItems')->willReturn([
|
||||
|
@ -13,6 +13,8 @@ namespace Symfony\Component\Cache\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Cache\CacheItem;
|
||||
use Symfony\Component\Cache\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Cache\Exception\LogicException;
|
||||
use Symfony\Component\Cache\Tests\Fixtures\StringableTag;
|
||||
|
||||
class CacheItemTest extends TestCase
|
||||
@ -27,7 +29,7 @@ class CacheItemTest extends TestCase
|
||||
*/
|
||||
public function testInvalidKey($key)
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Cache key');
|
||||
CacheItem::validateKey($key);
|
||||
}
|
||||
@ -75,7 +77,7 @@ class CacheItemTest extends TestCase
|
||||
*/
|
||||
public function testInvalidTag($tag)
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Cache tag');
|
||||
$item = new CacheItem();
|
||||
$r = new \ReflectionProperty($item, 'isTaggable');
|
||||
@ -87,7 +89,7 @@ class CacheItemTest extends TestCase
|
||||
|
||||
public function testNonTaggableItem()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Cache\Exception\LogicException::class);
|
||||
$this->expectException(LogicException::class);
|
||||
$this->expectExceptionMessage('Cache item "foo" comes from a non tag-aware pool: you cannot tag it.');
|
||||
$item = new CacheItem();
|
||||
$r = new \ReflectionProperty($item, 'key');
|
||||
|
@ -17,6 +17,7 @@ use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
|
||||
use Symfony\Component\Cache\DependencyInjection\CachePoolPrunerPass;
|
||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class CachePoolPrunerPassTest extends TestCase
|
||||
@ -58,7 +59,7 @@ class CachePoolPrunerPassTest extends TestCase
|
||||
|
||||
public function testCompilerPassThrowsOnInvalidDefinitionClass()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Class "Symfony\Component\Cache\Tests\DependencyInjection\NotFound" used for service "pool.not-found" cannot be found.');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('console.command.cache_pool_prune')->addArgument([]);
|
||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
||||
use Symfony\Component\Config\Definition\ScalarNode;
|
||||
|
||||
class ArrayNodeTest extends TestCase
|
||||
@ -23,7 +24,7 @@ class ArrayNodeTest extends TestCase
|
||||
|
||||
public function testNormalizeThrowsExceptionWhenFalseIsNotAllowed()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class);
|
||||
$this->expectException(InvalidTypeException::class);
|
||||
$node = new ArrayNode('root');
|
||||
$node->normalize(false);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Definition\BooleanNode;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
||||
|
||||
class BooleanNodeTest extends TestCase
|
||||
{
|
||||
@ -51,7 +52,7 @@ class BooleanNodeTest extends TestCase
|
||||
*/
|
||||
public function testNormalizeThrowsExceptionOnInvalidValues($value)
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class);
|
||||
$this->expectException(InvalidTypeException::class);
|
||||
$node = new BooleanNode('test');
|
||||
$node->normalize($value);
|
||||
}
|
||||
|
@ -17,8 +17,10 @@ use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
||||
|
||||
class ArrayNodeDefinitionTest extends TestCase
|
||||
{
|
||||
@ -155,8 +157,8 @@ class ArrayNodeDefinitionTest extends TestCase
|
||||
;
|
||||
$node = $nodeDefinition->getNode();
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Definition\PrototypedArrayNode::class, $node);
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Definition\PrototypedArrayNode::class, $node->getPrototype());
|
||||
$this->assertInstanceOf(PrototypedArrayNode::class, $node);
|
||||
$this->assertInstanceOf(PrototypedArrayNode::class, $node->getPrototype());
|
||||
}
|
||||
|
||||
public function testEnabledNodeDefaults()
|
||||
@ -320,7 +322,7 @@ class ArrayNodeDefinitionTest extends TestCase
|
||||
|
||||
public function testCannotBeEmpty()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('The path "root" should have at least 1 element(s) defined.');
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$node
|
||||
|
@ -13,12 +13,13 @@ namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
|
||||
class BooleanNodeDefinitionTest extends TestCase
|
||||
{
|
||||
public function testCannotBeEmptyThrowsAnException()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException::class);
|
||||
$this->expectException(InvalidDefinitionException::class);
|
||||
$this->expectExceptionMessage('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.');
|
||||
$def = new BooleanNodeDefinition('foo');
|
||||
$def->cannotBeEmpty();
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Definition\Builder\ExprBuilder;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
|
||||
class ExprBuilderTest extends TestCase
|
||||
{
|
||||
@ -167,7 +168,7 @@ class ExprBuilderTest extends TestCase
|
||||
|
||||
public function testThenInvalid()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$test = $this->getTestBuilder()
|
||||
->ifString()
|
||||
->thenInvalid('Invalid value')
|
||||
|
@ -12,6 +12,8 @@
|
||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Definition\Builder\FloatNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\NodeBuilder as BaseNodeBuilder;
|
||||
use Symfony\Component\Config\Definition\Builder\VariableNodeDefinition as BaseVariableNodeDefinition;
|
||||
|
||||
@ -79,10 +81,10 @@ class NodeBuilderTest extends TestCase
|
||||
$builder = new BaseNodeBuilder();
|
||||
|
||||
$node = $builder->integerNode('foo')->min(3)->max(5);
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition::class, $node);
|
||||
$this->assertInstanceOf(IntegerNodeDefinition::class, $node);
|
||||
|
||||
$node = $builder->floatNode('bar')->min(3.0)->max(5.0);
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Definition\Builder\FloatNodeDefinition::class, $node);
|
||||
$this->assertInstanceOf(FloatNodeDefinition::class, $node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,8 @@ namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Definition\Builder\FloatNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
|
||||
class NumericNodeDefinitionTest extends TestCase
|
||||
{
|
||||
@ -35,7 +37,7 @@ class NumericNodeDefinitionTest extends TestCase
|
||||
|
||||
public function testIntegerMinAssertion()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('The value 4 is too small for path "foo". Should be greater than or equal to 5');
|
||||
$def = new IntegerNodeDefinition('foo');
|
||||
$def->min(5)->getNode()->finalize(4);
|
||||
@ -43,7 +45,7 @@ class NumericNodeDefinitionTest extends TestCase
|
||||
|
||||
public function testIntegerMaxAssertion()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('The value 4 is too big for path "foo". Should be less than or equal to 3');
|
||||
$def = new IntegerNodeDefinition('foo');
|
||||
$def->max(3)->getNode()->finalize(4);
|
||||
@ -58,7 +60,7 @@ class NumericNodeDefinitionTest extends TestCase
|
||||
|
||||
public function testFloatMinAssertion()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('The value 400 is too small for path "foo". Should be greater than or equal to 500');
|
||||
$def = new FloatNodeDefinition('foo');
|
||||
$def->min(5E2)->getNode()->finalize(4e2);
|
||||
@ -66,7 +68,7 @@ class NumericNodeDefinitionTest extends TestCase
|
||||
|
||||
public function testFloatMaxAssertion()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('The value 4.3 is too big for path "foo". Should be less than or equal to 0.3');
|
||||
$def = new FloatNodeDefinition('foo');
|
||||
$def->max(0.3)->getNode()->finalize(4.3);
|
||||
@ -81,7 +83,7 @@ class NumericNodeDefinitionTest extends TestCase
|
||||
|
||||
public function testCannotBeEmptyThrowsAnException()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException::class);
|
||||
$this->expectException(InvalidDefinitionException::class);
|
||||
$this->expectExceptionMessage('->cannotBeEmpty() is not applicable to NumericNodeDefinition.');
|
||||
$def = new IntegerNodeDefinition('foo');
|
||||
$def->cannotBeEmpty();
|
||||
|
@ -12,8 +12,14 @@
|
||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Definition\BaseNode;
|
||||
use Symfony\Component\Config\Definition\BooleanNode;
|
||||
use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Tests\Fixtures\BarNode;
|
||||
use Symfony\Component\Config\Tests\Fixtures\Builder\BarNodeDefinition;
|
||||
use Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder as CustomNodeBuilder;
|
||||
use Symfony\Component\Config\Tests\Fixtures\Builder\VariableNodeDefinition;
|
||||
|
||||
class TreeBuilderTest extends TestCase
|
||||
{
|
||||
@ -23,11 +29,11 @@ class TreeBuilderTest extends TestCase
|
||||
|
||||
$nodeBuilder = $builder->getRootNode()->children();
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder::class, $nodeBuilder);
|
||||
$this->assertInstanceOf(CustomNodeBuilder::class, $nodeBuilder);
|
||||
|
||||
$nodeBuilder = $nodeBuilder->arrayNode('deeper')->children();
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder::class, $nodeBuilder);
|
||||
$this->assertInstanceOf(CustomNodeBuilder::class, $nodeBuilder);
|
||||
}
|
||||
|
||||
public function testOverrideABuiltInNodeType()
|
||||
@ -36,7 +42,7 @@ class TreeBuilderTest extends TestCase
|
||||
|
||||
$definition = $builder->getRootNode()->children()->variableNode('variable');
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\Builder\VariableNodeDefinition::class, $definition);
|
||||
$this->assertInstanceOf(VariableNodeDefinition::class, $definition);
|
||||
}
|
||||
|
||||
public function testAddANodeType()
|
||||
@ -45,7 +51,7 @@ class TreeBuilderTest extends TestCase
|
||||
|
||||
$definition = $builder->getRootNode()->children()->barNode('variable');
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\Builder\BarNodeDefinition::class, $definition);
|
||||
$this->assertInstanceOf(BarNodeDefinition::class, $definition);
|
||||
}
|
||||
|
||||
public function testCreateABuiltInNodeTypeWithACustomNodeBuilder()
|
||||
@ -54,7 +60,7 @@ class TreeBuilderTest extends TestCase
|
||||
|
||||
$definition = $builder->getRootNode()->children()->booleanNode('boolean');
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition::class, $definition);
|
||||
$this->assertInstanceOf(BooleanNodeDefinition::class, $definition);
|
||||
}
|
||||
|
||||
public function testPrototypedArrayNodeUseTheCustomNodeBuilder()
|
||||
@ -64,7 +70,7 @@ class TreeBuilderTest extends TestCase
|
||||
$root = $builder->getRootNode();
|
||||
$root->prototype('bar')->end();
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\BarNode::class, $root->getNode(true)->getPrototype());
|
||||
$this->assertInstanceOf(BarNode::class, $root->getNode(true)->getPrototype());
|
||||
}
|
||||
|
||||
public function testAnExtendedNodeBuilderGetsPropagatedToTheChildren()
|
||||
@ -86,11 +92,11 @@ class TreeBuilderTest extends TestCase
|
||||
$node = $builder->buildTree();
|
||||
$children = $node->getChildren();
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Definition\BooleanNode::class, $children['foo']);
|
||||
$this->assertInstanceOf(BooleanNode::class, $children['foo']);
|
||||
|
||||
$childChildren = $children['child']->getChildren();
|
||||
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Definition\BooleanNode::class, $childChildren['foo']);
|
||||
$this->assertInstanceOf(BooleanNode::class, $childChildren['foo']);
|
||||
}
|
||||
|
||||
public function testDefinitionInfoGetsTransferredToNode()
|
||||
@ -147,14 +153,14 @@ class TreeBuilderTest extends TestCase
|
||||
$children = $node->getChildren();
|
||||
|
||||
$this->assertArrayHasKey('foo', $children);
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Definition\BaseNode::class, $children['foo']);
|
||||
$this->assertInstanceOf(BaseNode::class, $children['foo']);
|
||||
$this->assertSame('propagation.foo', $children['foo']->getPath());
|
||||
|
||||
$this->assertArrayHasKey('child', $children);
|
||||
$childChildren = $children['child']->getChildren();
|
||||
|
||||
$this->assertArrayHasKey('foo', $childChildren);
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Definition\BaseNode::class, $childChildren['foo']);
|
||||
$this->assertInstanceOf(BaseNode::class, $childChildren['foo']);
|
||||
$this->assertSame('propagation.child.foo', $childChildren['foo']->getPath());
|
||||
}
|
||||
|
||||
@ -178,14 +184,14 @@ class TreeBuilderTest extends TestCase
|
||||
$children = $node->getChildren();
|
||||
|
||||
$this->assertArrayHasKey('foo', $children);
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Definition\BaseNode::class, $children['foo']);
|
||||
$this->assertInstanceOf(BaseNode::class, $children['foo']);
|
||||
$this->assertSame('propagation/foo', $children['foo']->getPath());
|
||||
|
||||
$this->assertArrayHasKey('child', $children);
|
||||
$childChildren = $children['child']->getChildren();
|
||||
|
||||
$this->assertArrayHasKey('foo', $childChildren);
|
||||
$this->assertInstanceOf(\Symfony\Component\Config\Definition\BaseNode::class, $childChildren['foo']);
|
||||
$this->assertInstanceOf(BaseNode::class, $childChildren['foo']);
|
||||
$this->assertSame('propagation/child/foo', $childChildren['foo']->getPath());
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Definition\EnumNode;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
|
||||
class EnumNodeTest extends TestCase
|
||||
{
|
||||
@ -49,7 +50,7 @@ class EnumNodeTest extends TestCase
|
||||
|
||||
public function testFinalizeWithInvalidValue()
|
||||
{
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage('The value "foobar" is not allowed for path "foo". Permissible values: "foo", "bar"');
|
||||
$node = new EnumNode('foo', null, ['foo', 'bar']);
|
||||
$node->finalize('foobar');
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user