Use createMock() and use import instead of FQCN
This commit is contained in:
parent
484a95d8d1
commit
e7e61ee551
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Doctrine\Tests\DataCollector;
|
namespace Symfony\Bridge\Doctrine\Tests\DataCollector;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Logging\DebugStack;
|
||||||
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
||||||
use Doctrine\DBAL\Version;
|
use Doctrine\DBAL\Version;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
@ -236,7 +237,7 @@ EOTXT
|
|||||||
->method('getDatabasePlatform')
|
->method('getDatabasePlatform')
|
||||||
->willReturn(new MySqlPlatform());
|
->willReturn(new MySqlPlatform());
|
||||||
|
|
||||||
$registry = $this->getMockBuilder(ManagerRegistry::class)->getMock();
|
$registry = $this->createMock(ManagerRegistry::class);
|
||||||
$registry
|
$registry
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getConnectionNames')
|
->method('getConnectionNames')
|
||||||
@ -249,7 +250,7 @@ EOTXT
|
|||||||
->method('getConnection')
|
->method('getConnection')
|
||||||
->willReturn($connection);
|
->willReturn($connection);
|
||||||
|
|
||||||
$logger = $this->getMockBuilder(\Doctrine\DBAL\Logging\DebugStack::class)->getMock();
|
$logger = $this->createMock(DebugStack::class);
|
||||||
$logger->queries = $queries;
|
$logger->queries = $queries;
|
||||||
|
|
||||||
$collector = new DoctrineDataCollector($registry);
|
$collector = new DoctrineDataCollector($registry);
|
||||||
|
@ -14,12 +14,13 @@ namespace Symfony\Bridge\Doctrine\Tests\DataFixtures;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
|
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\ContainerAwareFixture;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\ContainerAwareFixture;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
class ContainerAwareLoaderTest extends TestCase
|
class ContainerAwareLoaderTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testShouldSetContainerOnContainerAwareFixture()
|
public function testShouldSetContainerOnContainerAwareFixture()
|
||||||
{
|
{
|
||||||
$container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
|
$container = $this->createMock(ContainerInterface::class);
|
||||||
$loader = new ContainerAwareLoader($container);
|
$loader = new ContainerAwareLoader($container);
|
||||||
$fixture = new ContainerAwareFixture();
|
$fixture = new ContainerAwareFixture();
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection;
|
namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||||
@ -22,7 +23,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
|||||||
class DoctrineExtensionTest extends TestCase
|
class DoctrineExtensionTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension
|
* @var AbstractDoctrineExtension
|
||||||
*/
|
*/
|
||||||
private $extension;
|
private $extension;
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ class DoctrineExtensionTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->extension = $this
|
$this->extension = $this
|
||||||
->getMockBuilder(\Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension::class)
|
->getMockBuilder(AbstractDoctrineExtension::class)
|
||||||
->setMethods([
|
->setMethods([
|
||||||
'getMappingResourceConfigDirectory',
|
'getMappingResourceConfigDirectory',
|
||||||
'getObjectManagerElementName',
|
'getObjectManagerElementName',
|
||||||
|
@ -75,19 +75,17 @@ class DoctrineChoiceLoaderTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->factory = $this->getMockBuilder(ChoiceListFactoryInterface::class)->getMock();
|
$this->factory = $this->createMock(ChoiceListFactoryInterface::class);
|
||||||
$this->om = $this->getMockBuilder(ObjectManager::class)->getMock();
|
$this->om = $this->createMock(ObjectManager::class);
|
||||||
$this->repository = $this->getMockBuilder(ObjectRepository::class)->getMock();
|
$this->repository = $this->createMock(ObjectRepository::class);
|
||||||
$this->class = 'stdClass';
|
$this->class = 'stdClass';
|
||||||
$this->idReader = $this->getMockBuilder(IdReader::class)
|
$this->idReader = $this->createMock(IdReader::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
$this->idReader->expects($this->any())
|
$this->idReader->expects($this->any())
|
||||||
->method('isSingleId')
|
->method('isSingleId')
|
||||||
->willReturn(true)
|
->willReturn(true)
|
||||||
;
|
;
|
||||||
|
|
||||||
$this->objectLoader = $this->getMockBuilder(EntityLoaderInterface::class)->getMock();
|
$this->objectLoader = $this->createMock(EntityLoaderInterface::class);
|
||||||
$this->obj1 = (object) ['name' => 'A'];
|
$this->obj1 = (object) ['name' => 'A'];
|
||||||
$this->obj2 = (object) ['name' => 'B'];
|
$this->obj2 = (object) ['name' => 'B'];
|
||||||
$this->obj3 = (object) ['name' => 'C'];
|
$this->obj3 = (object) ['name' => 'C'];
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\DataTransformer;
|
|||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
|
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
|
||||||
|
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
@ -64,7 +65,7 @@ class CollectionToArrayTransformerTest extends TestCase
|
|||||||
|
|
||||||
public function testTransformExpectsArrayOrCollection()
|
public function testTransformExpectsArrayOrCollection()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
|
$this->expectException(TransformationFailedException::class);
|
||||||
$this->transformer->transform('Foo');
|
$this->transformer->transform('Foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,21 +34,21 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
|||||||
$return = [];
|
$return = [];
|
||||||
|
|
||||||
// Simple field, not nullable
|
// Simple field, not nullable
|
||||||
$classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock();
|
$classMetadata = $this->createMock(ClassMetadata::class);
|
||||||
$classMetadata->fieldMappings['field'] = true;
|
$classMetadata->fieldMappings['field'] = true;
|
||||||
$classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(false);
|
$classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(false);
|
||||||
|
|
||||||
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
|
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
|
||||||
|
|
||||||
// Simple field, nullable
|
// Simple field, nullable
|
||||||
$classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock();
|
$classMetadata = $this->createMock(ClassMetadata::class);
|
||||||
$classMetadata->fieldMappings['field'] = true;
|
$classMetadata->fieldMappings['field'] = true;
|
||||||
$classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(true);
|
$classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(true);
|
||||||
|
|
||||||
$return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)];
|
$return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)];
|
||||||
|
|
||||||
// One-to-one, nullable (by default)
|
// 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);
|
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
|
||||||
|
|
||||||
$mapping = ['joinColumns' => [[]]];
|
$mapping = ['joinColumns' => [[]]];
|
||||||
@ -57,7 +57,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
|||||||
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
|
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
|
||||||
|
|
||||||
// One-to-one, nullable (explicit)
|
// 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);
|
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
|
||||||
|
|
||||||
$mapping = ['joinColumns' => [['nullable' => true]]];
|
$mapping = ['joinColumns' => [['nullable' => true]]];
|
||||||
@ -66,7 +66,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
|||||||
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
|
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
|
||||||
|
|
||||||
// One-to-one, not nullable
|
// 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);
|
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
|
||||||
|
|
||||||
$mapping = ['joinColumns' => [['nullable' => false]]];
|
$mapping = ['joinColumns' => [['nullable' => false]]];
|
||||||
@ -75,7 +75,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
|||||||
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
|
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
|
||||||
|
|
||||||
// One-to-many, no clue
|
// 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);
|
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(false);
|
||||||
|
|
||||||
$return[] = [$classMetadata, null];
|
$return[] = [$classMetadata, null];
|
||||||
@ -85,10 +85,10 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
|||||||
|
|
||||||
private function getGuesser(ClassMetadata $classMetadata)
|
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);
|
$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]);
|
$registry->expects($this->once())->method('getManagers')->willReturn([$em]);
|
||||||
|
|
||||||
return new DoctrineOrmTypeGuesser($registry);
|
return new DoctrineOrmTypeGuesser($registry);
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
|
|||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\FormEvent;
|
use Symfony\Component\Form\FormEvent;
|
||||||
use Symfony\Component\Form\FormEvents;
|
use Symfony\Component\Form\FormEvents;
|
||||||
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
|
|
||||||
class MergeDoctrineCollectionListenerTest extends TestCase
|
class MergeDoctrineCollectionListenerTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -32,7 +33,7 @@ class MergeDoctrineCollectionListenerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->collection = new ArrayCollection(['test']);
|
$this->collection = new ArrayCollection(['test']);
|
||||||
$this->dispatcher = new EventDispatcher();
|
$this->dispatcher = new EventDispatcher();
|
||||||
$this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
|
$this->factory = $this->createMock(FormFactoryInterface::class);
|
||||||
$this->form = $this->getBuilder()
|
$this->form = $this->getBuilder()
|
||||||
->getForm();
|
->getForm();
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
|||||||
|
|
||||||
protected function getExtensions()
|
protected function getExtensions()
|
||||||
{
|
{
|
||||||
$manager = $this->getMockBuilder(ManagerRegistry::class)->getMock();
|
$manager = $this->createMock(ManagerRegistry::class);
|
||||||
|
|
||||||
$manager->expects($this->any())
|
$manager->expects($this->any())
|
||||||
->method('getManager')
|
->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\SingleIntIdNoToStringEntity;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringCastableIdEntity;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringCastableIdEntity;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity;
|
||||||
|
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
|
||||||
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
|
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
|
||||||
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
|
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\Forms;
|
||||||
use Symfony\Component\Form\Tests\Extension\Core\Type\BaseTypeTest;
|
use Symfony\Component\Form\Tests\Extension\Core\Type\BaseTypeTest;
|
||||||
use Symfony\Component\Form\Tests\Extension\Core\Type\FormTypeTest;
|
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
|
class EntityTypeTest extends BaseTypeTest
|
||||||
{
|
{
|
||||||
@ -118,13 +123,13 @@ class EntityTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testClassOptionIsRequired()
|
public function testClassOptionIsRequired()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\OptionsResolver\Exception\MissingOptionsException::class);
|
$this->expectException(MissingOptionsException::class);
|
||||||
$this->factory->createNamed('name', static::TESTED_TYPE);
|
$this->factory->createNamed('name', static::TESTED_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidClassOption()
|
public function testInvalidClassOption()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Form\Exception\RuntimeException::class);
|
$this->expectException(RuntimeException::class);
|
||||||
$this->factory->createNamed('name', static::TESTED_TYPE, null, [
|
$this->factory->createNamed('name', static::TESTED_TYPE, null, [
|
||||||
'class' => 'foo',
|
'class' => 'foo',
|
||||||
]);
|
]);
|
||||||
@ -219,7 +224,7 @@ class EntityTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testConfigureQueryBuilderWithNonQueryBuilderAndNonClosure()
|
public function testConfigureQueryBuilderWithNonQueryBuilderAndNonClosure()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class);
|
$this->expectException(InvalidOptionsException::class);
|
||||||
$this->factory->createNamed('name', static::TESTED_TYPE, null, [
|
$this->factory->createNamed('name', static::TESTED_TYPE, null, [
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
@ -229,7 +234,7 @@ class EntityTypeTest extends BaseTypeTest
|
|||||||
|
|
||||||
public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder()
|
public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class);
|
$this->expectException(UnexpectedTypeException::class);
|
||||||
$field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [
|
$field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [
|
||||||
'em' => 'default',
|
'em' => 'default',
|
||||||
'class' => self::SINGLE_IDENT_CLASS,
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
@ -1242,7 +1247,7 @@ class EntityTypeTest extends BaseTypeTest
|
|||||||
$choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader');
|
$choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader');
|
||||||
$choiceLoader3 = $form->get('property3')->getConfig()->getOption('choice_loader');
|
$choiceLoader3 = $form->get('property3')->getConfig()->getOption('choice_loader');
|
||||||
|
|
||||||
$this->assertInstanceOf(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class, $choiceLoader1);
|
$this->assertInstanceOf(ChoiceLoaderInterface::class, $choiceLoader1);
|
||||||
$this->assertSame($choiceLoader1, $choiceLoader2);
|
$this->assertSame($choiceLoader1, $choiceLoader2);
|
||||||
$this->assertSame($choiceLoader1, $choiceLoader3);
|
$this->assertSame($choiceLoader1, $choiceLoader3);
|
||||||
}
|
}
|
||||||
@ -1302,14 +1307,14 @@ class EntityTypeTest extends BaseTypeTest
|
|||||||
$choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader');
|
$choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader');
|
||||||
$choiceLoader3 = $form->get('property3')->getConfig()->getOption('choice_loader');
|
$choiceLoader3 = $form->get('property3')->getConfig()->getOption('choice_loader');
|
||||||
|
|
||||||
$this->assertInstanceOf(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class, $choiceLoader1);
|
$this->assertInstanceOf(ChoiceLoaderInterface::class, $choiceLoader1);
|
||||||
$this->assertSame($choiceLoader1, $choiceLoader2);
|
$this->assertSame($choiceLoader1, $choiceLoader2);
|
||||||
$this->assertSame($choiceLoader1, $choiceLoader3);
|
$this->assertSame($choiceLoader1, $choiceLoader3);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createRegistryMock($name, $em)
|
protected function createRegistryMock($name, $em)
|
||||||
{
|
{
|
||||||
$registry = $this->getMockBuilder(ManagerRegistry::class)->getMock();
|
$registry = $this->createMock(ManagerRegistry::class);
|
||||||
$registry->expects($this->any())
|
$registry->expects($this->any())
|
||||||
->method('getManager')
|
->method('getManager')
|
||||||
->with($this->equalTo($name))
|
->with($this->equalTo($name))
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Bridge\Doctrine\Tests\Logger;
|
namespace Symfony\Bridge\Doctrine\Tests\Logger;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Bridge\Doctrine\Logger\DbalLogger;
|
use Symfony\Bridge\Doctrine\Logger\DbalLogger;
|
||||||
|
|
||||||
class DbalLoggerTest extends TestCase
|
class DbalLoggerTest extends TestCase
|
||||||
@ -21,7 +22,7 @@ class DbalLoggerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testLog($sql, $params, $logParams)
|
public function testLog($sql, $params, $logParams)
|
||||||
{
|
{
|
||||||
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
|
$logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$dbalLogger = $this
|
$dbalLogger = $this
|
||||||
->getMockBuilder(DbalLogger::class)
|
->getMockBuilder(DbalLogger::class)
|
||||||
@ -53,7 +54,7 @@ class DbalLoggerTest extends TestCase
|
|||||||
|
|
||||||
public function testLogNonUtf8()
|
public function testLogNonUtf8()
|
||||||
{
|
{
|
||||||
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
|
$logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$dbalLogger = $this
|
$dbalLogger = $this
|
||||||
->getMockBuilder(DbalLogger::class)
|
->getMockBuilder(DbalLogger::class)
|
||||||
@ -76,7 +77,7 @@ class DbalLoggerTest extends TestCase
|
|||||||
|
|
||||||
public function testLogNonUtf8Array()
|
public function testLogNonUtf8Array()
|
||||||
{
|
{
|
||||||
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
|
$logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$dbalLogger = $this
|
$dbalLogger = $this
|
||||||
->getMockBuilder(DbalLogger::class)
|
->getMockBuilder(DbalLogger::class)
|
||||||
@ -107,7 +108,7 @@ class DbalLoggerTest extends TestCase
|
|||||||
|
|
||||||
public function testLogLongString()
|
public function testLogLongString()
|
||||||
{
|
{
|
||||||
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
|
$logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$dbalLogger = $this
|
$dbalLogger = $this
|
||||||
->getMockBuilder(DbalLogger::class)
|
->getMockBuilder(DbalLogger::class)
|
||||||
@ -135,7 +136,7 @@ class DbalLoggerTest extends TestCase
|
|||||||
|
|
||||||
public function testLogUTF8LongString()
|
public function testLogUTF8LongString()
|
||||||
{
|
{
|
||||||
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
|
$logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$dbalLogger = $this
|
$dbalLogger = $this
|
||||||
->getMockBuilder(DbalLogger::class)
|
->getMockBuilder(DbalLogger::class)
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Doctrine\Tests\Security\User;
|
namespace Symfony\Bridge\Doctrine\Tests\Security\User;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
use Doctrine\ORM\Tools\SchemaTool;
|
use Doctrine\ORM\Tools\SchemaTool;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
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\Security\User\UserLoaderInterface;
|
||||||
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\User;
|
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\PasswordUpgraderInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
|
||||||
@ -71,9 +73,7 @@ class EntityUserProviderTest extends TestCase
|
|||||||
->with('user1')
|
->with('user1')
|
||||||
->willReturn($user);
|
->willReturn($user);
|
||||||
|
|
||||||
$em = $this->getMockBuilder(\Doctrine\ORM\EntityManager::class)
|
$em = $this->createMock(EntityManager::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
$em
|
$em
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getRepository')
|
->method('getRepository')
|
||||||
@ -125,7 +125,7 @@ class EntityUserProviderTest extends TestCase
|
|||||||
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
||||||
|
|
||||||
$user2 = new User(1, 2, 'user2');
|
$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');
|
$this->expectExceptionMessage('User with id {"id1":1,"id2":2} not found');
|
||||||
|
|
||||||
$provider->refreshUser($user2);
|
$provider->refreshUser($user2);
|
||||||
@ -155,7 +155,7 @@ class EntityUserProviderTest extends TestCase
|
|||||||
->method('loadUserByUsername')
|
->method('loadUserByUsername')
|
||||||
->with('name')
|
->with('name')
|
||||||
->willReturn(
|
->willReturn(
|
||||||
$this->getMockBuilder(UserInterface::class)->getMock()
|
$this->createMock(UserInterface::class)
|
||||||
);
|
);
|
||||||
|
|
||||||
$provider = new EntityUserProvider(
|
$provider = new EntityUserProvider(
|
||||||
@ -198,7 +198,7 @@ class EntityUserProviderTest extends TestCase
|
|||||||
|
|
||||||
private function getManager($em, $name = null)
|
private function getManager($em, $name = null)
|
||||||
{
|
{
|
||||||
$manager = $this->getMockBuilder(ManagerRegistry::class)->getMock();
|
$manager = $this->createMock(ManagerRegistry::class);
|
||||||
$manager->expects($this->any())
|
$manager->expects($this->any())
|
||||||
->method('getManager')
|
->method('getManager')
|
||||||
->with($this->equalTo($name))
|
->with($this->equalTo($name))
|
||||||
|
@ -22,6 +22,7 @@ use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
|||||||
use Symfony\Bridge\Doctrine\Test\TestRepositoryFactory;
|
use Symfony\Bridge\Doctrine\Test\TestRepositoryFactory;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2;
|
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\CompositeObjectNoToStringIdEntity;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNullableNameEntity;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNullableNameEntity;
|
||||||
@ -30,9 +31,12 @@ use Symfony\Bridge\Doctrine\Tests\Fixtures\Person;
|
|||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdStringWrapperNameEntity;
|
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\StringWrapper;
|
||||||
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\Type\StringWrapperType;
|
||||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
|
||||||
|
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,7 +71,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
|||||||
$config->setRepositoryFactory($this->repositoryFactory);
|
$config->setRepositoryFactory($this->repositoryFactory);
|
||||||
|
|
||||||
if (!Type::hasType('string_wrapper')) {
|
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);
|
$this->em = DoctrineTestHelper::createTestEntityManager($config);
|
||||||
@ -79,7 +83,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
|||||||
|
|
||||||
protected function createRegistryMock($em = null)
|
protected function createRegistryMock($em = null)
|
||||||
{
|
{
|
||||||
$registry = $this->getMockBuilder(ManagerRegistry::class)->getMock();
|
$registry = $this->createMock(ManagerRegistry::class);
|
||||||
$registry->expects($this->any())
|
$registry->expects($this->any())
|
||||||
->method('getManager')
|
->method('getManager')
|
||||||
->with($this->equalTo(self::EM_NAME))
|
->with($this->equalTo(self::EM_NAME))
|
||||||
@ -100,15 +104,13 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
|||||||
|
|
||||||
protected function createEntityManagerMock($repositoryMock)
|
protected function createEntityManagerMock($repositoryMock)
|
||||||
{
|
{
|
||||||
$em = $this->getMockBuilder(ObjectManager::class)
|
$em = $this->createMock(ObjectManager::class);
|
||||||
->getMock()
|
|
||||||
;
|
|
||||||
$em->expects($this->any())
|
$em->expects($this->any())
|
||||||
->method('getRepository')
|
->method('getRepository')
|
||||||
->willReturn($repositoryMock)
|
->willReturn($repositoryMock)
|
||||||
;
|
;
|
||||||
|
|
||||||
$classMetadata = $this->getMockBuilder(ClassMetadata::class)->getMock();
|
$classMetadata = $this->createMock(ClassMetadata::class);
|
||||||
$classMetadata
|
$classMetadata
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('hasField')
|
->method('hasField')
|
||||||
@ -137,17 +139,17 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
|||||||
{
|
{
|
||||||
$schemaTool = new SchemaTool($em);
|
$schemaTool = new SchemaTool($em);
|
||||||
$schemaTool->createSchema([
|
$schemaTool->createSchema([
|
||||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity'),
|
$em->getClassMetadata(SingleIntIdEntity::class),
|
||||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity'),
|
$em->getClassMetadata(SingleIntIdNoToStringEntity::class),
|
||||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity'),
|
$em->getClassMetadata(DoubleNameEntity::class),
|
||||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNullableNameEntity'),
|
$em->getClassMetadata(DoubleNullableNameEntity::class),
|
||||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity'),
|
$em->getClassMetadata(CompositeIntIdEntity::class),
|
||||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity'),
|
$em->getClassMetadata(AssociationEntity::class),
|
||||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2'),
|
$em->getClassMetadata(AssociationEntity2::class),
|
||||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\Person'),
|
$em->getClassMetadata(Person::class),
|
||||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\Employee'),
|
$em->getClassMetadata(Employee::class),
|
||||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity'),
|
$em->getClassMetadata(CompositeObjectNoToStringIdEntity::class),
|
||||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdStringWrapperNameEntity'),
|
$em->getClassMetadata(SingleIntIdStringWrapperNameEntity::class),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +271,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
|||||||
|
|
||||||
public function testAllConfiguredFieldsAreCheckedOfBeingMappedByDoctrineWithIgnoreNullEnabled()
|
public function testAllConfiguredFieldsAreCheckedOfBeingMappedByDoctrineWithIgnoreNullEnabled()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
|
$this->expectException(ConstraintDefinitionException::class);
|
||||||
$constraint = new UniqueEntity([
|
$constraint = new UniqueEntity([
|
||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
'fields' => ['name', 'name2'],
|
'fields' => ['name', 'name2'],
|
||||||
@ -540,7 +542,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
|||||||
public function testValidateUniquenessWithArrayValue()
|
public function testValidateUniquenessWithArrayValue()
|
||||||
{
|
{
|
||||||
$repository = $this->createRepositoryMock();
|
$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([
|
$constraint = new UniqueEntity([
|
||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
@ -578,7 +580,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
|||||||
|
|
||||||
public function testDedicatedEntityManagerNullObject()
|
public function testDedicatedEntityManagerNullObject()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
|
$this->expectException(ConstraintDefinitionException::class);
|
||||||
$this->expectExceptionMessage('Object manager "foo" does not exist.');
|
$this->expectExceptionMessage('Object manager "foo" does not exist.');
|
||||||
$constraint = new UniqueEntity([
|
$constraint = new UniqueEntity([
|
||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
@ -598,7 +600,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
|||||||
|
|
||||||
public function testEntityManagerNullObject()
|
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"');
|
$this->expectExceptionMessage('Unable to find the object manager associated with an entity of class "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity"');
|
||||||
$constraint = new UniqueEntity([
|
$constraint = new UniqueEntity([
|
||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
@ -650,7 +652,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
'fields' => ['name'],
|
'fields' => ['name'],
|
||||||
'em' => self::EM_NAME,
|
'em' => self::EM_NAME,
|
||||||
'entityClass' => 'Symfony\Bridge\Doctrine\Tests\Fixtures\Person',
|
'entityClass' => Person::class,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$entity1 = new Person(1, 'Foo');
|
$entity1 = new Person(1, 'Foo');
|
||||||
@ -680,13 +682,13 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
|||||||
|
|
||||||
public function testInvalidateRepositoryForInheritance()
|
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".');
|
$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([
|
$constraint = new UniqueEntity([
|
||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
'fields' => ['name'],
|
'fields' => ['name'],
|
||||||
'em' => self::EM_NAME,
|
'em' => self::EM_NAME,
|
||||||
'entityClass' => 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity',
|
'entityClass' => SingleStringIdEntity::class,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$entity = new Person(1, 'Foo');
|
$entity = new Person(1, 'Foo');
|
||||||
|
@ -13,12 +13,15 @@ namespace Symfony\Bridge\Monolog\Tests\Handler;
|
|||||||
|
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter;
|
||||||
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
|
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\ConsoleEvents;
|
use Symfony\Component\Console\ConsoleEvents;
|
||||||
use Symfony\Component\Console\Event\ConsoleCommandEvent;
|
use Symfony\Component\Console\Event\ConsoleCommandEvent;
|
||||||
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\BufferedOutput;
|
use Symfony\Component\Console\Output\BufferedOutput;
|
||||||
|
use Symfony\Component\Console\Output\Output;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
|
||||||
@ -46,7 +49,7 @@ class ConsoleHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = [])
|
public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = [])
|
||||||
{
|
{
|
||||||
$output = $this->getMockBuilder(OutputInterface::class)->getMock();
|
$output = $this->createMock(OutputInterface::class);
|
||||||
$output
|
$output
|
||||||
->expects($this->atLeastOnce())
|
->expects($this->atLeastOnce())
|
||||||
->method('getVerbosity')
|
->method('getVerbosity')
|
||||||
@ -61,7 +64,7 @@ class ConsoleHandlerTest extends TestCase
|
|||||||
$levelName = Logger::getLevelName($level);
|
$levelName = Logger::getLevelName($level);
|
||||||
$levelName = sprintf('%-9s', $levelName);
|
$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);
|
$realOutput->setVerbosity($verbosity);
|
||||||
if ($realOutput->isDebug()) {
|
if ($realOutput->isDebug()) {
|
||||||
$log = "16:21:54 $levelName [app] My info message\n";
|
$log = "16:21:54 $levelName [app] My info message\n";
|
||||||
@ -110,7 +113,7 @@ class ConsoleHandlerTest extends TestCase
|
|||||||
|
|
||||||
public function testVerbosityChanged()
|
public function testVerbosityChanged()
|
||||||
{
|
{
|
||||||
$output = $this->getMockBuilder(OutputInterface::class)->getMock();
|
$output = $this->createMock(OutputInterface::class);
|
||||||
$output
|
$output
|
||||||
->expects($this->exactly(2))
|
->expects($this->exactly(2))
|
||||||
->method('getVerbosity')
|
->method('getVerbosity')
|
||||||
@ -131,14 +134,15 @@ class ConsoleHandlerTest extends TestCase
|
|||||||
public function testGetFormatter()
|
public function testGetFormatter()
|
||||||
{
|
{
|
||||||
$handler = new ConsoleHandler();
|
$handler = new ConsoleHandler();
|
||||||
$this->assertInstanceOf(\Symfony\Bridge\Monolog\Formatter\ConsoleFormatter::class, $handler->getFormatter(),
|
$this->assertInstanceOf(
|
||||||
'-getFormatter returns ConsoleFormatter by default'
|
ConsoleFormatter::class, $handler->getFormatter(),
|
||||||
|
'->getFormatter returns ConsoleFormatter by default'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWritingAndFormatting()
|
public function testWritingAndFormatting()
|
||||||
{
|
{
|
||||||
$output = $this->getMockBuilder(OutputInterface::class)->getMock();
|
$output = $this->createMock(OutputInterface::class);
|
||||||
$output
|
$output
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getVerbosity')
|
->method('getVerbosity')
|
||||||
@ -193,12 +197,12 @@ class ConsoleHandlerTest extends TestCase
|
|||||||
$logger->info('After terminate message.');
|
$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);
|
$dispatcher->dispatch($event, ConsoleEvents::COMMAND);
|
||||||
$this->assertStringContainsString('Before command message.', $out = $output->fetch());
|
$this->assertStringContainsString('Before command message.', $out = $output->fetch());
|
||||||
$this->assertStringContainsString('After command message.', $out);
|
$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);
|
$dispatcher->dispatch($event, ConsoleEvents::TERMINATE);
|
||||||
$this->assertStringContainsString('Before terminate message.', $out = $output->fetch());
|
$this->assertStringContainsString('Before terminate message.', $out = $output->fetch());
|
||||||
$this->assertStringContainsString('After terminate message.', $out);
|
$this->assertStringContainsString('After terminate message.', $out);
|
||||||
|
@ -44,7 +44,7 @@ class ServerLogHandlerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$handler = new ServerLogHandler('tcp://127.0.0.1:9999');
|
$handler = new ServerLogHandler('tcp://127.0.0.1:9999');
|
||||||
$this->assertInstanceOf(VarDumperFormatter::class, $handler->getFormatter(),
|
$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()
|
public function testGetLogsWithDebugProcessor3()
|
||||||
{
|
{
|
||||||
$request = new Request();
|
$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('getLogs')->with($request);
|
||||||
$processor->expects($this->once())->method('countErrors')->with($request);
|
$processor->expects($this->once())->method('countErrors')->with($request);
|
||||||
|
|
||||||
|
@ -61,12 +61,12 @@ class ConsoleCommandProcessorTest extends TestCase
|
|||||||
|
|
||||||
private function getConsoleEvent(): ConsoleEvent
|
private function getConsoleEvent(): ConsoleEvent
|
||||||
{
|
{
|
||||||
$input = $this->getMockBuilder(InputInterface::class)->getMock();
|
$input = $this->createMock(InputInterface::class);
|
||||||
$input->method('getArguments')->willReturn(self::TEST_ARGUMENTS);
|
$input->method('getArguments')->willReturn(self::TEST_ARGUMENTS);
|
||||||
$input->method('getOptions')->willReturn(self::TEST_OPTIONS);
|
$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);
|
$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('getCommand')->willReturn($command);
|
||||||
$consoleEvent->method('getInput')->willReturn($input);
|
$consoleEvent->method('getInput')->willReturn($input);
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ class RouteProcessorTest extends TestCase
|
|||||||
|
|
||||||
private function mockRequest(array $attributes): Request
|
private function mockRequest(array $attributes): Request
|
||||||
{
|
{
|
||||||
$request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
|
$request = $this->createMock(Request::class);
|
||||||
$request->attributes = new ParameterBag($attributes);
|
$request->attributes = new ParameterBag($attributes);
|
||||||
|
|
||||||
return $request;
|
return $request;
|
||||||
|
@ -26,7 +26,7 @@ class TokenProcessorTest extends TestCase
|
|||||||
public function testProcessor()
|
public function testProcessor()
|
||||||
{
|
{
|
||||||
$token = new UsernamePasswordToken('user', 'password', 'provider', ['ROLE_USER']);
|
$token = new UsernamePasswordToken('user', 'password', 'provider', ['ROLE_USER']);
|
||||||
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock();
|
$tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||||
$tokenStorage->method('getToken')->willReturn($token);
|
$tokenStorage->method('getToken')->willReturn($token);
|
||||||
|
|
||||||
$processor = new TokenProcessor($tokenStorage);
|
$processor = new TokenProcessor($tokenStorage);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\Dumper;
|
namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\Dumper;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use ProxyManager\Proxy\LazyLoadingInterface;
|
||||||
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
|
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
||||||
@ -46,7 +47,7 @@ class PhpDumperTest extends TestCase
|
|||||||
|
|
||||||
$proxy = $container->get('foo');
|
$proxy = $container->get('foo');
|
||||||
$this->assertInstanceOf(\stdClass::class, $proxy);
|
$this->assertInstanceOf(\stdClass::class, $proxy);
|
||||||
$this->assertInstanceOf(\ProxyManager\Proxy\LazyLoadingInterface::class, $proxy);
|
$this->assertInstanceOf(LazyLoadingInterface::class, $proxy);
|
||||||
$this->assertSame($proxy, $container->get('foo'));
|
$this->assertSame($proxy, $container->get('foo'));
|
||||||
|
|
||||||
$this->assertFalse($proxy->isProxyInitialized());
|
$this->assertFalse($proxy->isProxyInitialized());
|
||||||
|
@ -12,7 +12,10 @@
|
|||||||
namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\Instantiator;
|
namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\Instantiator;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use ProxyManager\Proxy\LazyLoadingInterface;
|
||||||
|
use ProxyManager\Proxy\ValueHolderInterface;
|
||||||
use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
|
use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,17 +41,17 @@ class RuntimeInstantiatorTest extends TestCase
|
|||||||
public function testInstantiateProxy()
|
public function testInstantiateProxy()
|
||||||
{
|
{
|
||||||
$instance = new \stdClass();
|
$instance = new \stdClass();
|
||||||
$container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
|
$container = $this->createMock(ContainerInterface::class);
|
||||||
$definition = new Definition('stdClass');
|
$definition = new Definition('stdClass');
|
||||||
$instantiator = function () use ($instance) {
|
$instantiator = function () use ($instance) {
|
||||||
return $instance;
|
return $instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* @var $proxy \ProxyManager\Proxy\LazyLoadingInterface|\ProxyManager\Proxy\ValueHolderInterface */
|
/* @var $proxy LazyLoadingInterface|ValueHolderInterface */
|
||||||
$proxy = $this->instantiator->instantiateProxy($container, $definition, 'foo', $instantiator);
|
$proxy = $this->instantiator->instantiateProxy($container, $definition, 'foo', $instantiator);
|
||||||
|
|
||||||
$this->assertInstanceOf(\ProxyManager\Proxy\LazyLoadingInterface::class, $proxy);
|
$this->assertInstanceOf(LazyLoadingInterface::class, $proxy);
|
||||||
$this->assertInstanceOf(\ProxyManager\Proxy\ValueHolderInterface::class, $proxy);
|
$this->assertInstanceOf(ValueHolderInterface::class, $proxy);
|
||||||
$this->assertFalse($proxy->isProxyInitialized());
|
$this->assertFalse($proxy->isProxyInitialized());
|
||||||
|
|
||||||
$proxy->initializeProxy();
|
$proxy->initializeProxy();
|
||||||
|
@ -5,8 +5,12 @@ namespace Symfony\Bridge\Twig\Tests;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bridge\Twig\AppVariable;
|
use Symfony\Bridge\Twig\AppVariable;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
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
|
class AppVariableTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -50,7 +54,7 @@ class AppVariableTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetSession()
|
public function testGetSession()
|
||||||
{
|
{
|
||||||
$request = $this->getMockBuilder(Request::class)->getMock();
|
$request = $this->createMock(Request::class);
|
||||||
$request->method('hasSession')->willReturn(true);
|
$request->method('hasSession')->willReturn(true);
|
||||||
$request->method('getSession')->willReturn($session = new Session());
|
$request->method('getSession')->willReturn($session = new Session());
|
||||||
|
|
||||||
@ -75,10 +79,10 @@ class AppVariableTest extends TestCase
|
|||||||
|
|
||||||
public function testGetToken()
|
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);
|
$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);
|
$tokenStorage->method('getToken')->willReturn($token);
|
||||||
|
|
||||||
$this->assertEquals($token, $this->appVariable->getToken());
|
$this->assertEquals($token, $this->appVariable->getToken());
|
||||||
@ -86,7 +90,7 @@ class AppVariableTest extends TestCase
|
|||||||
|
|
||||||
public function testGetUser()
|
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());
|
$this->assertEquals($user, $this->appVariable->getUser());
|
||||||
}
|
}
|
||||||
@ -100,7 +104,7 @@ class AppVariableTest extends TestCase
|
|||||||
|
|
||||||
public function testGetTokenWithNoToken()
|
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->appVariable->setTokenStorage($tokenStorage);
|
||||||
|
|
||||||
$this->assertNull($this->appVariable->getToken());
|
$this->assertNull($this->appVariable->getToken());
|
||||||
@ -108,7 +112,7 @@ class AppVariableTest extends TestCase
|
|||||||
|
|
||||||
public function testGetUserWithNoToken()
|
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->appVariable->setTokenStorage($tokenStorage);
|
||||||
|
|
||||||
$this->assertNull($this->appVariable->getUser());
|
$this->assertNull($this->appVariable->getUser());
|
||||||
@ -224,7 +228,7 @@ class AppVariableTest extends TestCase
|
|||||||
|
|
||||||
protected function setRequestStack($request)
|
protected function setRequestStack($request)
|
||||||
{
|
{
|
||||||
$requestStackMock = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
|
$requestStackMock = $this->createMock(RequestStack::class);
|
||||||
$requestStackMock->method('getCurrentRequest')->willReturn($request);
|
$requestStackMock->method('getCurrentRequest')->willReturn($request);
|
||||||
|
|
||||||
$this->appVariable->setRequestStack($requestStackMock);
|
$this->appVariable->setRequestStack($requestStackMock);
|
||||||
@ -232,10 +236,10 @@ class AppVariableTest extends TestCase
|
|||||||
|
|
||||||
protected function setTokenStorage($user)
|
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);
|
$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);
|
$tokenStorage->method('getToken')->willReturn($token);
|
||||||
|
|
||||||
$token->method('getUser')->willReturn($user);
|
$token->method('getUser')->willReturn($user);
|
||||||
@ -251,11 +255,11 @@ class AppVariableTest extends TestCase
|
|||||||
$flashBag = new FlashBag();
|
$flashBag = new FlashBag();
|
||||||
$flashBag->initialize($flashMessages);
|
$flashBag->initialize($flashMessages);
|
||||||
|
|
||||||
$session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock();
|
$session = $this->createMock(Session::class);
|
||||||
$session->method('isStarted')->willReturn($sessionHasStarted);
|
$session->method('isStarted')->willReturn($sessionHasStarted);
|
||||||
$session->method('getFlashBag')->willReturn($flashBag);
|
$session->method('getFlashBag')->willReturn($flashBag);
|
||||||
|
|
||||||
$request = $this->getMockBuilder(Request::class)->getMock();
|
$request = $this->createMock(Request::class);
|
||||||
$request->method('hasSession')->willReturn(true);
|
$request->method('hasSession')->willReturn(true);
|
||||||
$request->method('getSession')->willReturn($session);
|
$request->method('getSession')->willReturn($session);
|
||||||
$this->setRequestStack($request);
|
$this->setRequestStack($request);
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bridge\Twig\Tests\Command;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bridge\Twig\Command\DebugCommand;
|
use Symfony\Bridge\Twig\Command\DebugCommand;
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
|
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
use Twig\Loader\ChainLoader;
|
use Twig\Loader\ChainLoader;
|
||||||
@ -91,7 +92,7 @@ class DebugCommandTest extends TestCase
|
|||||||
|
|
||||||
public function testMalformedTemplateName()
|
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->expectExceptionMessage('Malformed namespaced template name "@foo" (expecting "@namespace/template_name").');
|
||||||
$this->createCommandTester()->execute(['name' => '@foo']);
|
$this->createCommandTester()->execute(['name' => '@foo']);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Component\VarDumper\Dumper\HtmlDumper;
|
|||||||
use Symfony\Component\VarDumper\VarDumper;
|
use Symfony\Component\VarDumper\VarDumper;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
use Twig\Loader\ArrayLoader;
|
use Twig\Loader\ArrayLoader;
|
||||||
|
use Twig\Loader\LoaderInterface;
|
||||||
|
|
||||||
class DumpExtensionTest extends TestCase
|
class DumpExtensionTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -67,7 +68,7 @@ class DumpExtensionTest extends TestCase
|
|||||||
public function testDump($context, $args, $expectedOutput, $debug = true)
|
public function testDump($context, $args, $expectedOutput, $debug = true)
|
||||||
{
|
{
|
||||||
$extension = new DumpExtension(new VarCloner());
|
$extension = new DumpExtension(new VarCloner());
|
||||||
$twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), [
|
$twig = new Environment($this->createMock(LoaderInterface::class), [
|
||||||
'debug' => $debug,
|
'debug' => $debug,
|
||||||
'cache' => false,
|
'cache' => false,
|
||||||
'optimizations' => 0,
|
'optimizations' => 0,
|
||||||
@ -124,7 +125,7 @@ class DumpExtensionTest extends TestCase
|
|||||||
'</pre><script>Sfdump("%s")</script>'
|
'</pre><script>Sfdump("%s")</script>'
|
||||||
);
|
);
|
||||||
$extension = new DumpExtension(new VarCloner(), $dumper);
|
$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,
|
'debug' => true,
|
||||||
'cache' => false,
|
'cache' => false,
|
||||||
'optimizations' => 0,
|
'optimizations' => 0,
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader;
|
|||||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||||
use Symfony\Component\Form\FormRenderer;
|
use Symfony\Component\Form\FormRenderer;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
|
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
|
||||||
class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTest
|
class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTest
|
||||||
@ -50,7 +51,7 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori
|
|||||||
'bootstrap_3_horizontal_layout.html.twig',
|
'bootstrap_3_horizontal_layout.html.twig',
|
||||||
'custom_widgets.html.twig',
|
'custom_widgets.html.twig',
|
||||||
], $environment);
|
], $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);
|
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader;
|
|||||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||||
use Symfony\Component\Form\FormRenderer;
|
use Symfony\Component\Form\FormRenderer;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
|
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
|
||||||
class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
|
class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
|
||||||
@ -46,7 +47,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
|
|||||||
'bootstrap_3_layout.html.twig',
|
'bootstrap_3_layout.html.twig',
|
||||||
'custom_widgets.html.twig',
|
'custom_widgets.html.twig',
|
||||||
], $environment);
|
], $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);
|
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +89,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
|
|||||||
'bootstrap_3_layout.html.twig',
|
'bootstrap_3_layout.html.twig',
|
||||||
'custom_widgets.html.twig',
|
'custom_widgets.html.twig',
|
||||||
], $environment);
|
], $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);
|
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||||
|
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader;
|
|||||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||||
use Symfony\Component\Form\FormRenderer;
|
use Symfony\Component\Form\FormRenderer;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
|
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,7 +53,7 @@ class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4Hori
|
|||||||
'bootstrap_4_horizontal_layout.html.twig',
|
'bootstrap_4_horizontal_layout.html.twig',
|
||||||
'custom_widgets.html.twig',
|
'custom_widgets.html.twig',
|
||||||
], $environment);
|
], $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);
|
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader;
|
|||||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||||
use Symfony\Component\Form\FormRenderer;
|
use Symfony\Component\Form\FormRenderer;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
|
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +51,7 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest
|
|||||||
'bootstrap_4_layout.html.twig',
|
'bootstrap_4_layout.html.twig',
|
||||||
'custom_widgets.html.twig',
|
'custom_widgets.html.twig',
|
||||||
], $environment);
|
], $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);
|
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest
|
|||||||
'bootstrap_4_layout.html.twig',
|
'bootstrap_4_layout.html.twig',
|
||||||
'custom_widgets.html.twig',
|
'custom_widgets.html.twig',
|
||||||
], $environment);
|
], $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);
|
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||||
|
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
|
@ -20,6 +20,7 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceView;
|
|||||||
use Symfony\Component\Form\FormRenderer;
|
use Symfony\Component\Form\FormRenderer;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\Form\Tests\AbstractDivLayoutTest;
|
use Symfony\Component\Form\Tests\AbstractDivLayoutTest;
|
||||||
|
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
|
||||||
class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
||||||
@ -53,7 +54,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||||||
'form_div_layout.html.twig',
|
'form_div_layout.html.twig',
|
||||||
'custom_widgets.html.twig',
|
'custom_widgets.html.twig',
|
||||||
], $environment);
|
], $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);
|
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +182,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||||||
'form_div_layout.html.twig',
|
'form_div_layout.html.twig',
|
||||||
'custom_widgets.html.twig',
|
'custom_widgets.html.twig',
|
||||||
], $environment);
|
], $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);
|
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||||
|
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
|
@ -19,6 +19,7 @@ use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
|||||||
use Symfony\Component\Form\FormRenderer;
|
use Symfony\Component\Form\FormRenderer;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\Form\Tests\AbstractTableLayoutTest;
|
use Symfony\Component\Form\Tests\AbstractTableLayoutTest;
|
||||||
|
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
|
||||||
class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
||||||
@ -50,7 +51,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
|||||||
'form_table_layout.html.twig',
|
'form_table_layout.html.twig',
|
||||||
'custom_widgets.html.twig',
|
'custom_widgets.html.twig',
|
||||||
], $environment);
|
], $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);
|
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,10 +15,13 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Bridge\Twig\Extension\HttpKernelExtension;
|
use Symfony\Bridge\Twig\Extension\HttpKernelExtension;
|
||||||
use Symfony\Bridge\Twig\Extension\HttpKernelRuntime;
|
use Symfony\Bridge\Twig\Extension\HttpKernelRuntime;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
|
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
|
||||||
|
use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
use Twig\Loader\ArrayLoader;
|
use Twig\Loader\ArrayLoader;
|
||||||
|
use Twig\RuntimeLoader\RuntimeLoaderInterface;
|
||||||
|
|
||||||
class HttpKernelExtensionTest extends TestCase
|
class HttpKernelExtensionTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -41,10 +44,7 @@ class HttpKernelExtensionTest extends TestCase
|
|||||||
|
|
||||||
public function testUnknownFragmentRenderer()
|
public function testUnknownFragmentRenderer()
|
||||||
{
|
{
|
||||||
$context = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)
|
$context = $this->createMock(RequestStack::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock()
|
|
||||||
;
|
|
||||||
$renderer = new FragmentHandler($context);
|
$renderer = new FragmentHandler($context);
|
||||||
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
@ -55,14 +55,11 @@ class HttpKernelExtensionTest extends TestCase
|
|||||||
|
|
||||||
protected function getFragmentHandler($return)
|
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('getName')->willReturn('inline');
|
||||||
$strategy->expects($this->once())->method('render')->will($return);
|
$strategy->expects($this->once())->method('render')->will($return);
|
||||||
|
|
||||||
$context = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)
|
$context = $this->createMock(RequestStack::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock()
|
|
||||||
;
|
|
||||||
|
|
||||||
$context->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/'));
|
$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 = new Environment($loader, ['debug' => true, 'cache' => false]);
|
||||||
$twig->addExtension(new HttpKernelExtension());
|
$twig->addExtension(new HttpKernelExtension());
|
||||||
|
|
||||||
$loader = $this->getMockBuilder(\Twig\RuntimeLoader\RuntimeLoaderInterface::class)->getMock();
|
$loader = $this->createMock(RuntimeLoaderInterface::class);
|
||||||
$loader->expects($this->any())->method('load')->willReturnMap([
|
$loader->expects($this->any())->method('load')->willReturnMap([
|
||||||
['Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)],
|
['Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)],
|
||||||
]);
|
]);
|
||||||
|
@ -13,7 +13,9 @@ namespace Symfony\Bridge\Twig\Tests\Extension;
|
|||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bridge\Twig\Extension\RoutingExtension;
|
use Symfony\Bridge\Twig\Extension\RoutingExtension;
|
||||||
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
use Twig\Loader\LoaderInterface;
|
||||||
use Twig\Node\Expression\FilterExpression;
|
use Twig\Node\Expression\FilterExpression;
|
||||||
use Twig\Source;
|
use Twig\Source;
|
||||||
|
|
||||||
@ -24,8 +26,8 @@ class RoutingExtensionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testEscaping($template, $mustBeEscaped)
|
public function testEscaping($template, $mustBeEscaped)
|
||||||
{
|
{
|
||||||
$twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]);
|
$twig = new Environment($this->createMock(LoaderInterface::class), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]);
|
||||||
$twig->addExtension(new RoutingExtension($this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock()));
|
$twig->addExtension(new RoutingExtension($this->createMock(UrlGeneratorInterface::class)));
|
||||||
|
|
||||||
$nodes = $twig->parse($twig->tokenize(new Source($template, '')));
|
$nodes = $twig->parse($twig->tokenize(new Source($template, '')));
|
||||||
|
|
||||||
|
@ -13,12 +13,13 @@ namespace Symfony\Bridge\Twig\Tests\Extension;
|
|||||||
|
|
||||||
use Symfony\Component\Form\FormRenderer;
|
use Symfony\Component\Form\FormRenderer;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
use Twig\RuntimeLoader\RuntimeLoaderInterface;
|
||||||
|
|
||||||
trait RuntimeLoaderProvider
|
trait RuntimeLoaderProvider
|
||||||
{
|
{
|
||||||
protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer)
|
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([
|
$loader->expects($this->any())->method('load')->will($this->returnValueMap([
|
||||||
['Symfony\Component\Form\FormRenderer', $renderer],
|
['Symfony\Component\Form\FormRenderer', $renderer],
|
||||||
]));
|
]));
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension;
|
|||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bridge\Twig\Extension\StopwatchExtension;
|
use Symfony\Bridge\Twig\Extension\StopwatchExtension;
|
||||||
|
use Symfony\Component\Stopwatch\Stopwatch;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
use Twig\Error\RuntimeError;
|
use Twig\Error\RuntimeError;
|
||||||
use Twig\Loader\ArrayLoader;
|
use Twig\Loader\ArrayLoader;
|
||||||
@ -55,7 +56,7 @@ class StopwatchExtensionTest extends TestCase
|
|||||||
protected function getStopwatch($events = [])
|
protected function getStopwatch($events = [])
|
||||||
{
|
{
|
||||||
$events = \is_array($events) ? $events : [$events];
|
$events = \is_array($events) ? $events : [$events];
|
||||||
$stopwatch = $this->getMockBuilder(\Symfony\Component\Stopwatch\Stopwatch::class)->getMock();
|
$stopwatch = $this->createMock(Stopwatch::class);
|
||||||
|
|
||||||
$expectedCalls = 0;
|
$expectedCalls = 0;
|
||||||
$expectedStartCalls = [];
|
$expectedStartCalls = [];
|
||||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Bridge\Twig\Node\DumpNode;
|
use Symfony\Bridge\Twig\Node\DumpNode;
|
||||||
use Twig\Compiler;
|
use Twig\Compiler;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
use Twig\Loader\LoaderInterface;
|
||||||
use Twig\Node\Expression\NameExpression;
|
use Twig\Node\Expression\NameExpression;
|
||||||
use Twig\Node\Node;
|
use Twig\Node\Node;
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ class DumpNodeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$node = new DumpNode('bar', null, 7);
|
$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);
|
$compiler = new Compiler($env);
|
||||||
|
|
||||||
$expected = <<<'EOTXT'
|
$expected = <<<'EOTXT'
|
||||||
@ -48,7 +49,7 @@ EOTXT;
|
|||||||
{
|
{
|
||||||
$node = new DumpNode('bar', null, 7);
|
$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);
|
$compiler = new Compiler($env);
|
||||||
|
|
||||||
$expected = <<<'EOTXT'
|
$expected = <<<'EOTXT'
|
||||||
@ -75,7 +76,7 @@ EOTXT;
|
|||||||
]);
|
]);
|
||||||
$node = new DumpNode('bar', $vars, 7);
|
$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);
|
$compiler = new Compiler($env);
|
||||||
|
|
||||||
$expected = <<<'EOTXT'
|
$expected = <<<'EOTXT'
|
||||||
@ -99,7 +100,7 @@ EOTXT;
|
|||||||
]);
|
]);
|
||||||
$node = new DumpNode('bar', $vars, 7);
|
$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);
|
$compiler = new Compiler($env);
|
||||||
|
|
||||||
$expected = <<<'EOTXT'
|
$expected = <<<'EOTXT'
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Component\Form\FormRenderer;
|
|||||||
use Symfony\Component\Form\FormRendererEngineInterface;
|
use Symfony\Component\Form\FormRendererEngineInterface;
|
||||||
use Twig\Compiler;
|
use Twig\Compiler;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
use Twig\Loader\LoaderInterface;
|
||||||
use Twig\Node\Expression\ArrayExpression;
|
use Twig\Node\Expression\ArrayExpression;
|
||||||
use Twig\Node\Expression\ConstantExpression;
|
use Twig\Node\Expression\ConstantExpression;
|
||||||
use Twig\Node\Expression\NameExpression;
|
use Twig\Node\Expression\NameExpression;
|
||||||
@ -54,8 +55,8 @@ class FormThemeTest extends TestCase
|
|||||||
|
|
||||||
$node = new FormThemeNode($form, $resources, 0);
|
$node = new FormThemeNode($form, $resources, 0);
|
||||||
|
|
||||||
$environment = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock());
|
$environment = new Environment($this->createMock(LoaderInterface::class));
|
||||||
$formRenderer = new FormRenderer($this->getMockBuilder(FormRendererEngineInterface::class)->getMock());
|
$formRenderer = new FormRenderer($this->createMock(FormRendererEngineInterface::class));
|
||||||
$this->registerTwigRuntimeLoader($environment, $formRenderer);
|
$this->registerTwigRuntimeLoader($environment, $formRenderer);
|
||||||
$compiler = new Compiler($environment);
|
$compiler = new Compiler($environment);
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode;
|
use Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode;
|
||||||
use Twig\Compiler;
|
use Twig\Compiler;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
use Twig\Loader\LoaderInterface;
|
||||||
use Twig\Node\Expression\ArrayExpression;
|
use Twig\Node\Expression\ArrayExpression;
|
||||||
use Twig\Node\Expression\ConditionalExpression;
|
use Twig\Node\Expression\ConditionalExpression;
|
||||||
use Twig\Node\Expression\ConstantExpression;
|
use Twig\Node\Expression\ConstantExpression;
|
||||||
@ -31,7 +32,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
|
|
||||||
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
|
$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(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
@ -54,7 +55,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
|
|
||||||
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
|
$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(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
@ -74,7 +75,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
|
|
||||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
$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(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
@ -94,7 +95,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
|
|
||||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
$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!
|
// "label" => null must not be included in the output!
|
||||||
// Otherwise the default label is overwritten with null.
|
// Otherwise the default label is overwritten with null.
|
||||||
@ -116,7 +117,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
|
|
||||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
$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!
|
// "label" => null must not be included in the output!
|
||||||
// Otherwise the default label is overwritten with null.
|
// Otherwise the default label is overwritten with null.
|
||||||
@ -137,7 +138,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
|
|
||||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
$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(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
@ -161,7 +162,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
|
|
||||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
$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!
|
// "label" => null must not be included in the output!
|
||||||
// Otherwise the default label is overwritten with null.
|
// Otherwise the default label is overwritten with null.
|
||||||
@ -190,7 +191,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
|
|
||||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
$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(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
@ -218,7 +219,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
|
|
||||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
$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!
|
// "label" => null must not be included in the output!
|
||||||
// Otherwise the default label is overwritten with null.
|
// Otherwise the default label is overwritten with null.
|
||||||
@ -255,7 +256,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
|
|
||||||
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
|
$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!
|
// "label" => null must not be included in the output!
|
||||||
// Otherwise the default label is overwritten with null.
|
// Otherwise the default label is overwritten with null.
|
||||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Bridge\Twig\Node\TransNode;
|
use Symfony\Bridge\Twig\Node\TransNode;
|
||||||
use Twig\Compiler;
|
use Twig\Compiler;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
use Twig\Loader\LoaderInterface;
|
||||||
use Twig\Node\Expression\NameExpression;
|
use Twig\Node\Expression\NameExpression;
|
||||||
use Twig\Node\TextNode;
|
use Twig\Node\TextNode;
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ class TransNodeTest extends TestCase
|
|||||||
$vars = new NameExpression('foo', 0);
|
$vars = new NameExpression('foo', 0);
|
||||||
$node = new TransNode($body, null, null, $vars);
|
$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);
|
$compiler = new Compiler($env);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Bridge\Twig\NodeVisitor\TranslationDefaultDomainNodeVisitor;
|
use Symfony\Bridge\Twig\NodeVisitor\TranslationDefaultDomainNodeVisitor;
|
||||||
use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor;
|
use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
use Twig\Loader\LoaderInterface;
|
||||||
use Twig\Node\Expression\ArrayExpression;
|
use Twig\Node\Expression\ArrayExpression;
|
||||||
use Twig\Node\Node;
|
use Twig\Node\Node;
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase
|
|||||||
/** @dataProvider getDefaultDomainAssignmentTestData */
|
/** @dataProvider getDefaultDomainAssignmentTestData */
|
||||||
public function testDefaultDomainAssignment(Node $node)
|
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();
|
$visitor = new TranslationDefaultDomainNodeVisitor();
|
||||||
|
|
||||||
// visit trans_default_domain tag
|
// visit trans_default_domain tag
|
||||||
@ -52,7 +53,7 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase
|
|||||||
/** @dataProvider getDefaultDomainAssignmentTestData */
|
/** @dataProvider getDefaultDomainAssignmentTestData */
|
||||||
public function testNewModuleWithoutDefaultDomainTag(Node $node)
|
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();
|
$visitor = new TranslationDefaultDomainNodeVisitor();
|
||||||
|
|
||||||
// visit trans_default_domain tag
|
// visit trans_default_domain tag
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bridge\Twig\Tests\NodeVisitor;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor;
|
use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
use Twig\Loader\LoaderInterface;
|
||||||
use Twig\Node\Expression\ArrayExpression;
|
use Twig\Node\Expression\ArrayExpression;
|
||||||
use Twig\Node\Expression\ConstantExpression;
|
use Twig\Node\Expression\ConstantExpression;
|
||||||
use Twig\Node\Expression\FilterExpression;
|
use Twig\Node\Expression\FilterExpression;
|
||||||
@ -25,7 +26,7 @@ class TranslationNodeVisitorTest extends TestCase
|
|||||||
/** @dataProvider getMessagesExtractionTestData */
|
/** @dataProvider getMessagesExtractionTestData */
|
||||||
public function testMessagesExtraction(Node $node, array $expectedMessages)
|
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 = new TranslationNodeVisitor();
|
||||||
$visitor->enable();
|
$visitor->enable();
|
||||||
$visitor->enterNode($node, $env);
|
$visitor->enterNode($node, $env);
|
||||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Bridge\Twig\Node\FormThemeNode;
|
use Symfony\Bridge\Twig\Node\FormThemeNode;
|
||||||
use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser;
|
use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
use Twig\Loader\LoaderInterface;
|
||||||
use Twig\Node\Expression\ArrayExpression;
|
use Twig\Node\Expression\ArrayExpression;
|
||||||
use Twig\Node\Expression\ConstantExpression;
|
use Twig\Node\Expression\ConstantExpression;
|
||||||
use Twig\Node\Expression\NameExpression;
|
use Twig\Node\Expression\NameExpression;
|
||||||
@ -28,7 +29,7 @@ class FormThemeTokenParserTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCompile($source, $expected)
|
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());
|
$env->addTokenParser(new FormThemeTokenParser());
|
||||||
$source = new Source($source, '');
|
$source = new Source($source, '');
|
||||||
$stream = $env->tokenize($source);
|
$stream = $env->tokenize($source);
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Component\Translation\MessageCatalogue;
|
|||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
use Twig\Loader\ArrayLoader;
|
use Twig\Loader\ArrayLoader;
|
||||||
|
use Twig\Loader\LoaderInterface;
|
||||||
|
|
||||||
class TwigExtractorTest extends TestCase
|
class TwigExtractorTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -26,14 +27,14 @@ class TwigExtractorTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testExtract($template, $messages)
|
public function testExtract($template, $messages)
|
||||||
{
|
{
|
||||||
$loader = $this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock();
|
$loader = $this->createMock(LoaderInterface::class);
|
||||||
$twig = new Environment($loader, [
|
$twig = new Environment($loader, [
|
||||||
'strict_variables' => true,
|
'strict_variables' => true,
|
||||||
'debug' => true,
|
'debug' => true,
|
||||||
'cache' => false,
|
'cache' => false,
|
||||||
'autoescape' => 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 = new TwigExtractor($twig);
|
||||||
$extractor->setPrefix('prefix');
|
$extractor->setPrefix('prefix');
|
||||||
@ -102,8 +103,8 @@ class TwigExtractorTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testExtractSyntaxError($resources, array $messages)
|
public function testExtractSyntaxError($resources, array $messages)
|
||||||
{
|
{
|
||||||
$twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock());
|
$twig = new Environment($this->createMock(LoaderInterface::class));
|
||||||
$twig->addExtension(new TranslationExtension($this->getMockBuilder(TranslatorInterface::class)->getMock()));
|
$twig->addExtension(new TranslationExtension($this->createMock(TranslatorInterface::class)));
|
||||||
|
|
||||||
$extractor = new TwigExtractor($twig);
|
$extractor = new TwigExtractor($twig);
|
||||||
$catalogue = new MessageCatalogue('en');
|
$catalogue = new MessageCatalogue('en');
|
||||||
@ -132,7 +133,7 @@ class TwigExtractorTest extends TestCase
|
|||||||
'cache' => false,
|
'cache' => false,
|
||||||
'autoescape' => 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 = new TwigExtractor($twig);
|
||||||
$catalogue = new MessageCatalogue('en');
|
$catalogue = new MessageCatalogue('en');
|
||||||
|
@ -13,9 +13,12 @@ namespace Symfony\Bridge\Twig\Tests;
|
|||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bridge\Twig\TwigEngine;
|
use Symfony\Bridge\Twig\TwigEngine;
|
||||||
|
use Symfony\Component\Templating\TemplateNameParserInterface;
|
||||||
use Symfony\Component\Templating\TemplateReference;
|
use Symfony\Component\Templating\TemplateReference;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
use Twig\Error\SyntaxError;
|
||||||
use Twig\Loader\ArrayLoader;
|
use Twig\Loader\ArrayLoader;
|
||||||
|
use Twig\Template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
@ -26,7 +29,7 @@ class TwigEngineTest extends TestCase
|
|||||||
{
|
{
|
||||||
$engine = $this->getTwig();
|
$engine = $this->getTwig();
|
||||||
|
|
||||||
$this->assertTrue($engine->exists($this->getMockForAbstractClass(\Twig\Template::class, [], '', false)));
|
$this->assertTrue($engine->exists($this->getMockForAbstractClass(Template::class, [], '', false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExistsWithNonExistentTemplates()
|
public function testExistsWithNonExistentTemplates()
|
||||||
@ -63,7 +66,7 @@ class TwigEngineTest extends TestCase
|
|||||||
|
|
||||||
public function testRenderWithError()
|
public function testRenderWithError()
|
||||||
{
|
{
|
||||||
$this->expectException(\Twig\Error\SyntaxError::class);
|
$this->expectException(SyntaxError::class);
|
||||||
$engine = $this->getTwig();
|
$engine = $this->getTwig();
|
||||||
|
|
||||||
$engine->render(new TemplateReference('error'));
|
$engine->render(new TemplateReference('error'));
|
||||||
@ -75,7 +78,7 @@ class TwigEngineTest extends TestCase
|
|||||||
'index' => 'foo',
|
'index' => 'foo',
|
||||||
'error' => '{{ foo }',
|
'error' => '{{ foo }',
|
||||||
]));
|
]));
|
||||||
$parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock();
|
$parser = $this->createMock(TemplateNameParserInterface::class);
|
||||||
|
|
||||||
return new TwigEngine($twig, $parser);
|
return new TwigEngine($twig, $parser);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ class AnnotationsCacheWarmerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function getReadOnlyReader()
|
private function getReadOnlyReader()
|
||||||
{
|
{
|
||||||
$readerMock = $this->getMockBuilder(Reader::class)->getMock();
|
$readerMock = $this->createMock(Reader::class);
|
||||||
$readerMock->expects($this->exactly(0))->method('getClassAnnotations');
|
$readerMock->expects($this->exactly(0))->method('getClassAnnotations');
|
||||||
$readerMock->expects($this->exactly(0))->method('getClassAnnotation');
|
$readerMock->expects($this->exactly(0))->method('getClassAnnotation');
|
||||||
$readerMock->expects($this->exactly(0))->method('getMethodAnnotations');
|
$readerMock->expects($this->exactly(0))->method('getMethodAnnotations');
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinder;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser;
|
use Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BaseBundle\BaseBundle;
|
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BaseBundle\BaseBundle;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||||
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
@ -23,12 +24,7 @@ class TemplateFinderTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testFindAllTemplates()
|
public function testFindAllTemplates()
|
||||||
{
|
{
|
||||||
$kernel = $this
|
$kernel = $this->createMock(Kernel::class);
|
||||||
->getMockBuilder(\Symfony\Component\HttpKernel\Kernel::class)
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock()
|
|
||||||
;
|
|
||||||
|
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getBundle')
|
->method('getBundle')
|
||||||
|
@ -17,6 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Command\CachePoolDeleteCommand;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
|
use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
|
||||||
use Symfony\Component\HttpKernel\KernelInterface;
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
|
|
||||||
@ -26,8 +27,7 @@ class CachePoolDeleteCommandTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->cachePool = $this->getMockBuilder(CacheItemPoolInterface::class)
|
$this->cachePool = $this->createMock(CacheItemPoolInterface::class);
|
||||||
->getMock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCommandWithValidKey()
|
public function testCommandWithValidKey()
|
||||||
@ -88,14 +88,9 @@ class CachePoolDeleteCommandTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function getKernel()
|
private function getKernel()
|
||||||
{
|
{
|
||||||
$container = $this
|
$container = $this->createMock(ContainerInterface::class);
|
||||||
->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$kernel = $this
|
|
||||||
->getMockBuilder(KernelInterface::class)
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
|
$kernel = $this->createMock(KernelInterface::class);
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getContainer')
|
->method('getContainer')
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
|||||||
use Symfony\Component\Cache\PruneableInterface;
|
use Symfony\Component\Cache\PruneableInterface;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
|
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\HttpKernel\KernelInterface;
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
|
|
||||||
class CachePruneCommandTest extends TestCase
|
class CachePruneCommandTest extends TestCase
|
||||||
@ -54,14 +55,9 @@ class CachePruneCommandTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function getKernel()
|
private function getKernel()
|
||||||
{
|
{
|
||||||
$container = $this
|
$container = $this->createMock(ContainerInterface::class);
|
||||||
->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$kernel = $this
|
|
||||||
->getMockBuilder(KernelInterface::class)
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
|
$kernel = $this->createMock(KernelInterface::class);
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getContainer')
|
->method('getContainer')
|
||||||
@ -80,10 +76,7 @@ class CachePruneCommandTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function getPruneableInterfaceMock()
|
private function getPruneableInterfaceMock()
|
||||||
{
|
{
|
||||||
$pruneable = $this
|
$pruneable = $this->createMock(PruneableInterface::class);
|
||||||
->getMockBuilder(PruneableInterface::class)
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$pruneable
|
$pruneable
|
||||||
->expects($this->atLeastOnce())
|
->expects($this->atLeastOnce())
|
||||||
->method('prune');
|
->method('prune');
|
||||||
|
@ -16,10 +16,12 @@ use Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand;
|
use Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand;
|
||||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\HttpKernel\KernelInterface;
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
use Symfony\Component\Routing\RequestContext;
|
use Symfony\Component\Routing\RequestContext;
|
||||||
use Symfony\Component\Routing\Route;
|
use Symfony\Component\Routing\Route;
|
||||||
use Symfony\Component\Routing\RouteCollection;
|
use Symfony\Component\Routing\RouteCollection;
|
||||||
|
use Symfony\Component\Routing\RouterInterface;
|
||||||
|
|
||||||
class RouterMatchCommandTest extends TestCase
|
class RouterMatchCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -55,7 +57,7 @@ class RouterMatchCommandTest extends TestCase
|
|||||||
$routeCollection = new RouteCollection();
|
$routeCollection = new RouteCollection();
|
||||||
$routeCollection->add('foo', new Route('foo'));
|
$routeCollection->add('foo', new Route('foo'));
|
||||||
$requestContext = new RequestContext();
|
$requestContext = new RequestContext();
|
||||||
$router = $this->getMockBuilder(\Symfony\Component\Routing\RouterInterface::class)->getMock();
|
$router = $this->createMock(RouterInterface::class);
|
||||||
$router
|
$router
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getRouteCollection')
|
->method('getRouteCollection')
|
||||||
@ -70,7 +72,7 @@ class RouterMatchCommandTest extends TestCase
|
|||||||
|
|
||||||
private function getKernel()
|
private function getKernel()
|
||||||
{
|
{
|
||||||
$container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
|
$container = $this->createMock(ContainerInterface::class);
|
||||||
$container
|
$container
|
||||||
->expects($this->atLeastOnce())
|
->expects($this->atLeastOnce())
|
||||||
->method('has')
|
->method('has')
|
||||||
@ -85,7 +87,7 @@ class RouterMatchCommandTest extends TestCase
|
|||||||
->willReturn($this->getRouter())
|
->willReturn($this->getRouter())
|
||||||
;
|
;
|
||||||
|
|
||||||
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
$kernel = $this->createMock(KernelInterface::class);
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getContainer')
|
->method('getContainer')
|
||||||
|
@ -18,6 +18,11 @@ use Symfony\Component\Console\Tester\CommandTester;
|
|||||||
use Symfony\Component\DependencyInjection\Container;
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use Symfony\Component\HttpKernel;
|
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;
|
||||||
|
|
||||||
class TranslationDebugCommandTest extends TestCase
|
class TranslationDebugCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -101,7 +106,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->fs->mkdir($this->translationDir.'/customDir/translations');
|
$this->fs->mkdir($this->translationDir.'/customDir/translations');
|
||||||
$this->fs->mkdir($this->translationDir.'/customDir/templates');
|
$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())
|
$kernel->expects($this->once())
|
||||||
->method('getBundle')
|
->method('getBundle')
|
||||||
->with($this->equalTo($this->translationDir.'/customDir'))
|
->with($this->equalTo($this->translationDir.'/customDir'))
|
||||||
@ -117,7 +122,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
public function testDebugInvalidDirectory()
|
public function testDebugInvalidDirectory()
|
||||||
{
|
{
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
|
$kernel = $this->createMock(KernelInterface::class);
|
||||||
$kernel->expects($this->once())
|
$kernel->expects($this->once())
|
||||||
->method('getBundle')
|
->method('getBundle')
|
||||||
->with($this->equalTo('dir'))
|
->with($this->equalTo('dir'))
|
||||||
@ -142,16 +147,13 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
|
|
||||||
private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null, array $transPaths = [], array $viewsPaths = []): CommandTester
|
private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null, array $transPaths = [], array $viewsPaths = []): CommandTester
|
||||||
{
|
{
|
||||||
$translator = $this->getMockBuilder(\Symfony\Component\Translation\Translator::class)
|
$translator = $this->createMock(Translator::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$translator
|
$translator
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getFallbackLocales')
|
->method('getFallbackLocales')
|
||||||
->willReturn(['en']);
|
->willReturn(['en']);
|
||||||
|
|
||||||
$extractor = $this->getMockBuilder(\Symfony\Component\Translation\Extractor\ExtractorInterface::class)->getMock();
|
$extractor = $this->createMock(ExtractorInterface::class);
|
||||||
$extractor
|
$extractor
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('extract')
|
->method('extract')
|
||||||
@ -161,7 +163,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Reader\TranslationReader::class)->getMock();
|
$loader = $this->createMock(TranslationReader::class);
|
||||||
$loader
|
$loader
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('read')
|
->method('read')
|
||||||
@ -182,7 +184,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
['test', true, $this->getBundle('test')],
|
['test', true, $this->getBundle('test')],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
|
$kernel = $this->createMock(KernelInterface::class);
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getBundle')
|
->method('getBundle')
|
||||||
@ -212,7 +214,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||||||
|
|
||||||
private function getBundle($path)
|
private function getBundle($path)
|
||||||
{
|
{
|
||||||
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
|
$bundle = $this->createMock(BundleInterface::class);
|
||||||
$bundle
|
$bundle
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getPath')
|
->method('getPath')
|
||||||
|
@ -18,6 +18,12 @@ use Symfony\Component\Console\Tester\CommandTester;
|
|||||||
use Symfony\Component\DependencyInjection\Container;
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use Symfony\Component\HttpKernel;
|
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
|
class TranslationUpdateCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -152,18 +158,15 @@ class TranslationUpdateCommandTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @return CommandTester
|
* @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)
|
$translator = $this->createMock(Translator::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$translator
|
$translator
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getFallbackLocales')
|
->method('getFallbackLocales')
|
||||||
->willReturn(['en']);
|
->willReturn(['en']);
|
||||||
|
|
||||||
$extractor = $this->getMockBuilder(\Symfony\Component\Translation\Extractor\ExtractorInterface::class)->getMock();
|
$extractor = $this->createMock(ExtractorInterface::class);
|
||||||
$extractor
|
$extractor
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('extract')
|
->method('extract')
|
||||||
@ -175,7 +178,7 @@ class TranslationUpdateCommandTest extends TestCase
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Reader\TranslationReader::class)->getMock();
|
$loader = $this->createMock(TranslationReader::class);
|
||||||
$loader
|
$loader
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('read')
|
->method('read')
|
||||||
@ -185,7 +188,7 @@ class TranslationUpdateCommandTest extends TestCase
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$writer = $this->getMockBuilder(\Symfony\Component\Translation\Writer\TranslationWriter::class)->getMock();
|
$writer = $this->createMock(TranslationWriter::class);
|
||||||
$writer
|
$writer
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getFormats')
|
->method('getFormats')
|
||||||
@ -204,7 +207,7 @@ class TranslationUpdateCommandTest extends TestCase
|
|||||||
['test', true, $this->getBundle('test')],
|
['test', true, $this->getBundle('test')],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
|
$kernel = $this->createMock(KernelInterface::class);
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getBundle')
|
->method('getBundle')
|
||||||
@ -233,7 +236,7 @@ class TranslationUpdateCommandTest extends TestCase
|
|||||||
|
|
||||||
private function getBundle($path)
|
private function getBundle($path)
|
||||||
{
|
{
|
||||||
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
|
$bundle = $this->createMock(BundleInterface::class);
|
||||||
$bundle
|
$bundle
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getPath')
|
->method('getPath')
|
||||||
|
@ -73,20 +73,14 @@ EOF;
|
|||||||
|
|
||||||
private function getKernelAwareApplicationMock()
|
private function getKernelAwareApplicationMock()
|
||||||
{
|
{
|
||||||
$kernel = $this->getMockBuilder(KernelInterface::class)
|
$kernel = $this->createMock(KernelInterface::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('locateResource')
|
->method('locateResource')
|
||||||
->with('@AppBundle/Resources')
|
->with('@AppBundle/Resources')
|
||||||
->willReturn(sys_get_temp_dir().'/xliff-lint-test');
|
->willReturn(sys_get_temp_dir().'/xliff-lint-test');
|
||||||
|
|
||||||
$application = $this->getMockBuilder(Application::class)
|
$application = $this->createMock(Application::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$application
|
$application
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getKernel')
|
->method('getKernel')
|
||||||
|
@ -120,20 +120,14 @@ EOF;
|
|||||||
|
|
||||||
private function getKernelAwareApplicationMock()
|
private function getKernelAwareApplicationMock()
|
||||||
{
|
{
|
||||||
$kernel = $this->getMockBuilder(KernelInterface::class)
|
$kernel = $this->createMock(KernelInterface::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('locateResource')
|
->method('locateResource')
|
||||||
->with('@AppBundle/Resources')
|
->with('@AppBundle/Resources')
|
||||||
->willReturn(sys_get_temp_dir().'/yml-lint-test');
|
->willReturn(sys_get_temp_dir().'/yml-lint-test');
|
||||||
|
|
||||||
$application = $this->getMockBuilder(Application::class)
|
$application = $this->createMock(Application::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$application
|
$application
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getKernel')
|
->method('getKernel')
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Console;
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Console;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||||
use Symfony\Bundle\FrameworkBundle\EventListener\SuggestMissingPackageSubscriber;
|
use Symfony\Bundle\FrameworkBundle\EventListener\SuggestMissingPackageSubscriber;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||||
@ -23,14 +24,18 @@ use Symfony\Component\Console\Output\NullOutput;
|
|||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Tester\ApplicationTester;
|
use Symfony\Component\Console\Tester\ApplicationTester;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
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;
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
|
|
||||||
class ApplicationTest extends TestCase
|
class ApplicationTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testBundleInterfaceImplementation()
|
public function testBundleInterfaceImplementation()
|
||||||
{
|
{
|
||||||
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
|
$bundle = $this->createMock(BundleInterface::class);
|
||||||
|
|
||||||
$kernel = $this->getKernel([$bundle], true);
|
$kernel = $this->getKernel([$bundle], true);
|
||||||
|
|
||||||
@ -110,7 +115,7 @@ class ApplicationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBundleCommandsHaveRightContainer()
|
public function testBundleCommandsHaveRightContainer()
|
||||||
{
|
{
|
||||||
$command = $this->getMockForAbstractClass(\Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand::class, ['foo'], '', true, true, true, ['setContainer']);
|
$command = $this->getMockForAbstractClass(ContainerAwareCommand::class, ['foo'], '', true, true, true, ['setContainer']);
|
||||||
$command->setCode(function () {});
|
$command->setCode(function () {});
|
||||||
$command->expects($this->exactly(2))->method('setContainer');
|
$command->expects($this->exactly(2))->method('setContainer');
|
||||||
|
|
||||||
@ -149,7 +154,7 @@ class ApplicationTest extends TestCase
|
|||||||
$container->register(ThrowingCommand::class, ThrowingCommand::class);
|
$container->register(ThrowingCommand::class, ThrowingCommand::class);
|
||||||
$container->setParameter('console.command.ids', [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
|
$kernel
|
||||||
->method('getBundles')
|
->method('getBundles')
|
||||||
->willReturn([$this->createBundleMock(
|
->willReturn([$this->createBundleMock(
|
||||||
@ -177,7 +182,7 @@ class ApplicationTest extends TestCase
|
|||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('event_dispatcher', EventDispatcher::class);
|
$container->register('event_dispatcher', EventDispatcher::class);
|
||||||
|
|
||||||
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
$kernel = $this->createMock(KernelInterface::class);
|
||||||
$kernel
|
$kernel
|
||||||
->method('getBundles')
|
->method('getBundles')
|
||||||
->willReturn([$this->createBundleMock(
|
->willReturn([$this->createBundleMock(
|
||||||
@ -206,7 +211,7 @@ class ApplicationTest extends TestCase
|
|||||||
$container->register(ThrowingCommand::class, ThrowingCommand::class);
|
$container->register(ThrowingCommand::class, ThrowingCommand::class);
|
||||||
$container->setParameter('console.command.ids', [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->expects($this->once())->method('boot');
|
||||||
$kernel
|
$kernel
|
||||||
->method('getBundles')
|
->method('getBundles')
|
||||||
@ -259,10 +264,10 @@ class ApplicationTest extends TestCase
|
|||||||
|
|
||||||
private function getKernel(array $bundles, $useDispatcher = false)
|
private function getKernel(array $bundles, $useDispatcher = false)
|
||||||
{
|
{
|
||||||
$container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
|
$container = $this->createMock(ContainerInterface::class);
|
||||||
|
|
||||||
if ($useDispatcher) {
|
if ($useDispatcher) {
|
||||||
$dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
|
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||||
$dispatcher
|
$dispatcher
|
||||||
->expects($this->atLeastOnce())
|
->expects($this->atLeastOnce())
|
||||||
->method('dispatch')
|
->method('dispatch')
|
||||||
@ -287,7 +292,7 @@ class ApplicationTest extends TestCase
|
|||||||
->willReturnOnConsecutiveCalls([], [])
|
->willReturnOnConsecutiveCalls([], [])
|
||||||
;
|
;
|
||||||
|
|
||||||
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
$kernel = $this->createMock(KernelInterface::class);
|
||||||
$kernel->expects($this->once())->method('boot');
|
$kernel->expects($this->once())->method('boot');
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
@ -305,7 +310,7 @@ class ApplicationTest extends TestCase
|
|||||||
|
|
||||||
private function createBundleMock(array $commands)
|
private function createBundleMock(array $commands)
|
||||||
{
|
{
|
||||||
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock();
|
$bundle = $this->createMock(Bundle::class);
|
||||||
$bundle
|
$bundle
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('registerCommands')
|
->method('registerCommands')
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
|
|||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\DependencyInjection\Container;
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
|
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBag;
|
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBag;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ class AbstractControllerTest extends ControllerTraitTest
|
|||||||
|
|
||||||
public function testMissingParameterBag()
|
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');
|
$this->expectExceptionMessage('TestAbstractController::getParameter()" method is missing a parameter bag');
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
|
|
||||||
|
@ -14,7 +14,9 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
|
|||||||
use Composer\Autoload\ClassLoader;
|
use Composer\Autoload\ClassLoader;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
|
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||||
|
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||||
use Symfony\Component\HttpKernel\Kernel;
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
@ -151,7 +153,7 @@ class ControllerNameParserTest extends TestCase
|
|||||||
'FooBundle' => $this->getBundle('TestBundle\FooBundle', 'FooBundle'),
|
'FooBundle' => $this->getBundle('TestBundle\FooBundle', 'FooBundle'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
|
$kernel = $this->createMock(KernelInterface::class);
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getBundle')
|
->method('getBundle')
|
||||||
@ -180,7 +182,7 @@ class ControllerNameParserTest extends TestCase
|
|||||||
|
|
||||||
private function getBundle($namespace, $name)
|
private function getBundle($namespace, $name)
|
||||||
{
|
{
|
||||||
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
|
$bundle = $this->createMock(BundleInterface::class);
|
||||||
$bundle->expects($this->any())->method('getName')->willReturn($name);
|
$bundle->expects($this->any())->method('getName')->willReturn($name);
|
||||||
$bundle->expects($this->any())->method('getNamespace')->willReturn($namespace);
|
$bundle->expects($this->any())->method('getNamespace')->willReturn($namespace);
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest
|
|||||||
|
|
||||||
$controller = $resolver->getController($request);
|
$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->assertInstanceOf(ContainerInterface::class, $controller[0]->getContainer());
|
||||||
$this->assertSame('testAction', $controller[1]);
|
$this->assertSame('testAction', $controller[1]);
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest
|
|||||||
|
|
||||||
$controller = $resolver->getController($request);
|
$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());
|
$this->assertInstanceOf(ContainerInterface::class, $controller->getContainer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest
|
|||||||
|
|
||||||
$controller = $resolver->getController($request);
|
$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->assertInstanceOf(ContainerInterface::class, $controller[0]->getContainer());
|
||||||
$this->assertSame('testAction', $controller[1]);
|
$this->assertSame('testAction', $controller[1]);
|
||||||
}
|
}
|
||||||
@ -200,12 +200,12 @@ class ControllerResolverTest extends ContainerControllerResolverTest
|
|||||||
|
|
||||||
protected function createMockParser()
|
protected function createMockParser()
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder(ControllerNameParser::class)->disableOriginalConstructor()->getMock();
|
return $this->createMock(ControllerNameParser::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createMockContainer()
|
protected function createMockContainer()
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder(ContainerInterface::class)->getMock();
|
return $this->createMock(ContainerInterface::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,23 +12,38 @@
|
|||||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
|
||||||
|
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||||
use Symfony\Component\DependencyInjection\Container;
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
use Symfony\Component\Form\Form;
|
use Symfony\Component\Form\Form;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Form\FormConfigInterface;
|
use Symfony\Component\Form\FormConfigInterface;
|
||||||
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||||
use Symfony\Component\HttpFoundation\File\File;
|
use Symfony\Component\HttpFoundation\File\File;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
||||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
||||||
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
|
use Symfony\Component\Routing\RouterInterface;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
|
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||||
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
use Symfony\Component\Security\Core\User\User;
|
use Symfony\Component\Security\Core\User\User;
|
||||||
|
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Symfony\Component\WebLink\Link;
|
use Symfony\Component\WebLink\Link;
|
||||||
|
use Twig\Environment;
|
||||||
|
|
||||||
abstract class ControllerTraitTest extends TestCase
|
abstract class ControllerTraitTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -43,7 +58,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
$requestStack = new RequestStack();
|
$requestStack = new RequestStack();
|
||||||
$requestStack->push($request);
|
$requestStack->push($request);
|
||||||
|
|
||||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock();
|
$kernel = $this->createMock(HttpKernelInterface::class);
|
||||||
$kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) {
|
$kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) {
|
||||||
return new Response($request->getRequestFormat().'--'.$request->getLocale());
|
return new Response($request->getRequestFormat().'--'.$request->getLocale());
|
||||||
});
|
});
|
||||||
@ -100,7 +115,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
|
|
||||||
private function getContainerWithTokenStorage($token = null): Container
|
private function getContainerWithTokenStorage($token = null): Container
|
||||||
{
|
{
|
||||||
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage::class)->getMock();
|
$tokenStorage = $this->createMock(TokenStorage::class);
|
||||||
$tokenStorage
|
$tokenStorage
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getToken')
|
->method('getToken')
|
||||||
@ -126,7 +141,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
|
|
||||||
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
|
$serializer = $this->createMock(SerializerInterface::class);
|
||||||
$serializer
|
$serializer
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('serialize')
|
->method('serialize')
|
||||||
@ -147,7 +162,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
|
|
||||||
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
|
$serializer = $this->createMock(SerializerInterface::class);
|
||||||
$serializer
|
$serializer
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('serialize')
|
->method('serialize')
|
||||||
@ -169,7 +184,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
public function testFile()
|
public function testFile()
|
||||||
{
|
{
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock();
|
$kernel = $this->createMock(HttpKernelInterface::class);
|
||||||
$container->set('http_kernel', $kernel);
|
$container->set('http_kernel', $kernel);
|
||||||
|
|
||||||
$controller = $this->createController();
|
$controller = $this->createController();
|
||||||
@ -270,7 +285,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
|
|
||||||
public function testFileWhichDoesNotExist()
|
public function testFileWhichDoesNotExist()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class);
|
$this->expectException(FileNotFoundException::class);
|
||||||
$controller = $this->createController();
|
$controller = $this->createController();
|
||||||
|
|
||||||
$controller->file('some-file.txt', 'test.php');
|
$controller->file('some-file.txt', 'test.php');
|
||||||
@ -278,7 +293,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
|
|
||||||
public function testIsGranted()
|
public function testIsGranted()
|
||||||
{
|
{
|
||||||
$authorizationChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class)->getMock();
|
$authorizationChecker = $this->createMock(AuthorizationCheckerInterface::class);
|
||||||
$authorizationChecker->expects($this->once())->method('isGranted')->willReturn(true);
|
$authorizationChecker->expects($this->once())->method('isGranted')->willReturn(true);
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
@ -292,8 +307,8 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
|
|
||||||
public function testdenyAccessUnlessGranted()
|
public function testdenyAccessUnlessGranted()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class);
|
$this->expectException(AccessDeniedException::class);
|
||||||
$authorizationChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class)->getMock();
|
$authorizationChecker = $this->createMock(AuthorizationCheckerInterface::class);
|
||||||
$authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false);
|
$authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false);
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
@ -307,7 +322,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
|
|
||||||
public function testRenderViewTwig()
|
public function testRenderViewTwig()
|
||||||
{
|
{
|
||||||
$twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
|
$twig = $this->createMock(Environment::class);
|
||||||
$twig->expects($this->once())->method('render')->willReturn('bar');
|
$twig->expects($this->once())->method('render')->willReturn('bar');
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
@ -321,7 +336,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
|
|
||||||
public function testRenderTwig()
|
public function testRenderTwig()
|
||||||
{
|
{
|
||||||
$twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
|
$twig = $this->createMock(Environment::class);
|
||||||
$twig->expects($this->once())->method('render')->willReturn('bar');
|
$twig->expects($this->once())->method('render')->willReturn('bar');
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
@ -335,7 +350,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
|
|
||||||
public function testStreamTwig()
|
public function testStreamTwig()
|
||||||
{
|
{
|
||||||
$twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
|
$twig = $this->createMock(Environment::class);
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
$container->set('twig', $twig);
|
$container->set('twig', $twig);
|
||||||
@ -343,12 +358,12 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
$controller = $this->createController();
|
$controller = $this->createController();
|
||||||
$controller->setContainer($container);
|
$controller->setContainer($container);
|
||||||
|
|
||||||
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\StreamedResponse::class, $controller->stream('foo'));
|
$this->assertInstanceOf(StreamedResponse::class, $controller->stream('foo'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRedirectToRoute()
|
public function testRedirectToRoute()
|
||||||
{
|
{
|
||||||
$router = $this->getMockBuilder(\Symfony\Component\Routing\RouterInterface::class)->getMock();
|
$router = $this->createMock(RouterInterface::class);
|
||||||
$router->expects($this->once())->method('generate')->willReturn('/foo');
|
$router->expects($this->once())->method('generate')->willReturn('/foo');
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
@ -358,7 +373,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
$controller->setContainer($container);
|
$controller->setContainer($container);
|
||||||
$response = $controller->redirectToRoute('foo');
|
$response = $controller->redirectToRoute('foo');
|
||||||
|
|
||||||
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $response);
|
$this->assertInstanceOf(RedirectResponse::class, $response);
|
||||||
$this->assertSame('/foo', $response->getTargetUrl());
|
$this->assertSame('/foo', $response->getTargetUrl());
|
||||||
$this->assertSame(302, $response->getStatusCode());
|
$this->assertSame(302, $response->getStatusCode());
|
||||||
}
|
}
|
||||||
@ -369,7 +384,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
public function testAddFlash()
|
public function testAddFlash()
|
||||||
{
|
{
|
||||||
$flashBag = new FlashBag();
|
$flashBag = new FlashBag();
|
||||||
$session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\Session::class)->getMock();
|
$session = $this->createMock(Session::class);
|
||||||
$session->expects($this->once())->method('getFlashBag')->willReturn($flashBag);
|
$session->expects($this->once())->method('getFlashBag')->willReturn($flashBag);
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
@ -386,12 +401,12 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
{
|
{
|
||||||
$controller = $this->createController();
|
$controller = $this->createController();
|
||||||
|
|
||||||
$this->assertInstanceOf(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class, $controller->createAccessDeniedException());
|
$this->assertInstanceOf(AccessDeniedException::class, $controller->createAccessDeniedException());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsCsrfTokenValid()
|
public function testIsCsrfTokenValid()
|
||||||
{
|
{
|
||||||
$tokenManager = $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock();
|
$tokenManager = $this->createMock(CsrfTokenManagerInterface::class);
|
||||||
$tokenManager->expects($this->once())->method('isTokenValid')->willReturn(true);
|
$tokenManager->expects($this->once())->method('isTokenValid')->willReturn(true);
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
@ -405,7 +420,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
|
|
||||||
public function testGenerateUrl()
|
public function testGenerateUrl()
|
||||||
{
|
{
|
||||||
$router = $this->getMockBuilder(\Symfony\Component\Routing\RouterInterface::class)->getMock();
|
$router = $this->createMock(RouterInterface::class);
|
||||||
$router->expects($this->once())->method('generate')->willReturn('/foo');
|
$router->expects($this->once())->method('generate')->willReturn('/foo');
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
@ -422,7 +437,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
$controller = $this->createController();
|
$controller = $this->createController();
|
||||||
$response = $controller->redirect('https://dunglas.fr', 301);
|
$response = $controller->redirect('https://dunglas.fr', 301);
|
||||||
|
|
||||||
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $response);
|
$this->assertInstanceOf(RedirectResponse::class, $response);
|
||||||
$this->assertSame('https://dunglas.fr', $response->getTargetUrl());
|
$this->assertSame('https://dunglas.fr', $response->getTargetUrl());
|
||||||
$this->assertSame(301, $response->getStatusCode());
|
$this->assertSame(301, $response->getStatusCode());
|
||||||
}
|
}
|
||||||
@ -432,7 +447,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenderViewTemplating()
|
public function testRenderViewTemplating()
|
||||||
{
|
{
|
||||||
$templating = $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::class)->getMock();
|
$templating = $this->createMock(EngineInterface::class);
|
||||||
$templating->expects($this->once())->method('render')->willReturn('bar');
|
$templating->expects($this->once())->method('render')->willReturn('bar');
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
@ -449,7 +464,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenderTemplating()
|
public function testRenderTemplating()
|
||||||
{
|
{
|
||||||
$templating = $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::class)->getMock();
|
$templating = $this->createMock(EngineInterface::class);
|
||||||
$templating->expects($this->once())->method('render')->willReturn('bar');
|
$templating->expects($this->once())->method('render')->willReturn('bar');
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
@ -466,7 +481,7 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testStreamTemplating()
|
public function testStreamTemplating()
|
||||||
{
|
{
|
||||||
$templating = $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::class)->getMock();
|
$templating = $this->createMock(EngineInterface::class);
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
$container->set('templating', $templating);
|
$container->set('templating', $templating);
|
||||||
@ -474,21 +489,21 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
$controller = $this->createController();
|
$controller = $this->createController();
|
||||||
$controller->setContainer($container);
|
$controller->setContainer($container);
|
||||||
|
|
||||||
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\StreamedResponse::class, $controller->stream('foo'));
|
$this->assertInstanceOf(StreamedResponse::class, $controller->stream('foo'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateNotFoundException()
|
public function testCreateNotFoundException()
|
||||||
{
|
{
|
||||||
$controller = $this->createController();
|
$controller = $this->createController();
|
||||||
|
|
||||||
$this->assertInstanceOf(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class, $controller->createNotFoundException());
|
$this->assertInstanceOf(NotFoundHttpException::class, $controller->createNotFoundException());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateForm()
|
public function testCreateForm()
|
||||||
{
|
{
|
||||||
$form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock());
|
$form = new Form($this->createMock(FormConfigInterface::class));
|
||||||
|
|
||||||
$formFactory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
|
$formFactory = $this->createMock(FormFactoryInterface::class);
|
||||||
$formFactory->expects($this->once())->method('create')->willReturn($form);
|
$formFactory->expects($this->once())->method('create')->willReturn($form);
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
@ -502,9 +517,9 @@ abstract class ControllerTraitTest extends TestCase
|
|||||||
|
|
||||||
public function testCreateFormBuilder()
|
public function testCreateFormBuilder()
|
||||||
{
|
{
|
||||||
$formBuilder = $this->getMockBuilder(\Symfony\Component\Form\FormBuilderInterface::class)->getMock();
|
$formBuilder = $this->createMock(FormBuilderInterface::class);
|
||||||
|
|
||||||
$formFactory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
|
$formFactory = $this->createMock(FormFactoryInterface::class);
|
||||||
$formFactory->expects($this->once())->method('createBuilder')->willReturn($formBuilder);
|
$formFactory->expects($this->once())->method('createBuilder')->willReturn($formBuilder);
|
||||||
|
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
|
@ -85,7 +85,7 @@ class RedirectControllerTest extends TestCase
|
|||||||
|
|
||||||
$request->attributes = new ParameterBag($attributes);
|
$request->attributes = new ParameterBag($attributes);
|
||||||
|
|
||||||
$router = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
|
$router = $this->createMock(UrlGeneratorInterface::class);
|
||||||
$router
|
$router
|
||||||
->expects($this->exactly(2))
|
->expects($this->exactly(2))
|
||||||
->method('generate')
|
->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 = $this->createRequestObject($scheme, $host, $port, $baseUrl, 'b.se=zaza&f[%2525][%26][%3D][p.c]=d');
|
||||||
$request->attributes = new ParameterBag(['_route_params' => ['base2' => 'zaza']]);
|
$request->attributes = new ParameterBag(['_route_params' => ['base2' => 'zaza']]);
|
||||||
$urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
|
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||||
$urlGenerator->expects($this->exactly(2))
|
$urlGenerator->expects($this->exactly(2))
|
||||||
->method('generate')
|
->method('generate')
|
||||||
->willReturn('/test?b.se=zaza&base2=zaza&f[%2525][%26][%3D][p.c]=d')
|
->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 = $this->createRequestObject($scheme, $host, $port, $baseUrl, 'b.se=zaza');
|
||||||
$request->attributes = new ParameterBag(['_route_params' => ['b.se' => 'zouzou']]);
|
$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);
|
$urlGenerator->expects($this->exactly(2))->method('generate')->willReturn('/test?b.se=zouzou')->with('/test', ['b.se' => 'zouzou'], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
|
|
||||||
$controller = new RedirectController($urlGenerator);
|
$controller = new RedirectController($urlGenerator);
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Controller\TemplateController;
|
use Symfony\Bundle\FrameworkBundle\Controller\TemplateController;
|
||||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||||
|
use Twig\Environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||||
@ -22,7 +23,7 @@ class TemplateControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testTwig()
|
public function testTwig()
|
||||||
{
|
{
|
||||||
$twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
|
$twig = $this->createMock(Environment::class);
|
||||||
$twig->expects($this->exactly(2))->method('render')->willReturn('bar');
|
$twig->expects($this->exactly(2))->method('render')->willReturn('bar');
|
||||||
|
|
||||||
$controller = new TemplateController($twig);
|
$controller = new TemplateController($twig);
|
||||||
@ -36,7 +37,7 @@ class TemplateControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTemplating()
|
public function testTemplating()
|
||||||
{
|
{
|
||||||
$templating = $this->getMockBuilder(EngineInterface::class)->getMock();
|
$templating = $this->createMock(EngineInterface::class);
|
||||||
$templating->expects($this->exactly(2))->method('render')->willReturn('bar');
|
$templating->expects($this->exactly(2))->method('render')->willReturn('bar');
|
||||||
|
|
||||||
$controller = new TemplateController(null, $templating);
|
$controller = new TemplateController(null, $templating);
|
||||||
|
@ -17,6 +17,7 @@ use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
|||||||
use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
|
use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
|
||||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +62,7 @@ class CachePoolPrunerPassTest extends TestCase
|
|||||||
|
|
||||||
public function testCompilerPassThrowsOnInvalidDefinitionClass()
|
public function testCompilerPassThrowsOnInvalidDefinitionClass()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
$this->expectExceptionMessage('Class "Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\NotFound" used for service "pool.not-found" cannot be found.');
|
$this->expectExceptionMessage('Class "Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\NotFound" used for service "pool.not-found" cannot be found.');
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->register('console.command.cache_pool_prune')->addArgument([]);
|
$container->register('console.command.cache_pool_prune')->addArgument([]);
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\WorkflowGuardListenerPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\WorkflowGuardListenerPass;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
||||||
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
|
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
@ -54,7 +55,7 @@ class WorkflowGuardListenerPassTest extends TestCase
|
|||||||
|
|
||||||
public function testExceptionIfTheTokenStorageServiceIsNotPresent()
|
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->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->setParameter('workflow.has_guard_listeners', true);
|
||||||
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);
|
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);
|
||||||
@ -66,7 +67,7 @@ class WorkflowGuardListenerPassTest extends TestCase
|
|||||||
|
|
||||||
public function testExceptionIfTheAuthorizationCheckerServiceIsNotPresent()
|
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->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->setParameter('workflow.has_guard_listeners', true);
|
||||||
$this->container->register('security.token_storage', TokenStorageInterface::class);
|
$this->container->register('security.token_storage', TokenStorageInterface::class);
|
||||||
@ -78,7 +79,7 @@ class WorkflowGuardListenerPassTest extends TestCase
|
|||||||
|
|
||||||
public function testExceptionIfTheAuthenticationTrustResolverServiceIsNotPresent()
|
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->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->setParameter('workflow.has_guard_listeners', true);
|
||||||
$this->container->register('security.token_storage', TokenStorageInterface::class);
|
$this->container->register('security.token_storage', TokenStorageInterface::class);
|
||||||
@ -90,7 +91,7 @@ class WorkflowGuardListenerPassTest extends TestCase
|
|||||||
|
|
||||||
public function testExceptionIfTheRoleHierarchyServiceIsNotPresent()
|
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->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->setParameter('workflow.has_guard_listeners', true);
|
||||||
$this->container->register('security.token_storage', TokenStorageInterface::class);
|
$this->container->register('security.token_storage', TokenStorageInterface::class);
|
||||||
|
@ -27,6 +27,7 @@ use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
|||||||
use Symfony\Component\Cache\Adapter\ProxyAdapter;
|
use Symfony\Component\Cache\Adapter\ProxyAdapter;
|
||||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||||
use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
|
use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
|
||||||
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||||
use Symfony\Component\DependencyInjection\ChildDefinition;
|
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
use Symfony\Component\DependencyInjection\Compiler\ResolveInstanceofConditionalsPass;
|
use Symfony\Component\DependencyInjection\Compiler\ResolveInstanceofConditionalsPass;
|
||||||
@ -37,10 +38,12 @@ use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
|
|||||||
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
|
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
use Symfony\Component\Form\Form;
|
||||||
use Symfony\Component\HttpClient\ScopingHttpClient;
|
use Symfony\Component\HttpClient\ScopingHttpClient;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\LoggerPass;
|
use Symfony\Component\HttpKernel\DependencyInjection\LoggerPass;
|
||||||
use Symfony\Component\Messenger\Transport\TransportFactory;
|
use Symfony\Component\Messenger\Transport\TransportFactory;
|
||||||
use Symfony\Component\PropertyAccess\PropertyAccessor;
|
use Symfony\Component\PropertyAccess\PropertyAccessor;
|
||||||
|
use Symfony\Component\Security\Core\Security;
|
||||||
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
|
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
|
||||||
use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
|
use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
|
||||||
use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
|
use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
|
||||||
@ -54,7 +57,10 @@ use Symfony\Component\Translation\DependencyInjection\TranslatorPass;
|
|||||||
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
|
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
|
||||||
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
|
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
|
||||||
use Symfony\Component\Validator\Util\LegacyTranslatorProxy;
|
use Symfony\Component\Validator\Util\LegacyTranslatorProxy;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
use Symfony\Component\Workflow;
|
use Symfony\Component\Workflow;
|
||||||
|
use Symfony\Component\Workflow\Exception\InvalidDefinitionException;
|
||||||
use Symfony\Component\Workflow\Metadata\InMemoryMetadataStore;
|
use Symfony\Component\Workflow\Metadata\InMemoryMetadataStore;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
@ -331,28 +337,28 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
|
|
||||||
public function testWorkflowAreValidated()
|
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->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');
|
$this->createContainerFromFile('workflow_not_valid');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWorkflowCannotHaveBothTypeAndService()
|
public function testWorkflowCannotHaveBothTypeAndService()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
$this->expectException(InvalidConfigurationException::class);
|
||||||
$this->expectExceptionMessage('"type" and "service" cannot be used together.');
|
$this->expectExceptionMessage('"type" and "service" cannot be used together.');
|
||||||
$this->createContainerFromFile('workflow_legacy_with_type_and_service');
|
$this->createContainerFromFile('workflow_legacy_with_type_and_service');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWorkflowCannotHaveBothSupportsAndSupportStrategy()
|
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->expectExceptionMessage('"supports" and "support_strategy" cannot be used together.');
|
||||||
$this->createContainerFromFile('workflow_with_support_and_support_strategy');
|
$this->createContainerFromFile('workflow_with_support_and_support_strategy');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWorkflowShouldHaveOneOfSupportsAndSupportStrategy()
|
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->expectExceptionMessage('"supports" or "support_strategy" should be configured.');
|
||||||
$this->createContainerFromFile('workflow_without_support_and_support_strategy');
|
$this->createContainerFromFile('workflow_without_support_and_support_strategy');
|
||||||
}
|
}
|
||||||
@ -362,7 +368,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWorkflowCannotHaveBothArgumentsAndService()
|
public function testWorkflowCannotHaveBothArgumentsAndService()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
$this->expectException(InvalidConfigurationException::class);
|
||||||
$this->expectExceptionMessage('"arguments" and "service" cannot be used together.');
|
$this->expectExceptionMessage('"arguments" and "service" cannot be used together.');
|
||||||
$this->createContainerFromFile('workflow_legacy_with_arguments_and_service');
|
$this->createContainerFromFile('workflow_legacy_with_arguments_and_service');
|
||||||
}
|
}
|
||||||
@ -524,7 +530,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
|
|
||||||
public function testRouterRequiresResourceOption()
|
public function testRouterRequiresResourceOption()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
$this->expectException(InvalidConfigurationException::class);
|
||||||
$container = $this->createContainer();
|
$container = $this->createContainer();
|
||||||
$loader = new FrameworkExtension();
|
$loader = new FrameworkExtension();
|
||||||
$loader->load([['router' => true]], $container);
|
$loader->load([['router' => true]], $container);
|
||||||
@ -838,19 +844,19 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
$this->assertSame($container->getParameter('kernel.cache_dir').'/translations', $options['cache_dir']);
|
$this->assertSame($container->getParameter('kernel.cache_dir').'/translations', $options['cache_dir']);
|
||||||
|
|
||||||
$files = array_map('realpath', $options['resource_files']['en']);
|
$files = array_map('realpath', $options['resource_files']['en']);
|
||||||
$ref = new \ReflectionClass(\Symfony\Component\Validator\Validation::class);
|
$ref = new \ReflectionClass(Validation::class);
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR),
|
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR),
|
||||||
$files,
|
$files,
|
||||||
'->registerTranslatorConfiguration() finds Validator translation resources'
|
'->registerTranslatorConfiguration() finds Validator translation resources'
|
||||||
);
|
);
|
||||||
$ref = new \ReflectionClass(\Symfony\Component\Form\Form::class);
|
$ref = new \ReflectionClass(Form::class);
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR),
|
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR),
|
||||||
$files,
|
$files,
|
||||||
'->registerTranslatorConfiguration() finds Form translation resources'
|
'->registerTranslatorConfiguration() finds Form translation resources'
|
||||||
);
|
);
|
||||||
$ref = new \ReflectionClass(\Symfony\Component\Security\Core\Security::class);
|
$ref = new \ReflectionClass(Security::class);
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
strtr(\dirname($ref->getFileName()).'/Resources/translations/security.en.xlf', '/', \DIRECTORY_SEPARATOR),
|
strtr(\dirname($ref->getFileName()).'/Resources/translations/security.en.xlf', '/', \DIRECTORY_SEPARATOR),
|
||||||
$files,
|
$files,
|
||||||
@ -921,7 +927,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTemplatingRequiresAtLeastOneEngine()
|
public function testTemplatingRequiresAtLeastOneEngine()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
$this->expectException(InvalidConfigurationException::class);
|
||||||
$container = $this->createContainer();
|
$container = $this->createContainer();
|
||||||
$loader = new FrameworkExtension();
|
$loader = new FrameworkExtension();
|
||||||
$loader->load([['templating' => null]], $container);
|
$loader->load([['templating' => null]], $container);
|
||||||
@ -932,7 +938,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
$container = $this->createContainerFromFile('full');
|
$container = $this->createContainerFromFile('full');
|
||||||
$projectDir = $container->getParameter('kernel.project_dir');
|
$projectDir = $container->getParameter('kernel.project_dir');
|
||||||
|
|
||||||
$ref = new \ReflectionClass(\Symfony\Component\Form\Form::class);
|
$ref = new \ReflectionClass(Form::class);
|
||||||
$xmlMappings = [
|
$xmlMappings = [
|
||||||
\dirname($ref->getFileName()).'/Resources/config/validation.xml',
|
\dirname($ref->getFileName()).'/Resources/config/validation.xml',
|
||||||
strtr($projectDir.'/config/validator/foo.xml', '/', \DIRECTORY_SEPARATOR),
|
strtr($projectDir.'/config/validator/foo.xml', '/', \DIRECTORY_SEPARATOR),
|
||||||
@ -969,7 +975,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = $this->createContainerFromFile('validation_annotations', ['kernel.charset' => 'UTF-8'], false);
|
$container = $this->createContainerFromFile('validation_annotations', ['kernel.charset' => 'UTF-8'], false);
|
||||||
|
|
||||||
$this->assertInstanceOf(\Symfony\Component\Validator\Validator\ValidatorInterface::class, $container->get('validator'));
|
$this->assertInstanceOf(ValidatorInterface::class, $container->get('validator'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAnnotations()
|
public function testAnnotations()
|
||||||
@ -1097,7 +1103,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCannotConfigureStrictEmailAndEmailValidationModeAtTheSameTime()
|
public function testCannotConfigureStrictEmailAndEmailValidationModeAtTheSameTime()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
$this->expectException(InvalidConfigurationException::class);
|
||||||
$this->expectExceptionMessage('"strict_email" and "email_validation_mode" cannot be used together.');
|
$this->expectExceptionMessage('"strict_email" and "email_validation_mode" cannot be used together.');
|
||||||
$this->createContainerFromFile('validation_strict_email_and_validation_mode');
|
$this->createContainerFromFile('validation_strict_email_and_validation_mode');
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
|
|||||||
use Symfony\Component\Config\FileLocator;
|
use Symfony\Component\Config\FileLocator;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||||
|
use Symfony\Component\Workflow\Exception\InvalidDefinitionException;
|
||||||
|
|
||||||
class PhpFrameworkExtensionTest extends FrameworkExtensionTest
|
class PhpFrameworkExtensionTest extends FrameworkExtensionTest
|
||||||
{
|
{
|
||||||
@ -55,7 +56,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
|
|||||||
|
|
||||||
public function testWorkflowValidationStateMachine()
|
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->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) {
|
$this->createContainerFromClosure(function ($container) {
|
||||||
$container->loadFromExtension('framework', [
|
$container->loadFromExtension('framework', [
|
||||||
@ -157,7 +158,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
|
|||||||
*/
|
*/
|
||||||
public function testWorkflowValidationSingleState()
|
public function testWorkflowValidationSingleState()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class);
|
$this->expectException(InvalidDefinitionException::class);
|
||||||
$this->expectExceptionMessage('The marking store of workflow "article" can not store many places. But the transition "a_to_b" has too many output (2). Only one is accepted.');
|
$this->expectExceptionMessage('The marking store of workflow "article" can not store many places. But the transition "a_to_b" has too many output (2). Only one is accepted.');
|
||||||
$this->createContainerFromClosure(function ($container) {
|
$this->createContainerFromClosure(function ($container) {
|
||||||
$container->loadFromExtension('framework', [
|
$container->loadFromExtension('framework', [
|
||||||
|
@ -26,12 +26,12 @@ class ResolveControllerNameSubscriberTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testReplacesControllerAttribute()
|
public function testReplacesControllerAttribute()
|
||||||
{
|
{
|
||||||
$parser = $this->getMockBuilder(ControllerNameParser::class)->disableOriginalConstructor()->getMock();
|
$parser = $this->createMock(ControllerNameParser::class);
|
||||||
$parser->expects($this->any())
|
$parser->expects($this->any())
|
||||||
->method('parse')
|
->method('parse')
|
||||||
->with('AppBundle:Starting:format')
|
->with('AppBundle:Starting:format')
|
||||||
->willReturn('App\\Final\\Format::methodName');
|
->willReturn('App\\Final\\Format::methodName');
|
||||||
$httpKernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
|
$httpKernel = $this->createMock(HttpKernelInterface::class);
|
||||||
|
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$request->attributes->set('_controller', 'AppBundle:Starting:format');
|
$request->attributes->set('_controller', 'AppBundle:Starting:format');
|
||||||
@ -50,10 +50,10 @@ class ResolveControllerNameSubscriberTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testSkipsOtherControllerFormats($controller)
|
public function testSkipsOtherControllerFormats($controller)
|
||||||
{
|
{
|
||||||
$parser = $this->getMockBuilder(ControllerNameParser::class)->disableOriginalConstructor()->getMock();
|
$parser = $this->createMock(ControllerNameParser::class);
|
||||||
$parser->expects($this->never())
|
$parser->expects($this->never())
|
||||||
->method('parse');
|
->method('parse');
|
||||||
$httpKernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
|
$httpKernel = $this->createMock(HttpKernelInterface::class);
|
||||||
|
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$request->attributes->set('_controller', $controller);
|
$request->attributes->set('_controller', $controller);
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand;
|
use Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand;
|
||||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group functional
|
* @group functional
|
||||||
@ -67,7 +68,7 @@ class CachePoolClearCommandTest extends AbstractWebTestCase
|
|||||||
|
|
||||||
public function testClearUnexistingPool()
|
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->expectExceptionMessage('You have requested a non-existent service "unknown_pool"');
|
||||||
$this->createCommandTester()
|
$this->createCommandTester()
|
||||||
->execute(['pools' => ['unknown_pool']], ['decorated' => false]);
|
->execute(['pools' => ['unknown_pool']], ['decorated' => false]);
|
||||||
|
@ -10,6 +10,7 @@ use Symfony\Component\Config\Loader\LoaderResolver;
|
|||||||
use Symfony\Component\Config\Loader\LoaderResolverInterface;
|
use Symfony\Component\Config\Loader\LoaderResolverInterface;
|
||||||
use Symfony\Component\Routing\Route;
|
use Symfony\Component\Routing\Route;
|
||||||
use Symfony\Component\Routing\RouteCollection;
|
use Symfony\Component\Routing\RouteCollection;
|
||||||
|
use Symfony\Component\Routing\RouteCompiler;
|
||||||
|
|
||||||
class DelegatingLoaderTest extends TestCase
|
class DelegatingLoaderTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -19,20 +20,16 @@ class DelegatingLoaderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testConstructorApi()
|
public function testConstructorApi()
|
||||||
{
|
{
|
||||||
$controllerNameParser = $this->getMockBuilder(ControllerNameParser::class)
|
$controllerNameParser = $this->createMock(ControllerNameParser::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
new DelegatingLoader($controllerNameParser, new LoaderResolver());
|
new DelegatingLoader($controllerNameParser, new LoaderResolver());
|
||||||
$this->assertTrue(true, '__construct() takes a ControllerNameParser and LoaderResolverInterface respectively as its first and second argument.');
|
$this->assertTrue(true, '__construct() takes a ControllerNameParser and LoaderResolverInterface respectively as its first and second argument.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoadDefaultOptions()
|
public function testLoadDefaultOptions()
|
||||||
{
|
{
|
||||||
$loaderResolver = $this->getMockBuilder(LoaderResolverInterface::class)
|
$loaderResolver = $this->createMock(LoaderResolverInterface::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$loader = $this->getMockBuilder(LoaderInterface::class)->getMock();
|
$loader = $this->createMock(LoaderInterface::class);
|
||||||
|
|
||||||
$loaderResolver->expects($this->once())
|
$loaderResolver->expects($this->once())
|
||||||
->method('resolve')
|
->method('resolve')
|
||||||
@ -52,13 +49,13 @@ class DelegatingLoaderTest extends TestCase
|
|||||||
$this->assertCount(2, $loadedRouteCollection);
|
$this->assertCount(2, $loadedRouteCollection);
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'compiler_class' => 'Symfony\Component\Routing\RouteCompiler',
|
'compiler_class' => RouteCompiler::class,
|
||||||
'utf8' => false,
|
'utf8' => false,
|
||||||
];
|
];
|
||||||
$this->assertSame($expected, $routeCollection->get('foo')->getOptions());
|
$this->assertSame($expected, $routeCollection->get('foo')->getOptions());
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'compiler_class' => 'Symfony\Component\Routing\RouteCompiler',
|
'compiler_class' => RouteCompiler::class,
|
||||||
'foo' => 123,
|
'foo' => 123,
|
||||||
'utf8' => true,
|
'utf8' => true,
|
||||||
];
|
];
|
||||||
@ -71,20 +68,15 @@ class DelegatingLoaderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testLoad()
|
public function testLoad()
|
||||||
{
|
{
|
||||||
$controllerNameParser = $this->getMockBuilder(ControllerNameParser::class)
|
$controllerNameParser = $this->createMock(ControllerNameParser::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$controllerNameParser->expects($this->once())
|
$controllerNameParser->expects($this->once())
|
||||||
->method('parse')
|
->method('parse')
|
||||||
->with('foo:bar:baz')
|
->with('foo:bar:baz')
|
||||||
->willReturn('some_parsed::controller');
|
->willReturn('some_parsed::controller');
|
||||||
|
|
||||||
$loaderResolver = $this->getMockBuilder(LoaderResolverInterface::class)
|
$loaderResolver = $this->createMock(LoaderResolverInterface::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$loader = $this->getMockBuilder(LoaderInterface::class)->getMock();
|
$loader = $this->createMock(LoaderInterface::class);
|
||||||
|
|
||||||
$loaderResolver->expects($this->once())
|
$loaderResolver->expects($this->once())
|
||||||
->method('resolve')
|
->method('resolve')
|
||||||
|
@ -17,6 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Routing\Router;
|
|||||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||||
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
|
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
|
||||||
use Symfony\Component\DependencyInjection\Container;
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
|
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
||||||
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||||
use Symfony\Component\Routing\Route;
|
use Symfony\Component\Routing\Route;
|
||||||
use Symfony\Component\Routing\RouteCollection;
|
use Symfony\Component\Routing\RouteCollection;
|
||||||
@ -375,7 +376,7 @@ class RouterTest extends TestCase
|
|||||||
|
|
||||||
public function testExceptionOnNonExistentParameterWithSfContainer()
|
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".');
|
$this->expectExceptionMessage('You have requested a non-existent parameter "nope".');
|
||||||
$routes = new RouteCollection();
|
$routes = new RouteCollection();
|
||||||
|
|
||||||
@ -504,7 +505,7 @@ class RouterTest extends TestCase
|
|||||||
|
|
||||||
private function getServiceContainer(RouteCollection $routes): Container
|
private function getServiceContainer(RouteCollection $routes): Container
|
||||||
{
|
{
|
||||||
$loader = $this->getMockBuilder(LoaderInterface::class)->getMock();
|
$loader = $this->createMock(LoaderInterface::class);
|
||||||
|
|
||||||
$loader
|
$loader
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
@ -525,7 +526,7 @@ class RouterTest extends TestCase
|
|||||||
|
|
||||||
private function getPsr11ServiceContainer(RouteCollection $routes): ContainerInterface
|
private function getPsr11ServiceContainer(RouteCollection $routes): ContainerInterface
|
||||||
{
|
{
|
||||||
$loader = $this->getMockBuilder(LoaderInterface::class)->getMock();
|
$loader = $this->createMock(LoaderInterface::class);
|
||||||
|
|
||||||
$loader
|
$loader
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
@ -533,7 +534,7 @@ class RouterTest extends TestCase
|
|||||||
->willReturn($routes)
|
->willReturn($routes)
|
||||||
;
|
;
|
||||||
|
|
||||||
$sc = $this->getMockBuilder(ContainerInterface::class)->getMock();
|
$sc = $this->createMock(ContainerInterface::class);
|
||||||
|
|
||||||
$sc
|
$sc
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
@ -546,7 +547,7 @@ class RouterTest extends TestCase
|
|||||||
|
|
||||||
private function getParameterBag(array $params = []): ContainerInterface
|
private function getParameterBag(array $params = []): ContainerInterface
|
||||||
{
|
{
|
||||||
$bag = $this->getMockBuilder(ContainerInterface::class)->getMock();
|
$bag = $this->createMock(ContainerInterface::class);
|
||||||
$bag
|
$bag
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine;
|
use Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
@ -88,7 +89,7 @@ class DelegatingEngineTest extends TestCase
|
|||||||
|
|
||||||
private function getEngineMock($template, $supports)
|
private function getEngineMock($template, $supports)
|
||||||
{
|
{
|
||||||
$engine = $this->getMockBuilder(\Symfony\Component\Templating\EngineInterface::class)->getMock();
|
$engine = $this->createMock(EngineInterface::class);
|
||||||
|
|
||||||
$engine->expects($this->once())
|
$engine->expects($this->once())
|
||||||
->method('supports')
|
->method('supports')
|
||||||
@ -100,7 +101,7 @@ class DelegatingEngineTest extends TestCase
|
|||||||
|
|
||||||
private function getFrameworkEngineMock($template, $supports)
|
private function getFrameworkEngineMock($template, $supports)
|
||||||
{
|
{
|
||||||
$engine = $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::class)->getMock();
|
$engine = $this->createMock(\Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::class);
|
||||||
|
|
||||||
$engine->expects($this->once())
|
$engine->expects($this->once())
|
||||||
->method('supports')
|
->method('supports')
|
||||||
|
@ -14,6 +14,9 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
|
use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||||
use Symfony\Component\DependencyInjection\Container;
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
@ -36,14 +39,14 @@ class GlobalVariablesTest extends TestCase
|
|||||||
|
|
||||||
public function testGetTokenNoToken()
|
public function testGetTokenNoToken()
|
||||||
{
|
{
|
||||||
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
|
$tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||||
$this->container->set('security.token_storage', $tokenStorage);
|
$this->container->set('security.token_storage', $tokenStorage);
|
||||||
$this->assertNull($this->globals->getToken());
|
$this->assertNull($this->globals->getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetToken()
|
public function testGetToken()
|
||||||
{
|
{
|
||||||
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
|
$tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||||
|
|
||||||
$this->container->set('security.token_storage', $tokenStorage);
|
$this->container->set('security.token_storage', $tokenStorage);
|
||||||
|
|
||||||
@ -62,7 +65,7 @@ class GlobalVariablesTest extends TestCase
|
|||||||
|
|
||||||
public function testGetUserNoToken()
|
public function testGetUserNoToken()
|
||||||
{
|
{
|
||||||
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
|
$tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||||
$this->container->set('security.token_storage', $tokenStorage);
|
$this->container->set('security.token_storage', $tokenStorage);
|
||||||
$this->assertNull($this->globals->getUser());
|
$this->assertNull($this->globals->getUser());
|
||||||
}
|
}
|
||||||
@ -72,8 +75,8 @@ class GlobalVariablesTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetUser($user, $expectedUser)
|
public function testGetUser($user, $expectedUser)
|
||||||
{
|
{
|
||||||
$tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
|
$tokenStorage = $this->createMock(TokenStorageInterface::class);
|
||||||
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
|
$token = $this->createMock(TokenInterface::class);
|
||||||
|
|
||||||
$this->container->set('security.token_storage', $tokenStorage);
|
$this->container->set('security.token_storage', $tokenStorage);
|
||||||
|
|
||||||
@ -92,9 +95,9 @@ class GlobalVariablesTest extends TestCase
|
|||||||
|
|
||||||
public function getUserProvider()
|
public function getUserProvider()
|
||||||
{
|
{
|
||||||
$user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock();
|
$user = $this->createMock(UserInterface::class);
|
||||||
$std = new \stdClass();
|
$std = new \stdClass();
|
||||||
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
|
$token = $this->createMock(TokenInterface::class);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
[$user, $user],
|
[$user, $user],
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||||
use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper;
|
use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser;
|
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator;
|
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator;
|
||||||
@ -36,7 +37,7 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
|||||||
{
|
{
|
||||||
// should be moved to the Form component once absolute file paths are supported
|
// should be moved to the Form component once absolute file paths are supported
|
||||||
// by the default name parser in the Templating component
|
// by the default name parser in the Templating component
|
||||||
$reflClass = new \ReflectionClass(\Symfony\Bundle\FrameworkBundle\FrameworkBundle::class);
|
$reflClass = new \ReflectionClass(FrameworkBundle::class);
|
||||||
$root = realpath(\dirname($reflClass->getFileName()).'/Resources/views');
|
$root = realpath(\dirname($reflClass->getFileName()).'/Resources/views');
|
||||||
$rootTheme = realpath(__DIR__.'/Resources');
|
$rootTheme = realpath(__DIR__.'/Resources');
|
||||||
$templateNameParser = new StubTemplateNameParser($root, $rootTheme);
|
$templateNameParser = new StubTemplateNameParser($root, $rootTheme);
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||||
use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper;
|
use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser;
|
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator;
|
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator;
|
||||||
@ -80,7 +81,7 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest
|
|||||||
{
|
{
|
||||||
// should be moved to the Form component once absolute file paths are supported
|
// should be moved to the Form component once absolute file paths are supported
|
||||||
// by the default name parser in the Templating component
|
// by the default name parser in the Templating component
|
||||||
$reflClass = new \ReflectionClass(\Symfony\Bundle\FrameworkBundle\FrameworkBundle::class);
|
$reflClass = new \ReflectionClass(FrameworkBundle::class);
|
||||||
$root = realpath(\dirname($reflClass->getFileName()).'/Resources/views');
|
$root = realpath(\dirname($reflClass->getFileName()).'/Resources/views');
|
||||||
$rootTheme = realpath(__DIR__.'/Resources');
|
$rootTheme = realpath(__DIR__.'/Resources');
|
||||||
$templateNameParser = new StubTemplateNameParser($root, $rootTheme);
|
$templateNameParser = new StubTemplateNameParser($root, $rootTheme);
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
|
|||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bundle\FrameworkBundle\Templating\Helper\StopwatchHelper;
|
use Symfony\Bundle\FrameworkBundle\Templating\Helper\StopwatchHelper;
|
||||||
|
use Symfony\Component\Stopwatch\Stopwatch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
@ -21,7 +22,7 @@ class StopwatchHelperTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testDevEnvironment()
|
public function testDevEnvironment()
|
||||||
{
|
{
|
||||||
$stopwatch = $this->getMockBuilder(\Symfony\Component\Stopwatch\Stopwatch::class)->getMock();
|
$stopwatch = $this->createMock(Stopwatch::class);
|
||||||
$stopwatch->expects($this->once())
|
$stopwatch->expects($this->once())
|
||||||
->method('start')
|
->method('start')
|
||||||
->with('foo');
|
->with('foo');
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Loader;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator;
|
use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator;
|
||||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||||
|
use Symfony\Component\Config\FileLocator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
@ -90,7 +91,7 @@ class TemplateLocatorTest extends TestCase
|
|||||||
protected function getFileLocator()
|
protected function getFileLocator()
|
||||||
{
|
{
|
||||||
return $this
|
return $this
|
||||||
->getMockBuilder(\Symfony\Component\Config\FileLocator::class)
|
->getMockBuilder(FileLocator::class)
|
||||||
->setMethods(['locate'])
|
->setMethods(['locate'])
|
||||||
->setConstructorArgs(['/path/to/fallback'])
|
->setConstructorArgs(['/path/to/fallback'])
|
||||||
->getMock()
|
->getMock()
|
||||||
|
@ -19,6 +19,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||||
|
use Symfony\Component\Templating\Loader\Loader;
|
||||||
use Symfony\Component\Templating\TemplateNameParser;
|
use Symfony\Component\Templating\TemplateNameParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,7 +30,7 @@ class PhpEngineTest extends TestCase
|
|||||||
public function testEvaluateAddsAppGlobal()
|
public function testEvaluateAddsAppGlobal()
|
||||||
{
|
{
|
||||||
$container = $this->getContainer();
|
$container = $this->getContainer();
|
||||||
$loader = $this->getMockForAbstractClass(\Symfony\Component\Templating\Loader\Loader::class);
|
$loader = $this->getMockForAbstractClass(Loader::class);
|
||||||
$engine = new PhpEngine(new TemplateNameParser(), $container, $loader, $app = new GlobalVariables($container));
|
$engine = new PhpEngine(new TemplateNameParser(), $container, $loader, $app = new GlobalVariables($container));
|
||||||
$globals = $engine->getGlobals();
|
$globals = $engine->getGlobals();
|
||||||
$this->assertSame($app, $globals['app']);
|
$this->assertSame($app, $globals['app']);
|
||||||
@ -38,7 +39,7 @@ class PhpEngineTest extends TestCase
|
|||||||
public function testEvaluateWithoutAvailableRequest()
|
public function testEvaluateWithoutAvailableRequest()
|
||||||
{
|
{
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
$loader = $this->getMockForAbstractClass(\Symfony\Component\Templating\Loader\Loader::class);
|
$loader = $this->getMockForAbstractClass(Loader::class);
|
||||||
$engine = new PhpEngine(new TemplateNameParser(), $container, $loader, new GlobalVariables($container));
|
$engine = new PhpEngine(new TemplateNameParser(), $container, $loader, new GlobalVariables($container));
|
||||||
|
|
||||||
$this->assertFalse($container->has('request_stack'));
|
$this->assertFalse($container->has('request_stack'));
|
||||||
@ -50,7 +51,7 @@ class PhpEngineTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
$container = $this->getContainer();
|
$container = $this->getContainer();
|
||||||
$loader = $this->getMockForAbstractClass(\Symfony\Component\Templating\Loader\Loader::class);
|
$loader = $this->getMockForAbstractClass(Loader::class);
|
||||||
$engine = new PhpEngine(new TemplateNameParser(), $container, $loader);
|
$engine = new PhpEngine(new TemplateNameParser(), $container, $loader);
|
||||||
|
|
||||||
$engine->get('non-existing-helper');
|
$engine->get('non-existing-helper');
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
|
use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
|
||||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||||
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
use Symfony\Component\Templating\TemplateReference as BaseTemplateReference;
|
use Symfony\Component\Templating\TemplateReference as BaseTemplateReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,7 +26,7 @@ class TemplateNameParserTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
|
$kernel = $this->createMock(KernelInterface::class);
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getBundle')
|
->method('getBundle')
|
||||||
|
@ -20,6 +20,7 @@ use Symfony\Component\Stopwatch\StopwatchEvent;
|
|||||||
use Symfony\Component\Templating\Loader\Loader;
|
use Symfony\Component\Templating\Loader\Loader;
|
||||||
use Symfony\Component\Templating\Storage\StringStorage;
|
use Symfony\Component\Templating\Storage\StringStorage;
|
||||||
use Symfony\Component\Templating\TemplateNameParserInterface;
|
use Symfony\Component\Templating\TemplateNameParserInterface;
|
||||||
|
use Symfony\Component\Templating\TemplateReferenceInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
@ -49,13 +50,13 @@ class TimedPhpEngineTest extends TestCase
|
|||||||
|
|
||||||
private function getContainer(): Container
|
private function getContainer(): Container
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder(Container::class)->getMock();
|
return $this->createMock(Container::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getTemplateNameParser(): TemplateNameParserInterface
|
private function getTemplateNameParser(): TemplateNameParserInterface
|
||||||
{
|
{
|
||||||
$templateReference = $this->getMockBuilder(\Symfony\Component\Templating\TemplateReferenceInterface::class)->getMock();
|
$templateReference = $this->createMock(TemplateReferenceInterface::class);
|
||||||
$templateNameParser = $this->getMockBuilder(TemplateNameParserInterface::class)->getMock();
|
$templateNameParser = $this->createMock(TemplateNameParserInterface::class);
|
||||||
$templateNameParser->expects($this->any())
|
$templateNameParser->expects($this->any())
|
||||||
->method('parse')
|
->method('parse')
|
||||||
->willReturn($templateReference);
|
->willReturn($templateReference);
|
||||||
@ -65,9 +66,7 @@ class TimedPhpEngineTest extends TestCase
|
|||||||
|
|
||||||
private function getGlobalVariables(): GlobalVariables
|
private function getGlobalVariables(): GlobalVariables
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder(GlobalVariables::class)
|
return $this->createMock(GlobalVariables::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getStorage(): StringStorage
|
private function getStorage(): StringStorage
|
||||||
@ -92,13 +91,11 @@ class TimedPhpEngineTest extends TestCase
|
|||||||
|
|
||||||
private function getStopwatchEvent(): StopwatchEvent
|
private function getStopwatchEvent(): StopwatchEvent
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder(StopwatchEvent::class)
|
return $this->createMock(StopwatchEvent::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getStopwatch(): Stopwatch
|
private function getStopwatch(): Stopwatch
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder(Stopwatch::class)->getMock();
|
return $this->createMock(Stopwatch::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,14 @@
|
|||||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Translation;
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Translation;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Container\ContainerInterface;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Translation\Translator;
|
use Symfony\Bundle\FrameworkBundle\Translation\Translator;
|
||||||
use Symfony\Component\Config\Resource\DirectoryResource;
|
use Symfony\Component\Config\Resource\DirectoryResource;
|
||||||
use Symfony\Component\Config\Resource\FileExistenceResource;
|
use Symfony\Component\Config\Resource\FileExistenceResource;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
use Symfony\Component\Translation\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Translation\Formatter\MessageFormatter;
|
use Symfony\Component\Translation\Formatter\MessageFormatter;
|
||||||
|
use Symfony\Component\Translation\Loader\LoaderInterface;
|
||||||
use Symfony\Component\Translation\Loader\YamlFileLoader;
|
use Symfony\Component\Translation\Loader\YamlFileLoader;
|
||||||
use Symfony\Component\Translation\MessageCatalogue;
|
use Symfony\Component\Translation\MessageCatalogue;
|
||||||
|
|
||||||
@ -94,7 +96,7 @@ class TranslatorTest extends TestCase
|
|||||||
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));
|
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));
|
||||||
|
|
||||||
// do it another time as the cache is primed now
|
// 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');
|
$loader->expects($this->never())->method('load');
|
||||||
|
|
||||||
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]);
|
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]);
|
||||||
@ -124,7 +126,7 @@ class TranslatorTest extends TestCase
|
|||||||
$this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1));
|
$this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1));
|
||||||
|
|
||||||
// do it another time as the cache is primed now
|
// 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');
|
$loader->expects($this->never())->method('load');
|
||||||
|
|
||||||
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]);
|
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]);
|
||||||
@ -139,7 +141,7 @@ class TranslatorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
$this->expectExceptionMessage('Invalid "invalid locale" locale.');
|
$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 = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', TranslatorWithInvalidLocale::class);
|
||||||
|
|
||||||
$translator->trans('foo');
|
$translator->trans('foo');
|
||||||
@ -162,7 +164,7 @@ class TranslatorTest extends TestCase
|
|||||||
|
|
||||||
public function testGetDefaultLocale()
|
public function testGetDefaultLocale()
|
||||||
{
|
{
|
||||||
$container = $this->getMockBuilder(ContainerInterface::class)->getMock();
|
$container = $this->createMock(\Psr\Container\ContainerInterface::class);
|
||||||
$translator = new Translator($container, new MessageFormatter(), 'en');
|
$translator = new Translator($container, new MessageFormatter(), 'en');
|
||||||
|
|
||||||
$this->assertSame('en', $translator->getLocale());
|
$this->assertSame('en', $translator->getLocale());
|
||||||
@ -170,9 +172,9 @@ class TranslatorTest extends TestCase
|
|||||||
|
|
||||||
public function testInvalidOptions()
|
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\'');
|
$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']));
|
(new Translator($container, new MessageFormatter(), 'en', [], ['foo' => 'bar']));
|
||||||
}
|
}
|
||||||
@ -182,7 +184,7 @@ class TranslatorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$someCatalogue = $this->getCatalogue('some_locale', []);
|
$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))
|
$loader->expects($this->exactly(2))
|
||||||
->method('load')
|
->method('load')
|
||||||
@ -300,7 +302,7 @@ class TranslatorTest extends TestCase
|
|||||||
|
|
||||||
protected function getLoader()
|
protected function getLoader()
|
||||||
{
|
{
|
||||||
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
|
$loader = $this->createMock(LoaderInterface::class);
|
||||||
$loader
|
$loader
|
||||||
->expects($this->exactly(7))
|
->expects($this->exactly(7))
|
||||||
->method('load')
|
->method('load')
|
||||||
@ -336,7 +338,7 @@ class TranslatorTest extends TestCase
|
|||||||
|
|
||||||
protected function getContainer($loader)
|
protected function getContainer($loader)
|
||||||
{
|
{
|
||||||
$container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
|
$container = $this->createMock(ContainerInterface::class);
|
||||||
$container
|
$container
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
@ -377,7 +379,7 @@ class TranslatorTest extends TestCase
|
|||||||
$translator->setFallbackLocales(['fr']);
|
$translator->setFallbackLocales(['fr']);
|
||||||
$translator->warmup($this->tmpDir);
|
$translator->warmup($this->tmpDir);
|
||||||
|
|
||||||
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
|
$loader = $this->createMock(LoaderInterface::class);
|
||||||
$loader
|
$loader
|
||||||
->expects($this->never())
|
->expects($this->never())
|
||||||
->method('load');
|
->method('load');
|
||||||
|
@ -220,7 +220,7 @@ class SecurityDataCollectorTest extends TestCase
|
|||||||
public function testGetListeners()
|
public function testGetListeners()
|
||||||
{
|
{
|
||||||
$request = new Request();
|
$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());
|
$event->setResponse($response = new Response());
|
||||||
$listener = function ($e) use ($event, &$listenerCalled) {
|
$listener = function ($e) use ($event, &$listenerCalled) {
|
||||||
$listenerCalled += $e === $event;
|
$listenerCalled += $e === $event;
|
||||||
|
@ -29,15 +29,12 @@ class TraceableFirewallListenerTest extends TestCase
|
|||||||
public function testOnKernelRequestRecordsListeners()
|
public function testOnKernelRequestRecordsListeners()
|
||||||
{
|
{
|
||||||
$request = new Request();
|
$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());
|
$event->setResponse($response = new Response());
|
||||||
$listener = function ($e) use ($event, &$listenerCalled) {
|
$listener = function ($e) use ($event, &$listenerCalled) {
|
||||||
$listenerCalled += $e === $event;
|
$listenerCalled += $e === $event;
|
||||||
};
|
};
|
||||||
$firewallMap = $this
|
$firewallMap = $this->createMock(FirewallMap::class);
|
||||||
->getMockBuilder(FirewallMap::class)
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
$firewallMap
|
$firewallMap
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getFirewallConfig')
|
->method('getFirewallConfig')
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
|
||||||
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
||||||
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
@ -610,7 +611,7 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||||||
|
|
||||||
public function testAccessDecisionManagerServiceAndStrategyCannotBeUsedAtTheSameTime()
|
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->expectExceptionMessage('Invalid configuration for path "security.access_decision_manager": "strategy" and "service" cannot be used together.');
|
||||||
$this->getContainer('access_decision_manager_service_and_strategy');
|
$this->getContainer('access_decision_manager_service_and_strategy');
|
||||||
}
|
}
|
||||||
@ -628,14 +629,14 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||||||
|
|
||||||
public function testFirewallUndefinedUserProvider()
|
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->expectExceptionMessage('Invalid firewall "main": user provider "undefined" not found.');
|
||||||
$this->getContainer('firewall_undefined_provider');
|
$this->getContainer('firewall_undefined_provider');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFirewallListenerUndefinedProvider()
|
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->expectExceptionMessage('Invalid firewall "main": user provider "undefined" not found.');
|
||||||
$this->getContainer('listener_undefined_provider');
|
$this->getContainer('listener_undefined_provider');
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
|
|||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\MainConfiguration;
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\MainConfiguration;
|
||||||
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||||
use Symfony\Component\Config\Definition\Processor;
|
use Symfony\Component\Config\Definition\Processor;
|
||||||
|
|
||||||
class MainConfigurationTest extends TestCase
|
class MainConfigurationTest extends TestCase
|
||||||
@ -34,7 +35,7 @@ class MainConfigurationTest extends TestCase
|
|||||||
|
|
||||||
public function testNoConfigForProvider()
|
public function testNoConfigForProvider()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
$this->expectException(InvalidConfigurationException::class);
|
||||||
$config = [
|
$config = [
|
||||||
'providers' => [
|
'providers' => [
|
||||||
'stub' => [],
|
'stub' => [],
|
||||||
@ -48,7 +49,7 @@ class MainConfigurationTest extends TestCase
|
|||||||
|
|
||||||
public function testManyConfigForProvider()
|
public function testManyConfigForProvider()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
$this->expectException(InvalidConfigurationException::class);
|
||||||
$config = [
|
$config = [
|
||||||
'providers' => [
|
'providers' => [
|
||||||
'stub' => [
|
'stub' => [
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Security\Factory;
|
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Security\Factory;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
|
||||||
@ -127,7 +128,7 @@ class AbstractFactoryTest extends TestCase
|
|||||||
|
|
||||||
protected function callFactory($id, $config, $userProviderId, $defaultEntryPointId)
|
protected function callFactory($id, $config, $userProviderId, $defaultEntryPointId)
|
||||||
{
|
{
|
||||||
$factory = $this->getMockForAbstractClass(\Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory::class, []);
|
$factory = $this->getMockForAbstractClass(AbstractFactory::class);
|
||||||
|
|
||||||
$factory
|
$factory
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Security\Facto
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\GuardAuthenticationFactory;
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\GuardAuthenticationFactory;
|
||||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||||
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
@ -41,7 +42,7 @@ class GuardAuthenticationFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAddInvalidConfiguration(array $inputConfig)
|
public function testAddInvalidConfiguration(array $inputConfig)
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
|
$this->expectException(InvalidConfigurationException::class);
|
||||||
$factory = new GuardAuthenticationFactory();
|
$factory = new GuardAuthenticationFactory();
|
||||||
$nodeDefinition = new ArrayNodeDefinition('guard');
|
$nodeDefinition = new ArrayNodeDefinition('guard');
|
||||||
$factory->addConfiguration($nodeDefinition);
|
$factory->addConfiguration($nodeDefinition);
|
||||||
|
@ -16,6 +16,7 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
|
|||||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
|
||||||
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
||||||
use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider\DummyProvider;
|
use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider\DummyProvider;
|
||||||
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
@ -26,7 +27,7 @@ class SecurityExtensionTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testInvalidCheckPath()
|
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/.*".');
|
$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();
|
$container = $this->getRawContainer();
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ class SecurityExtensionTest extends TestCase
|
|||||||
|
|
||||||
public function testFirewallWithoutAuthenticationListener()
|
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"');
|
$this->expectExceptionMessage('No authentication listener registered for firewall "some_firewall"');
|
||||||
$container = $this->getRawContainer();
|
$container = $this->getRawContainer();
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ class SecurityExtensionTest extends TestCase
|
|||||||
|
|
||||||
public function testFirewallWithInvalidUserProvider()
|
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');
|
$this->expectExceptionMessage('Unable to create definition for "security.user.provider.concrete.my_foo" user provider');
|
||||||
$container = $this->getRawContainer();
|
$container = $this->getRawContainer();
|
||||||
|
|
||||||
@ -190,7 +191,7 @@ class SecurityExtensionTest extends TestCase
|
|||||||
|
|
||||||
public function testMissingProviderForListener()
|
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.');
|
$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 = $this->getRawContainer();
|
||||||
$container->loadFromExtension('security', [
|
$container->loadFromExtension('security', [
|
||||||
|
@ -301,7 +301,7 @@ EOTXT
|
|||||||
$this->expectException(\RuntimeException::class);
|
$this->expectException(\RuntimeException::class);
|
||||||
$this->expectExceptionMessage('There are no configured encoders for the "security" extension.');
|
$this->expectExceptionMessage('There are no configured encoders for the "security" extension.');
|
||||||
$application = new ConsoleApplication();
|
$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');
|
$passwordEncoderCommand = $application->find('security:encode-password');
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class FirewallMapTest extends TestCase
|
|||||||
$request = new Request();
|
$request = new Request();
|
||||||
|
|
||||||
$map = [];
|
$map = [];
|
||||||
$container = $this->getMockBuilder(Container::class)->getMock();
|
$container = $this->createMock(Container::class);
|
||||||
$container->expects($this->never())->method('get');
|
$container->expects($this->never())->method('get');
|
||||||
|
|
||||||
$firewallMap = new FirewallMap($container, $map);
|
$firewallMap = new FirewallMap($container, $map);
|
||||||
@ -46,7 +46,7 @@ class FirewallMapTest extends TestCase
|
|||||||
$request->attributes->set(self::ATTRIBUTE_FIREWALL_CONTEXT, 'foo');
|
$request->attributes->set(self::ATTRIBUTE_FIREWALL_CONTEXT, 'foo');
|
||||||
|
|
||||||
$map = [];
|
$map = [];
|
||||||
$container = $this->getMockBuilder(Container::class)->getMock();
|
$container = $this->createMock(Container::class);
|
||||||
$container->expects($this->never())->method('get');
|
$container->expects($this->never())->method('get');
|
||||||
|
|
||||||
$firewallMap = new FirewallMap($container, $map);
|
$firewallMap = new FirewallMap($container, $map);
|
||||||
@ -60,7 +60,7 @@ class FirewallMapTest extends TestCase
|
|||||||
{
|
{
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
|
|
||||||
$firewallContext = $this->getMockBuilder(FirewallContext::class)->disableOriginalConstructor()->getMock();
|
$firewallContext = $this->createMock(FirewallContext::class);
|
||||||
|
|
||||||
$firewallConfig = new FirewallConfig('main', 'user_checker');
|
$firewallConfig = new FirewallConfig('main', 'user_checker');
|
||||||
$firewallContext->expects($this->once())->method('getConfig')->willReturn($firewallConfig);
|
$firewallContext->expects($this->once())->method('getConfig')->willReturn($firewallConfig);
|
||||||
@ -68,19 +68,19 @@ class FirewallMapTest extends TestCase
|
|||||||
$listener = function () {};
|
$listener = function () {};
|
||||||
$firewallContext->expects($this->once())->method('getListeners')->willReturn([$listener]);
|
$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);
|
$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);
|
$firewallContext->expects($this->once())->method('getLogoutListener')->willReturn($logoutListener);
|
||||||
|
|
||||||
$matcher = $this->getMockBuilder(RequestMatcherInterface::class)->getMock();
|
$matcher = $this->createMock(RequestMatcherInterface::class);
|
||||||
$matcher->expects($this->once())
|
$matcher->expects($this->once())
|
||||||
->method('matches')
|
->method('matches')
|
||||||
->with($request)
|
->with($request)
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$container = $this->getMockBuilder(Container::class)->getMock();
|
$container = $this->createMock(Container::class);
|
||||||
$container->expects($this->exactly(2))->method('get')->willReturn($firewallContext);
|
$container->expects($this->exactly(2))->method('get')->willReturn($firewallContext);
|
||||||
|
|
||||||
$firewallMap = new FirewallMap($container, ['security.firewall.map.context.foo' => $matcher]);
|
$firewallMap = new FirewallMap($container, ['security.firewall.map.context.foo' => $matcher]);
|
||||||
|
@ -37,8 +37,8 @@ class SecurityUserValueResolverTest extends TestCase
|
|||||||
|
|
||||||
public function testResolveNoUser()
|
public function testResolveNoUser()
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder(UserInterface::class)->getMock();
|
$mock = $this->createMock(UserInterface::class);
|
||||||
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
|
$token = $this->createMock(TokenInterface::class);
|
||||||
$tokenStorage = new TokenStorage();
|
$tokenStorage = new TokenStorage();
|
||||||
$tokenStorage->setToken($token);
|
$tokenStorage->setToken($token);
|
||||||
|
|
||||||
@ -59,8 +59,8 @@ class SecurityUserValueResolverTest extends TestCase
|
|||||||
|
|
||||||
public function testResolve()
|
public function testResolve()
|
||||||
{
|
{
|
||||||
$user = $this->getMockBuilder(UserInterface::class)->getMock();
|
$user = $this->createMock(UserInterface::class);
|
||||||
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
|
$token = $this->createMock(TokenInterface::class);
|
||||||
$token->expects($this->any())->method('getUser')->willReturn($user);
|
$token->expects($this->any())->method('getUser')->willReturn($user);
|
||||||
$tokenStorage = new TokenStorage();
|
$tokenStorage = new TokenStorage();
|
||||||
$tokenStorage->setToken($token);
|
$tokenStorage->setToken($token);
|
||||||
@ -74,8 +74,8 @@ class SecurityUserValueResolverTest extends TestCase
|
|||||||
|
|
||||||
public function testIntegration()
|
public function testIntegration()
|
||||||
{
|
{
|
||||||
$user = $this->getMockBuilder(UserInterface::class)->getMock();
|
$user = $this->createMock(UserInterface::class);
|
||||||
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
|
$token = $this->createMock(TokenInterface::class);
|
||||||
$token->expects($this->any())->method('getUser')->willReturn($user);
|
$token->expects($this->any())->method('getUser')->willReturn($user);
|
||||||
$tokenStorage = new TokenStorage();
|
$tokenStorage = new TokenStorage();
|
||||||
$tokenStorage->setToken($token);
|
$tokenStorage->setToken($token);
|
||||||
@ -86,7 +86,7 @@ class SecurityUserValueResolverTest extends TestCase
|
|||||||
|
|
||||||
public function testIntegrationNoUser()
|
public function testIntegrationNoUser()
|
||||||
{
|
{
|
||||||
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
|
$token = $this->createMock(TokenInterface::class);
|
||||||
$tokenStorage = new TokenStorage();
|
$tokenStorage = new TokenStorage();
|
||||||
$tokenStorage->setToken($token);
|
$tokenStorage->setToken($token);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class PreviewErrorControllerTest extends TestCase
|
|||||||
$code = 123;
|
$code = 123;
|
||||||
$logicalControllerName = 'foo:bar:baz';
|
$logicalControllerName = 'foo:bar:baz';
|
||||||
|
|
||||||
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
|
$kernel = $this->createMock(HttpKernelInterface::class);
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('handle')
|
->method('handle')
|
||||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigLoaderPass;
|
use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigLoaderPass;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
|
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
||||||
|
|
||||||
class TwigLoaderPassTest extends TestCase
|
class TwigLoaderPassTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -89,7 +90,7 @@ class TwigLoaderPassTest extends TestCase
|
|||||||
|
|
||||||
public function testMapperPassWithZeroTaggedLoaders()
|
public function testMapperPassWithZeroTaggedLoaders()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class);
|
$this->expectException(LogicException::class);
|
||||||
$this->pass->process($this->builder);
|
$this->pass->process($this->builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,10 @@ namespace Symfony\Bundle\TwigBundle\Tests\Loader;
|
|||||||
|
|
||||||
use Symfony\Bundle\TwigBundle\Loader\FilesystemLoader;
|
use Symfony\Bundle\TwigBundle\Loader\FilesystemLoader;
|
||||||
use Symfony\Bundle\TwigBundle\Tests\TestCase;
|
use Symfony\Bundle\TwigBundle\Tests\TestCase;
|
||||||
|
use Symfony\Component\Config\FileLocatorInterface;
|
||||||
|
use Symfony\Component\Templating\TemplateNameParserInterface;
|
||||||
use Symfony\Component\Templating\TemplateReferenceInterface;
|
use Symfony\Component\Templating\TemplateReferenceInterface;
|
||||||
|
use Twig\Error\LoaderError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
@ -22,8 +25,8 @@ class FilesystemLoaderTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testGetSourceContext()
|
public function testGetSourceContext()
|
||||||
{
|
{
|
||||||
$parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock();
|
$parser = $this->createMock(TemplateNameParserInterface::class);
|
||||||
$locator = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock();
|
$locator = $this->createMock(FileLocatorInterface::class);
|
||||||
$locator
|
$locator
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('locate')
|
->method('locate')
|
||||||
@ -42,8 +45,8 @@ class FilesystemLoaderTest extends TestCase
|
|||||||
public function testExists()
|
public function testExists()
|
||||||
{
|
{
|
||||||
// should return true for templates that Twig does not find, but Symfony does
|
// should return true for templates that Twig does not find, but Symfony does
|
||||||
$parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock();
|
$parser = $this->createMock(TemplateNameParserInterface::class);
|
||||||
$locator = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock();
|
$locator = $this->createMock(FileLocatorInterface::class);
|
||||||
$locator
|
$locator
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('locate')
|
->method('locate')
|
||||||
@ -56,16 +59,16 @@ class FilesystemLoaderTest extends TestCase
|
|||||||
|
|
||||||
public function testTwigErrorIfLocatorThrowsInvalid()
|
public function testTwigErrorIfLocatorThrowsInvalid()
|
||||||
{
|
{
|
||||||
$this->expectException(\Twig\Error\LoaderError::class);
|
$this->expectException(LoaderError::class);
|
||||||
$parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock();
|
$parser = $this->createMock(TemplateNameParserInterface::class);
|
||||||
$parser
|
$parser
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('parse')
|
->method('parse')
|
||||||
->with('name.format.engine')
|
->with('name.format.engine')
|
||||||
->willReturn($this->getMockBuilder(TemplateReferenceInterface::class)->getMock())
|
->willReturn($this->createMock(TemplateReferenceInterface::class))
|
||||||
;
|
;
|
||||||
|
|
||||||
$locator = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock();
|
$locator = $this->createMock(FileLocatorInterface::class);
|
||||||
$locator
|
$locator
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('locate')
|
->method('locate')
|
||||||
@ -78,16 +81,16 @@ class FilesystemLoaderTest extends TestCase
|
|||||||
|
|
||||||
public function testTwigErrorIfLocatorReturnsFalse()
|
public function testTwigErrorIfLocatorReturnsFalse()
|
||||||
{
|
{
|
||||||
$this->expectException(\Twig\Error\LoaderError::class);
|
$this->expectException(LoaderError::class);
|
||||||
$parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock();
|
$parser = $this->createMock(TemplateNameParserInterface::class);
|
||||||
$parser
|
$parser
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('parse')
|
->method('parse')
|
||||||
->with('name.format.engine')
|
->with('name.format.engine')
|
||||||
->willReturn($this->getMockBuilder(TemplateReferenceInterface::class)->getMock())
|
->willReturn($this->createMock(TemplateReferenceInterface::class))
|
||||||
;
|
;
|
||||||
|
|
||||||
$locator = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock();
|
$locator = $this->createMock(FileLocatorInterface::class);
|
||||||
$locator
|
$locator
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('locate')
|
->method('locate')
|
||||||
@ -100,10 +103,10 @@ class FilesystemLoaderTest extends TestCase
|
|||||||
|
|
||||||
public function testTwigErrorIfTemplateDoesNotExist()
|
public function testTwigErrorIfTemplateDoesNotExist()
|
||||||
{
|
{
|
||||||
$this->expectException(\Twig\Error\LoaderError::class);
|
$this->expectException(LoaderError::class);
|
||||||
$this->expectExceptionMessageMatches('/Unable to find template "name\.format\.engine" \(looked into: .*Tests.Loader.\.\..DependencyInjection.Fixtures.templates\)/');
|
$this->expectExceptionMessageMatches('/Unable to find template "name\.format\.engine" \(looked into: .*Tests.Loader.\.\..DependencyInjection.Fixtures.templates\)/');
|
||||||
$parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock();
|
$parser = $this->createMock(TemplateNameParserInterface::class);
|
||||||
$locator = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock();
|
$locator = $this->createMock(FileLocatorInterface::class);
|
||||||
|
|
||||||
$loader = new FilesystemLoader($locator, $parser);
|
$loader = new FilesystemLoader($locator, $parser);
|
||||||
$loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/templates');
|
$loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/templates');
|
||||||
@ -115,8 +118,8 @@ class FilesystemLoaderTest extends TestCase
|
|||||||
|
|
||||||
public function testTwigSoftErrorIfTemplateDoesNotExist()
|
public function testTwigSoftErrorIfTemplateDoesNotExist()
|
||||||
{
|
{
|
||||||
$parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock();
|
$parser = $this->createMock(TemplateNameParserInterface::class);
|
||||||
$locator = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock();
|
$locator = $this->createMock(FileLocatorInterface::class);
|
||||||
|
|
||||||
$loader = new FilesystemLoader($locator, $parser);
|
$loader = new FilesystemLoader($locator, $parser);
|
||||||
$loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/templates');
|
$loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/templates');
|
||||||
|
@ -4,6 +4,7 @@ namespace Symfony\Bundle\TwigBundle\Tests\Loader;
|
|||||||
|
|
||||||
use Symfony\Bundle\TwigBundle\Loader\NativeFilesystemLoader;
|
use Symfony\Bundle\TwigBundle\Loader\NativeFilesystemLoader;
|
||||||
use Symfony\Bundle\TwigBundle\Tests\TestCase;
|
use Symfony\Bundle\TwigBundle\Tests\TestCase;
|
||||||
|
use Twig\Error\LoaderError;
|
||||||
|
|
||||||
class NativeFilesystemLoaderTest extends TestCase
|
class NativeFilesystemLoaderTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -17,7 +18,7 @@ class NativeFilesystemLoaderTest extends TestCase
|
|||||||
|
|
||||||
public function testWithLegacyStyle1()
|
public function testWithLegacyStyle1()
|
||||||
{
|
{
|
||||||
$this->expectException(\Twig\Error\LoaderError::class);
|
$this->expectException(LoaderError::class);
|
||||||
$this->expectExceptionMessage('Template reference "TestBundle::Foo/index.html.twig" not found, did you mean "@Test/Foo/index.html.twig"?');
|
$this->expectExceptionMessage('Template reference "TestBundle::Foo/index.html.twig" not found, did you mean "@Test/Foo/index.html.twig"?');
|
||||||
$loader = new NativeFilesystemLoader(null, __DIR__.'/../');
|
$loader = new NativeFilesystemLoader(null, __DIR__.'/../');
|
||||||
$loader->addPath('Fixtures/templates', 'Test');
|
$loader->addPath('Fixtures/templates', 'Test');
|
||||||
@ -27,7 +28,7 @@ class NativeFilesystemLoaderTest extends TestCase
|
|||||||
|
|
||||||
public function testWithLegacyStyle2()
|
public function testWithLegacyStyle2()
|
||||||
{
|
{
|
||||||
$this->expectException(\Twig\Error\LoaderError::class);
|
$this->expectException(LoaderError::class);
|
||||||
$this->expectExceptionMessage('Template reference "TestBundle:Foo:index.html.twig" not found, did you mean "@Test/Foo/index.html.twig"?');
|
$this->expectExceptionMessage('Template reference "TestBundle:Foo:index.html.twig" not found, did you mean "@Test/Foo/index.html.twig"?');
|
||||||
$loader = new NativeFilesystemLoader(null, __DIR__.'/../');
|
$loader = new NativeFilesystemLoader(null, __DIR__.'/../');
|
||||||
$loader->addPath('Fixtures/templates', 'Test');
|
$loader->addPath('Fixtures/templates', 'Test');
|
||||||
|
@ -12,16 +12,18 @@
|
|||||||
namespace Symfony\Bundle\TwigBundle\Tests;
|
namespace Symfony\Bundle\TwigBundle\Tests;
|
||||||
|
|
||||||
use Symfony\Bundle\TwigBundle\TemplateIterator;
|
use Symfony\Bundle\TwigBundle\TemplateIterator;
|
||||||
|
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||||
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
|
|
||||||
class TemplateIteratorTest extends TestCase
|
class TemplateIteratorTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testGetIterator()
|
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('getName')->willReturn('BarBundle');
|
||||||
$bundle->expects($this->any())->method('getPath')->willReturn(__DIR__.'/Fixtures/templates/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([
|
$kernel->expects($this->any())->method('getBundles')->willReturn([
|
||||||
$bundle,
|
$bundle,
|
||||||
]);
|
]);
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController;
|
use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController;
|
||||||
use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler;
|
use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler;
|
||||||
|
use Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator;
|
||||||
use Symfony\Bundle\WebProfilerBundle\Tests\Functional\WebProfilerBundleKernel;
|
use Symfony\Bundle\WebProfilerBundle\Tests\Functional\WebProfilerBundleKernel;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
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\Exception\NotFoundHttpException;
|
||||||
use Symfony\Component\HttpKernel\Profiler\Profile;
|
use Symfony\Component\HttpKernel\Profiler\Profile;
|
||||||
use Symfony\Component\HttpKernel\Profiler\Profiler;
|
use Symfony\Component\HttpKernel\Profiler\Profiler;
|
||||||
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
use Twig\Loader\LoaderInterface;
|
use Twig\Loader\LoaderInterface;
|
||||||
use Twig\Loader\SourceContextLoaderInterface;
|
use Twig\Loader\SourceContextLoaderInterface;
|
||||||
@ -35,8 +37,8 @@ class ProfilerControllerTest extends WebTestCase
|
|||||||
$this->expectException(NotFoundHttpException::class);
|
$this->expectException(NotFoundHttpException::class);
|
||||||
$this->expectExceptionMessage('The profiler must be enabled.');
|
$this->expectExceptionMessage('The profiler must be enabled.');
|
||||||
|
|
||||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
$twig = $this->createMock(Environment::class);
|
||||||
|
|
||||||
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
||||||
$controller->homeAction();
|
$controller->homeAction();
|
||||||
@ -111,8 +113,8 @@ class ProfilerControllerTest extends WebTestCase
|
|||||||
$this->expectException(NotFoundHttpException::class);
|
$this->expectException(NotFoundHttpException::class);
|
||||||
$this->expectExceptionMessage('The profiler must be enabled.');
|
$this->expectExceptionMessage('The profiler must be enabled.');
|
||||||
|
|
||||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
$twig = $this->createMock(Environment::class);
|
||||||
|
|
||||||
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
||||||
$controller->toolbarAction(Request::create('/_wdt/foo-token'), null);
|
$controller->toolbarAction(Request::create('/_wdt/foo-token'), null);
|
||||||
@ -123,12 +125,9 @@ class ProfilerControllerTest extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testToolbarActionWithEmptyToken($token)
|
public function testToolbarActionWithEmptyToken($token)
|
||||||
{
|
{
|
||||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
$twig = $this->createMock(Environment::class);
|
||||||
$profiler = $this
|
$profiler = $this->createMock(Profiler::class);
|
||||||
->getMockBuilder(Profiler::class)
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$controller = new ProfilerController($urlGenerator, $profiler, $twig, []);
|
$controller = new ProfilerController($urlGenerator, $profiler, $twig, []);
|
||||||
|
|
||||||
@ -150,12 +149,9 @@ class ProfilerControllerTest extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testOpeningDisallowedPaths($path, $isAllowed)
|
public function testOpeningDisallowedPaths($path, $isAllowed)
|
||||||
{
|
{
|
||||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
$twig = $this->createMock(Environment::class);
|
||||||
$profiler = $this
|
$profiler = $this->createMock(Profiler::class);
|
||||||
->getMockBuilder(Profiler::class)
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$controller = new ProfilerController($urlGenerator, $profiler, $twig, [], null, __DIR__.'/../..');
|
$controller = new ProfilerController($urlGenerator, $profiler, $twig, [], null, __DIR__.'/../..');
|
||||||
|
|
||||||
@ -186,11 +182,8 @@ class ProfilerControllerTest extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testReturns404onTokenNotFound($withCsp)
|
public function testReturns404onTokenNotFound($withCsp)
|
||||||
{
|
{
|
||||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
$twig = $this->createMock(Environment::class);
|
||||||
$profiler = $this
|
$profiler = $this->createMock(Profiler::class);
|
||||||
->getMockBuilder(Profiler::class)
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$profiler
|
$profiler
|
||||||
->expects($this->exactly(2))
|
->expects($this->exactly(2))
|
||||||
@ -214,8 +207,8 @@ class ProfilerControllerTest extends WebTestCase
|
|||||||
$this->expectException(NotFoundHttpException::class);
|
$this->expectException(NotFoundHttpException::class);
|
||||||
$this->expectExceptionMessage('The profiler must be enabled.');
|
$this->expectExceptionMessage('The profiler must be enabled.');
|
||||||
|
|
||||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
$twig = $this->createMock(Environment::class);
|
||||||
|
|
||||||
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
||||||
$controller->searchBarAction(Request::create('/_profiler/search_bar'));
|
$controller->searchBarAction(Request::create('/_profiler/search_bar'));
|
||||||
@ -240,11 +233,8 @@ class ProfilerControllerTest extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testSearchResultsAction($withCsp)
|
public function testSearchResultsAction($withCsp)
|
||||||
{
|
{
|
||||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
$twig = $this->createMock(Environment::class);
|
||||||
$profiler = $this
|
$profiler = $this->createMock(Profiler::class);
|
||||||
->getMockBuilder(Profiler::class)
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$controller = $this->createController($profiler, $twig, $withCsp);
|
$controller = $this->createController($profiler, $twig, $withCsp);
|
||||||
|
|
||||||
@ -306,8 +296,8 @@ class ProfilerControllerTest extends WebTestCase
|
|||||||
$this->expectException(NotFoundHttpException::class);
|
$this->expectException(NotFoundHttpException::class);
|
||||||
$this->expectExceptionMessage('The profiler must be enabled.');
|
$this->expectExceptionMessage('The profiler must be enabled.');
|
||||||
|
|
||||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
$twig = $this->createMock(Environment::class);
|
||||||
|
|
||||||
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
||||||
$controller->searchBarAction(Request::create('/_profiler/search'));
|
$controller->searchBarAction(Request::create('/_profiler/search'));
|
||||||
@ -345,8 +335,8 @@ class ProfilerControllerTest extends WebTestCase
|
|||||||
$this->expectException(NotFoundHttpException::class);
|
$this->expectException(NotFoundHttpException::class);
|
||||||
$this->expectExceptionMessage('The profiler must be enabled.');
|
$this->expectExceptionMessage('The profiler must be enabled.');
|
||||||
|
|
||||||
$urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
|
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
||||||
$twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
$twig = $this->createMock(Environment::class);
|
||||||
|
|
||||||
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
$controller = new ProfilerController($urlGenerator, null, $twig, []);
|
||||||
$controller->phpinfoAction(Request::create('/_profiler/phpinfo'));
|
$controller->phpinfoAction(Request::create('/_profiler/phpinfo'));
|
||||||
@ -464,10 +454,10 @@ class ProfilerControllerTest extends WebTestCase
|
|||||||
|
|
||||||
private function createController($profiler, $twig, $withCSP, array $templates = []): ProfilerController
|
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) {
|
if ($withCSP) {
|
||||||
$nonceGenerator = $this->getMockBuilder(\Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator::class)->getMock();
|
$nonceGenerator = $this->createMock(NonceGenerator::class);
|
||||||
$nonceGenerator->method('generate')->willReturn('dummy_nonce');
|
$nonceGenerator->method('generate')->willReturn('dummy_nonce');
|
||||||
|
|
||||||
return new ProfilerController($urlGenerator, $profiler, $twig, $templates, new ContentSecurityPolicyHandler($nonceGenerator));
|
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 PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler;
|
use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler;
|
||||||
|
use Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
@ -210,7 +211,7 @@ class ContentSecurityPolicyHandlerTest extends TestCase
|
|||||||
|
|
||||||
private function mockNonceGenerator($value)
|
private function mockNonceGenerator($value)
|
||||||
{
|
{
|
||||||
$generator = $this->getMockBuilder(\Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator::class)->getMock();
|
$generator = $this->createMock(NonceGenerator::class);
|
||||||
|
|
||||||
$generator->expects($this->any())
|
$generator->expects($this->any())
|
||||||
->method('generate')
|
->method('generate')
|
||||||
|
@ -52,7 +52,7 @@ class WebProfilerExtensionTest extends TestCase
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
$this->kernel = $this->createMock(KernelInterface::class);
|
||||||
|
|
||||||
$this->container = new ContainerBuilder();
|
$this->container = new ContainerBuilder();
|
||||||
$this->container->register('error_handler.error_renderer.html', HtmlErrorRenderer::class)->setPublic(true);
|
$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\HeaderBag;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
|
use Twig\Environment;
|
||||||
|
|
||||||
class WebDebugToolbarListenerTest extends TestCase
|
class WebDebugToolbarListenerTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -310,7 +313,7 @@ class WebDebugToolbarListenerTest extends TestCase
|
|||||||
$request->headers = new HeaderBag();
|
$request->headers = new HeaderBag();
|
||||||
|
|
||||||
if ($hasSession) {
|
if ($hasSession) {
|
||||||
$session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\Session::class)->disableOriginalConstructor()->getMock();
|
$session = $this->createMock(Session::class);
|
||||||
$request->expects($this->any())
|
$request->expects($this->any())
|
||||||
->method('getSession')
|
->method('getSession')
|
||||||
->willReturn($session);
|
->willReturn($session);
|
||||||
@ -321,7 +324,7 @@ class WebDebugToolbarListenerTest extends TestCase
|
|||||||
|
|
||||||
protected function getTwigMock($render = 'WDT')
|
protected function getTwigMock($render = 'WDT')
|
||||||
{
|
{
|
||||||
$templating = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
|
$templating = $this->createMock(Environment::class);
|
||||||
$templating->expects($this->any())
|
$templating->expects($this->any())
|
||||||
->method('render')
|
->method('render')
|
||||||
->willReturn($render);
|
->willReturn($render);
|
||||||
@ -331,11 +334,11 @@ class WebDebugToolbarListenerTest extends TestCase
|
|||||||
|
|
||||||
protected function getUrlGeneratorMock()
|
protected function getUrlGeneratorMock()
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
|
return $this->createMock(UrlGeneratorInterface::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getKernelMock()
|
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\Profiler\TemplateManager;
|
||||||
use Symfony\Bundle\WebProfilerBundle\Tests\TestCase;
|
use Symfony\Bundle\WebProfilerBundle\Tests\TestCase;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Symfony\Component\HttpKernel\Profiler\Profile;
|
use Symfony\Component\HttpKernel\Profiler\Profile;
|
||||||
|
use Symfony\Component\HttpKernel\Profiler\Profiler;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
use Twig\Loader\LoaderInterface;
|
use Twig\Loader\LoaderInterface;
|
||||||
use Twig\Loader\SourceContextLoaderInterface;
|
use Twig\Loader\SourceContextLoaderInterface;
|
||||||
@ -31,7 +33,7 @@ class TemplateManagerTest extends TestCase
|
|||||||
protected $twigEnvironment;
|
protected $twigEnvironment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Symfony\Component\HttpKernel\Profiler\Profiler
|
* @var Profiler
|
||||||
*/
|
*/
|
||||||
protected $profiler;
|
protected $profiler;
|
||||||
|
|
||||||
@ -57,7 +59,7 @@ class TemplateManagerTest extends TestCase
|
|||||||
|
|
||||||
public function testGetNameOfInvalidTemplate()
|
public function testGetNameOfInvalidTemplate()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class);
|
$this->expectException(NotFoundHttpException::class);
|
||||||
$this->templateManager->getName(new Profile('token'), 'notexistingpanel');
|
$this->templateManager->getName(new Profile('token'), 'notexistingpanel');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,12 +100,12 @@ class TemplateManagerTest extends TestCase
|
|||||||
|
|
||||||
protected function mockProfile()
|
protected function mockProfile()
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder(Profile::class)->disableOriginalConstructor()->getMock();
|
return $this->createMock(Profile::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function mockTwigEnvironment()
|
protected function mockTwigEnvironment()
|
||||||
{
|
{
|
||||||
$this->twigEnvironment = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
|
$this->twigEnvironment = $this->createMock(Environment::class);
|
||||||
|
|
||||||
if (Environment::MAJOR_VERSION > 1) {
|
if (Environment::MAJOR_VERSION > 1) {
|
||||||
$loader = $this->createMock(LoaderInterface::class);
|
$loader = $this->createMock(LoaderInterface::class);
|
||||||
@ -122,9 +124,7 @@ class TemplateManagerTest extends TestCase
|
|||||||
|
|
||||||
protected function mockProfiler()
|
protected function mockProfiler()
|
||||||
{
|
{
|
||||||
$this->profiler = $this->getMockBuilder(\Symfony\Component\HttpKernel\Profiler\Profiler::class)
|
$this->profiler = $this->createMock(Profiler::class);
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
return $this->profiler;
|
return $this->profiler;
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,14 @@ namespace Symfony\Component\Asset\Tests\Context;
|
|||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Asset\Context\RequestStackContext;
|
use Symfony\Component\Asset\Context\RequestStackContext;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
|
||||||
class RequestStackContextTest extends TestCase
|
class RequestStackContextTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testGetBasePathEmpty()
|
public function testGetBasePathEmpty()
|
||||||
{
|
{
|
||||||
$requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
|
$requestStack = $this->createMock(RequestStack::class);
|
||||||
$requestStackContext = new RequestStackContext($requestStack);
|
$requestStackContext = new RequestStackContext($requestStack);
|
||||||
|
|
||||||
$this->assertEmpty($requestStackContext->getBasePath());
|
$this->assertEmpty($requestStackContext->getBasePath());
|
||||||
@ -28,10 +30,10 @@ class RequestStackContextTest extends TestCase
|
|||||||
{
|
{
|
||||||
$testBasePath = 'test-path';
|
$testBasePath = 'test-path';
|
||||||
|
|
||||||
$request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
|
$request = $this->createMock(Request::class);
|
||||||
$request->method('getBasePath')
|
$request->method('getBasePath')
|
||||||
->willReturn($testBasePath);
|
->willReturn($testBasePath);
|
||||||
$requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
|
$requestStack = $this->createMock(RequestStack::class);
|
||||||
$requestStack->method('getMasterRequest')
|
$requestStack->method('getMasterRequest')
|
||||||
->willReturn($request);
|
->willReturn($request);
|
||||||
|
|
||||||
@ -42,7 +44,7 @@ class RequestStackContextTest extends TestCase
|
|||||||
|
|
||||||
public function testIsSecureFalse()
|
public function testIsSecureFalse()
|
||||||
{
|
{
|
||||||
$requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
|
$requestStack = $this->createMock(RequestStack::class);
|
||||||
$requestStackContext = new RequestStackContext($requestStack);
|
$requestStackContext = new RequestStackContext($requestStack);
|
||||||
|
|
||||||
$this->assertFalse($requestStackContext->isSecure());
|
$this->assertFalse($requestStackContext->isSecure());
|
||||||
@ -50,10 +52,10 @@ class RequestStackContextTest extends TestCase
|
|||||||
|
|
||||||
public function testIsSecureTrue()
|
public function testIsSecureTrue()
|
||||||
{
|
{
|
||||||
$request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
|
$request = $this->createMock(Request::class);
|
||||||
$request->method('isSecure')
|
$request->method('isSecure')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
$requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
|
$requestStack = $this->createMock(RequestStack::class);
|
||||||
$requestStack->method('getMasterRequest')
|
$requestStack->method('getMasterRequest')
|
||||||
->willReturn($request);
|
->willReturn($request);
|
||||||
|
|
||||||
@ -64,7 +66,7 @@ class RequestStackContextTest extends TestCase
|
|||||||
|
|
||||||
public function testDefaultContext()
|
public function testDefaultContext()
|
||||||
{
|
{
|
||||||
$requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
|
$requestStack = $this->createMock(RequestStack::class);
|
||||||
$requestStackContext = new RequestStackContext($requestStack, 'default-path', true);
|
$requestStackContext = new RequestStackContext($requestStack, 'default-path', true);
|
||||||
|
|
||||||
$this->assertSame('default-path', $requestStackContext->getBasePath());
|
$this->assertSame('default-path', $requestStackContext->getBasePath());
|
||||||
|
@ -12,7 +12,10 @@
|
|||||||
namespace Symfony\Component\Asset\Tests;
|
namespace Symfony\Component\Asset\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
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\Package;
|
||||||
|
use Symfony\Component\Asset\PackageInterface;
|
||||||
use Symfony\Component\Asset\Packages;
|
use Symfony\Component\Asset\Packages;
|
||||||
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
||||||
|
|
||||||
@ -21,8 +24,8 @@ class PackagesTest extends TestCase
|
|||||||
public function testGetterSetters()
|
public function testGetterSetters()
|
||||||
{
|
{
|
||||||
$packages = new Packages();
|
$packages = new Packages();
|
||||||
$packages->setDefaultPackage($default = $this->getMockBuilder(\Symfony\Component\Asset\PackageInterface::class)->getMock());
|
$packages->setDefaultPackage($default = $this->createMock(PackageInterface::class));
|
||||||
$packages->addPackage('a', $a = $this->getMockBuilder(\Symfony\Component\Asset\PackageInterface::class)->getMock());
|
$packages->addPackage('a', $a = $this->createMock(PackageInterface::class));
|
||||||
|
|
||||||
$this->assertSame($default, $packages->getPackage());
|
$this->assertSame($default, $packages->getPackage());
|
||||||
$this->assertSame($a, $packages->getPackage('a'));
|
$this->assertSame($a, $packages->getPackage('a'));
|
||||||
@ -57,14 +60,14 @@ class PackagesTest extends TestCase
|
|||||||
|
|
||||||
public function testNoDefaultPackage()
|
public function testNoDefaultPackage()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Asset\Exception\LogicException::class);
|
$this->expectException(LogicException::class);
|
||||||
$packages = new Packages();
|
$packages = new Packages();
|
||||||
$packages->getPackage();
|
$packages->getPackage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUndefinedPackage()
|
public function testUndefinedPackage()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Asset\Exception\InvalidArgumentException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
$packages = new Packages();
|
$packages = new Packages();
|
||||||
$packages->getPackage('a');
|
$packages->getPackage('a');
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,10 @@
|
|||||||
namespace Symfony\Component\Asset\Tests;
|
namespace Symfony\Component\Asset\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\Asset\Context\ContextInterface;
|
||||||
use Symfony\Component\Asset\PathPackage;
|
use Symfony\Component\Asset\PathPackage;
|
||||||
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
||||||
|
use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;
|
||||||
|
|
||||||
class PathPackageTest extends TestCase
|
class PathPackageTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -77,7 +79,7 @@ class PathPackageTest extends TestCase
|
|||||||
|
|
||||||
public function testVersionStrategyGivesAbsoluteURL()
|
public function testVersionStrategyGivesAbsoluteURL()
|
||||||
{
|
{
|
||||||
$versionStrategy = $this->getMockBuilder(\Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface::class)->getMock();
|
$versionStrategy = $this->createMock(VersionStrategyInterface::class);
|
||||||
$versionStrategy->expects($this->any())
|
$versionStrategy->expects($this->any())
|
||||||
->method('applyVersion')
|
->method('applyVersion')
|
||||||
->willReturn('https://cdn.com/bar/main.css');
|
->willReturn('https://cdn.com/bar/main.css');
|
||||||
@ -88,7 +90,7 @@ class PathPackageTest extends TestCase
|
|||||||
|
|
||||||
private function getContext($basePath)
|
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);
|
$context->expects($this->any())->method('getBasePath')->willReturn($basePath);
|
||||||
|
|
||||||
return $context;
|
return $context;
|
||||||
|
@ -12,9 +12,13 @@
|
|||||||
namespace Symfony\Component\Asset\Tests;
|
namespace Symfony\Component\Asset\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
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\UrlPackage;
|
||||||
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
|
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
|
||||||
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
||||||
|
use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;
|
||||||
|
|
||||||
class UrlPackageTest extends TestCase
|
class UrlPackageTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -86,7 +90,7 @@ class UrlPackageTest extends TestCase
|
|||||||
|
|
||||||
public function testVersionStrategyGivesAbsoluteURL()
|
public function testVersionStrategyGivesAbsoluteURL()
|
||||||
{
|
{
|
||||||
$versionStrategy = $this->getMockBuilder(\Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface::class)->getMock();
|
$versionStrategy = $this->createMock(VersionStrategyInterface::class);
|
||||||
$versionStrategy->expects($this->any())
|
$versionStrategy->expects($this->any())
|
||||||
->method('applyVersion')
|
->method('applyVersion')
|
||||||
->willReturn('https://cdn.com/bar/main.css');
|
->willReturn('https://cdn.com/bar/main.css');
|
||||||
@ -97,7 +101,7 @@ class UrlPackageTest extends TestCase
|
|||||||
|
|
||||||
public function testNoBaseUrls()
|
public function testNoBaseUrls()
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Asset\Exception\LogicException::class);
|
$this->expectException(LogicException::class);
|
||||||
new UrlPackage([], new EmptyVersionStrategy());
|
new UrlPackage([], new EmptyVersionStrategy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +110,7 @@ class UrlPackageTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWrongBaseUrl($baseUrls)
|
public function testWrongBaseUrl($baseUrls)
|
||||||
{
|
{
|
||||||
$this->expectException(\Symfony\Component\Asset\Exception\InvalidArgumentException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
new UrlPackage($baseUrls, new EmptyVersionStrategy());
|
new UrlPackage($baseUrls, new EmptyVersionStrategy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +124,7 @@ class UrlPackageTest extends TestCase
|
|||||||
|
|
||||||
private function getContext($secure)
|
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);
|
$context->expects($this->any())->method('isSecure')->willReturn($secure);
|
||||||
|
|
||||||
return $context;
|
return $context;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user