Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Component CssSelector tests #29798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion 5 src/Symfony/Component/Console/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@
"symfony/process": "~3.3|~4.0",
"psr/log": "~1.0"
},
"provide": {
"psr/log-implementation": "1.0"
},
"suggest": {
"symfony/event-dispatcher": "",
"symfony/lock": "",
"symfony/process": "",
"psr/log-implementation": "For using the console logger"
"psr/log": "For using the console logger"
},
"conflict": {
"symfony/dependency-injection": "<3.4",
Expand Down
60 changes: 60 additions & 0 deletions 60 src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
namespace Symfony\Component\CssSelector\Tests\XPath;

use PHPUnit\Framework\TestCase;
use Symfony\Component\CssSelector\Exception\ExpressionErrorException;
use Symfony\Component\CssSelector\Node\ElementNode;
use Symfony\Component\CssSelector\Node\FunctionNode;
use Symfony\Component\CssSelector\Parser\Parser;
use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension;
use Symfony\Component\CssSelector\XPath\Translator;
use Symfony\Component\CssSelector\XPath\XPathExpr;

class TranslatorTest extends TestCase
{
Expand All @@ -31,6 +36,61 @@ public function testCssToXPath($css, $xpath)
$this->assertEquals($xpath, $translator->cssToXPath($css, ''));
}

public function testCssToXPathPseudoElement()
{
$translator = new Translator();
$translator->registerExtension(new HtmlExtension($translator));
$this->expectException(ExpressionErrorException::class);
$translator->cssToXPath('e::first-line');
}

public function testGetExtensionNotExistsExtension()
{
$translator = new Translator();
$translator->registerExtension(new HtmlExtension($translator));
$this->expectException(ExpressionErrorException::class);
$translator->getExtension('fake');
}

public function testAddCombinationNotExistsExtension()
{
$translator = new Translator();
$translator->registerExtension(new HtmlExtension($translator));
$this->expectException(ExpressionErrorException::class);
$parser = new Parser();
$xpath = $parser->parse('*')[0];
$combinedXpath = $parser->parse('*')[0];
$translator->addCombination('fake', $xpath, $combinedXpath);
}

public function testAddFunctionNotExistsFunction()
{
$translator = new Translator();
$translator->registerExtension(new HtmlExtension($translator));
$xpath = new XPathExpr();
$function = new FunctionNode(new ElementNode(), 'fake');
$this->expectException(ExpressionErrorException::class);
$translator->addFunction($xpath, $function);
}

public function testAddPseudoClassNotExistsClass()
{
$translator = new Translator();
$translator->registerExtension(new HtmlExtension($translator));
$xpath = new XPathExpr();
$this->expectException(ExpressionErrorException::class);
$translator->addPseudoClass($xpath, 'fake');
}

public function testAddAttributeMatchingClassNotExistsClass()
{
$translator = new Translator();
$translator->registerExtension(new HtmlExtension($translator));
$xpath = new XPathExpr();
$this->expectException(ExpressionErrorException::class);
$translator->addAttributeMatching($xpath, '', '', '');
}

/** @dataProvider getXmlLangTestData */
public function testXmlLang($css, array $elementsId)
{
Expand Down
5 changes: 5 additions & 0 deletions 5 src/Symfony/Component/Debug/DebugClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ public static function disable()
}
}

public function findFile($class): ?string
{
return $this->isFinder ? $this->classLoader[0]->findFile($class) ?: null : null;
}

/**
* Loads the given class or interface.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class ResolveBindingsPass extends AbstractRecursivePass
*/
public function process(ContainerBuilder $container)
{
$this->usedBindings = $container->getRemovedBindingIds();

try {
parent::process($container);

Expand Down
46 changes: 7 additions & 39 deletions 46 src/Symfony/Component/DependencyInjection/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface

private $removedIds = array();

private $removedBindingIds = array();

private static $internalTypes = array(
'int' => true,
'float' => true,
Expand Down Expand Up @@ -533,8 +531,7 @@ public function set($id, $service)
throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id));
}

$this->removeId($id);
unset($this->removedIds[$id]);
unset($this->definitions[$id], $this->aliasDefinitions[$id], $this->removedIds[$id]);

parent::set($id, $service);
}
Expand All @@ -547,7 +544,8 @@ public function set($id, $service)
public function removeDefinition($id)
{
if (isset($this->definitions[$id = $this->normalizeId($id)])) {
$this->removeId($id);
unset($this->definitions[$id]);
$this->removedIds[$id] = true;
}
}

Expand Down Expand Up @@ -878,8 +876,7 @@ public function setAlias($alias, $id)
throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias));
}

