/** * @group legacy * @dataProvider provideAbsolutePaths * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered */ public function testAbsolutePathsAreDeprecated($name, $logicalName, $path, $ref) { ErrorAssert::assertDeprecationsAreTriggered('Absolute template path support is deprecated since Symfony 3.1 and will be removed in 4.0.', function () use($name, $logicalName, $path, $ref) { $template = $this->parser->parse($name); $this->assertSame($ref->getLogicalName(), $template->getLogicalName()); $this->assertSame($logicalName, $template->getLogicalName()); $this->assertSame($path, $template->getPath()); }); }
public function testCreateDeprecatedService() { ErrorAssert::assertDeprecationsAreTriggered('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', function () { $definition = new Definition('stdClass'); $definition->setDeprecated(true); $builder = new ContainerBuilder(); $builder->createService($definition, 'deprecated_foo'); }); }
/** * @group legacy * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered */ public function testRenderFallbackWithObjectAttributesIsDeprecated() { ErrorAssert::assertDeprecationsAreTriggered('Passing objects as part of URI attributes to the ESI and SSI rendering strategies is deprecated', function () { $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true), new UriSigner('foo')); $request = Request::create('/'); $reference = new ControllerReference('main_controller', array('foo' => array('a' => array(), 'b' => new \stdClass())), array()); $strategy->render($reference, $request); }); }
/** * @group legacy * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered */ public function testDeprecatedSerializerCacheOption() { ErrorAssert::assertDeprecationsAreTriggered('The "framework.serializer.cache" option is deprecated', function () { $container = $this->createContainerFromFile('serializer_legacy_cache', array('kernel.debug' => true, 'kernel.container_class' => __CLASS__)); $this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory')); $this->assertTrue($container->hasDefinition('serializer.mapping.class_metadata_factory')); $cache = $container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1); $this->assertEquals(new Reference('foo'), $cache); }); }
/** * @dataProvider getParseExceptionOnDuplicateData * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered * throws \Symfony\Component\Yaml\Exception\ParseException in 4.0 */ public function testParseExceptionOnDuplicate($input, $duplicateKey, $lineNumber) { ErrorAssert::assertDeprecationsAreTriggered(sprintf('Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \\Symfony\\Component\\Yaml\\Exception\\ParseException in 4.0.', $duplicateKey, $lineNumber), function () use($input) { Yaml::parse($input); }); }
/** * @group legacy * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered * throws \Symfony\Component\Yaml\Exception\ParseException in 4.0 */ public function testParseUnquotedScalarStartingWithPercentCharacter() { ErrorAssert::assertDeprecationsAreTriggered('Not quoting the scalar "%foo " starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', function () { Inline::parse('{ foo: %foo }'); }); }
/** * @group legacy * @dataProvider provideInlineStyleTagsWithUnknownOptions * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered */ public function testInlineStyleOptionsUnknownAreDeprecated($tag, $option) { ErrorAssert::assertDeprecationsAreTriggered(array(sprintf('Unknown style options are deprecated since version 3.2 and will be removed in 4.0. Exception "Invalid option specified: "%s". Expected one of (bold, underscore, blink, reverse, conceal)".', $option)), function () use($tag) { $formatter = new OutputFormatter(true); $formatter->format($tag); }); }
/** * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered */ public function testDeprecations() { $deprecationMessages = array(); foreach (array('getDate', 'setLastModified') as $method) { $deprecationMessages[] = sprintf('Extending %s::%s() in Response\\ExtendedResponse is deprecated', Response::class, $method); } ErrorAssert::assertDeprecationsAreTriggered($deprecationMessages, function () { new ExtendedResponse(); // Deprecations should not be triggered twice new ExtendedResponse(); }); }
/** * @group legacy * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered */ public function testRequestAnInternalSharedPrivateServiceIsDeprecated() { $deprecations = array('Requesting the "internal" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.'); ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () { $c = new ProjectServiceContainer(); $c->get('internal'); }); }
/** * @group legacy * throw ParseException in Symfony 3.0 * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered */ public function testColonInMappingValueException() { $parser = $this->parser; ErrorAssert::assertDeprecationsAreTriggered('Using a colon in the unquoted mapping value "bar: baz" in line 1 is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.', function () use($parser) { $yaml = <<<EOF foo: bar: baz EOF; $parser->parse($yaml); }); }
/** * @group legacy * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered */ public function testNotValidIfNotSubmitted() { ErrorAssert::assertDeprecationsAreTriggered(array('Call Form::isValid() with an unsubmitted form'), function () { $this->assertFalse($this->form->isValid()); }); }
/** * @group legacy * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered */ public function testAliasDefinitionContainsUnsupportedElements() { $deprecations = array('Using the attribute "class" is deprecated for alias definition "bar"', 'Using the element "tag" is deprecated for alias definition "bar"', 'Using the element "factory" is deprecated for alias definition "bar"'); ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () { $container = new ContainerBuilder(); $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath . '/xml')); $loader->load('legacy_invalid_alias_definition.xml'); $this->assertTrue($container->has('bar')); }); }