$this->removeId($alias);
unset($this->removedIds[$alias]);
unset($this->definitions[$alias], $this->removedIds[$alias]);

return $this->aliasDefinitions[$alias] = $id;
}
Expand All @@ -892,7 +889,8 @@ public function setAlias($alias, $id)
public function removeAlias($alias)
{
if (isset($this->aliasDefinitions[$alias = $this->normalizeId($alias)])) {
$this->removeId($alias);
unset($this->aliasDefinitions[$alias]);
$this->removedIds[$alias] = true;
}
}

Expand Down Expand Up @@ -1021,8 +1019,7 @@ public function setDefinition($id, Definition $definition)

$id = $this->normalizeId($id);

$this->removeId($id);
unset($this->removedIds[$id]);
unset($this->aliasDefinitions[$id], $this->removedIds[$id]);

return $this->definitions[$id] = $definition;
}
Expand Down Expand Up @@ -1555,18 +1552,6 @@ public static function getInitializedConditionals($value)
return $services;
}

/**
* Gets removed binding ids.
*
* @return array
*
* @internal
*/
public function getRemovedBindingIds()
{
return $this->removedBindingIds;
}

/**
* Computes a reasonably unique hash of a value.
*
Expand Down Expand Up @@ -1671,21 +1656,4 @@ private function inVendors($path)

return false;
}

private function removeId($id)
{
$this->removedIds[$id] = true;
unset($this->aliasDefinitions[$id]);

if (!isset($this->definitions[$id])) {
return;
}

foreach ($this->definitions[$id]->getBindings() as $binding) {
list(, $identifier) = $binding->getValues();
$this->removedBindingIds[$identifier] = true;
}

unset($this->definitions[$id]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,4 @@ public function testScalarSetter()

$this->assertEquals(array(array('setDefaultLocale', array('fr'))), $definition->getMethodCalls());
}

public function testOverriddenBindings()
{
$container = new ContainerBuilder();

$binding = new BoundArgument('bar');

$container->register('foo', 'stdClass')
->setBindings(array('$foo' => clone $binding));
$container->register('bar', 'stdClass')
->setBindings(array('$foo' => clone $binding));

$container->register('foo', 'stdClass');

(new ResolveBindingsPass())->process($container);

$this->assertInstanceOf('stdClass', $container->get('foo'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ protected function process(ContainerBuilder $container)

/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
* @expectedExceptionMessageRegExp /^Circular reference detected for service "a", path: "a -> c -> b -> a"./
* @expectedExceptionMessageRegExp /^Circular reference detected for service "c", path: "c -> b -> a -> c"./
*/
public function testProcessDetectsChildDefinitionIndirectCircularReference()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public function testMerge()
$config->setDefinition('baz', new Definition('BazClass'));
$config->setAlias('alias_for_foo', 'foo');
$container->merge($config);
$this->assertEquals(array('foo', 'bar', 'service_container', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
$this->assertEquals(array('service_container', 'foo', 'bar', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');

$aliases = $container->getAliases();
$this->assertArrayHasKey('alias_for_foo', $aliases);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ services:
class: Symfony\Component\DependencyInjection\ContainerInterface
public: true
synthetic: true
foo:
class: App\FooService
public: true
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
public: true
Expand All @@ -19,3 +16,6 @@ services:

shared: false
configurator: c
foo:
class: App\FooService
public: true
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ services:
class: Symfony\Component\DependencyInjection\ContainerInterface
public: true
synthetic: true
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar:
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
public: true
tags:
- { name: foo }
- { name: baz }
deprecated: '%service_id%'
lazy: true
arguments: [1]
factory: f
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar:
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar
public: true
tags:
- { name: foo }
- { name: baz }
deprecated: '%service_id%'
lazy: true
arguments: [1]
factory: f
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ContainerConstraintValidatorFactory implements ConstraintValidatorFactoryI
public function __construct(ContainerInterface $container)
{
$this->container = $container;
$this->validators = array();
$this->validators = [];
}

/**
Expand All @@ -46,7 +46,7 @@ public function getInstance(Constraint $constraint)
$this->validators[$name] = $this->container->get($name);
} else {
if (!class_exists($name)) {
throw new ValidatorException(sprintf('Constraint validator "%s" does not exist or it is not enabled. Check the "validatedBy" method in your constraint class "%s".', $name, \get_class($constraint)));
throw new ValidatorException(sprintf('Constraint validator "%s" does not exist or is not enabled. Check the "validatedBy" method in your constraint class "%s".', $name, \get_class($constraint)));
}

$this->validators[$name] = new $name();
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.