Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7cccb0

Browse files
committed
fixed tests
2 parents 020664e + f5f3dd7 commit e7cccb0

File tree

67 files changed

+356
-195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+356
-195
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ public function startTestSuite($suite)
120120
$this->state = 0;
121121

122122
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
123-
AnnotationRegistry::registerLoader('class_exists');
123+
if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
124+
AnnotationRegistry::registerUniqueLoader('class_exists');
125+
} else {
126+
AnnotationRegistry::registerLoader('class_exists');
127+
}
124128
}
125129

126130
if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) {

src/Symfony/Bridge/PhpUnit/bootstrap.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@
2828
setlocale(LC_ALL, 'C');
2929

3030
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
31-
AnnotationRegistry::registerLoader('class_exists');
31+
if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
32+
AnnotationRegistry::registerUniqueLoader('class_exists');
33+
} else {
34+
AnnotationRegistry::registerLoader('class_exists');
35+
}
3236
}
3337

3438
if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) {

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
1313

1414
use Doctrine\Common\Annotations\Reader;
15+
use Doctrine\Common\Annotations\AnnotationRegistry;
1516
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
1617
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1718
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
@@ -1342,7 +1343,14 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
13421343

13431344
$loader->load('annotations.xml');
13441345

1346+
<<<<<<< HEAD
13451347
$container->getAlias('annotation_reader')->setPrivate(true);
1348+
=======
1349+
if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
1350+
$container->getDefinition('annotations.dummy_registry')
1351+
->setMethodCalls(array(array('registerLoader', array('class_exists'))));
1352+
}
1353+
>>>>>>> 3.3
13461354

13471355
if ('none' !== $config['cache']) {
13481356
if (!class_exists('Doctrine\Common\Cache\CacheProvider')) {

src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader">
1111
<call method="addGlobalIgnoredName">
1212
<argument>required</argument>
13-
<argument type="service">
14-
<!-- dummy arg to register class_exists as annotation loader only when required -->
15-
<service class="Doctrine\Common\Annotations\AnnotationRegistry">
16-
<call method="registerLoader">
17-
<argument>class_exists</argument>
18-
</call>
19-
</service>
20-
</argument>
13+
<!-- dummy arg to register class_exists as annotation loader only when required -->
14+
<argument type="service" id="annotations.dummy_registry" />
15+
</call>
16+
</service>
17+
18+
<service id="annotations.dummy_registry" class="Doctrine\Common\Annotations\AnnotationRegistry">
19+
<call method="registerUniqueLoader">
20+
<argument>class_exists</argument>
2121
</call>
2222
</service>
2323

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@
199199
<xsd:attribute name="cache" type="xsd:string" />
200200
<xsd:attribute name="enable-annotations" type="xsd:boolean" />
201201
<xsd:attribute name="static-method" type="xsd:boolean" />
202+
<xsd:attribute name="translation-domain" type="xsd:string" />
203+
<xsd:attribute name="strict-email" type="xsd:boolean" />
202204
</xsd:complexType>
203205

204206
<xsd:complexType name="file_mapping">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', array(
4+
'validation' => array(
5+
'strict_email' => true,
6+
),
7+
));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', array(
4+
'validation' => array(
5+
'translation_domain' => 'messages',
6+
),
7+
));
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:validation strict-email="true" />
10+
</framework:config>
11+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:validation translation-domain="messages" />
10+
</framework:config>
11+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework:
2+
validation:
3+
strict_email: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework:
2+
validation:
3+
translation_domain: messages

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,20 @@ public function testValidationNoStaticMethod()
702702
// no cache, no annotations, no static methods
703703
}
704704

705+
public function testValidationTranslationDomain()
706+
{
707+
$container = $this->createContainerFromFile('validation_translation_domain');
708+
709+
$this->assertSame('messages', $container->getParameter('validator.translation_domain'));
710+
}
711+
712+
public function testValidationStrictEmail()
713+
{
714+
$container = $this->createContainerFromFile('validation_strict_email');
715+
716+
$this->assertTrue($container->getDefinition('validator.email')->getArgument(0));
717+
}
718+
705719
public function testValidationMapping()
706720
{
707721
$container = $this->createContainerFromFile('validation_mapping');

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ public function testAccess()
378378
foreach ($rules as list($matcherId, $attributes, $channel)) {
379379
$requestMatcher = $container->getDefinition($matcherId);
380380

381-
$this->assertFalse(isset($matcherIds[$matcherId]));
381+
$this->assertArrayNotHasKey($matcherId, $matcherIds);
382382
$matcherIds[$matcherId] = true;
383383

384384
$i = count($matcherIds);

src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testAppendingSomeNode()
3232
->append($child);
3333

3434
$this->assertCount(3, $this->getField($parent, 'children'));
35-
$this->assertTrue(in_array($child, $this->getField($parent, 'children')));
35+
$this->assertContains($child, $this->getField($parent, 'children'));
3636
}
3737

3838
/**

src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,6 @@ public function testResourcesWithDifferentPatternsAreDifferent()
178178
$resourceA = new DirectoryResource($this->directory, '/.xml$/');
179179
$resourceB = new DirectoryResource($this->directory, '/.yaml$/');
180180

181-
$this->assertEquals(2, count(array_unique(array($resourceA, $resourceB))));
181+
$this->assertCount(2, array_unique(array($resourceA, $resourceB)));
182182
}
183183
}

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ public function hasParameterOption($values, $onlyParams = false)
287287
}
288288

289289
if (0 === strpos($token, '-') && 0 !== strpos($token, '--')) {
290+
$noValue = explode('=', $token);
291+
$token = $noValue[0];
290292
$searchableToken = str_replace('-', '', $token);
291293
$searchableValue = str_replace('-', '', $value);
292294
if ('' !== $searchableToken && '' !== $searchableValue && false !== strpos($searchableToken, $searchableValue)) {

src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ public function testHasParameterOption()
317317
$input = new ArgvInput(array('cli.php', '-fh'));
318318
$this->assertTrue($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
319319

320+
$input = new ArgvInput(array('cli.php', '-e=test'));
321+
$this->assertFalse($input->hasParameterOption('-s'), '->hasParameterOption() returns true if the given short option is in the raw input');
322+
320323
$input = new ArgvInput(array('cli.php', '--foo', 'foo'));
321324
$this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input');
322325

src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testXmlLang($css, array $elementsId)
3737
$translator = new Translator();
3838
$document = new \SimpleXMLElement(file_get_contents(__DIR__.'/Fixtures/lang.xml'));
3939
$elements = $document->xpath($translator->cssToXPath($css));
40-
$this->assertEquals(count($elementsId), count($elements));
40+
$this->assertCount(count($elementsId), $elements);
4141
foreach ($elements as $element) {
4242
$this->assertTrue(in_array($element->attributes()->id, $elementsId));
4343
}

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testDefinitions()
7373

7474
$builder->setDefinition('foobar', $foo = new Definition('FooBarClass'));
7575
$this->assertEquals($foo, $builder->getDefinition('foobar'), '->getDefinition() returns a service definition if defined');
76-
$this->assertTrue($builder->setDefinition('foobar', $foo = new Definition('FooBarClass')) === $foo, '->setDefinition() implements a fluid interface by returning the service reference');
76+
$this->assertSame($builder->setDefinition('foobar', $foo = new Definition('FooBarClass')), $foo, '->setDefinition() implements a fluid interface by returning the service reference');
7777

7878
$builder->addDefinitions($defs = array('foobar' => new Definition('FooBarClass')));
7979
$this->assertEquals(array_merge($definitions, $defs), $builder->getDefinitions(), '->addDefinitions() adds the service definitions');
@@ -242,7 +242,7 @@ public function testAliases()
242242
$this->assertFalse($builder->hasAlias('foobar'), '->hasAlias() returns false if the alias does not exist');
243243
$this->assertEquals('foo', (string) $builder->getAlias('bar'), '->getAlias() returns the aliased service');
244244
$this->assertTrue($builder->has('bar'), '->setAlias() defines a new service');
245-
$this->assertTrue($builder->get('bar') === $builder->get('foo'), '->setAlias() creates a service that is an alias to another one');
245+
$this->assertSame($builder->get('bar'), $builder->get('foo'), '->setAlias() creates a service that is an alias to another one');
246246

247247
try {
248248
$builder->setAlias('foobar', 'foobar');
@@ -287,8 +287,8 @@ public function testSetAliases()
287287
$builder->setAliases(array('bar' => 'foo', 'foobar' => 'foo'));
288288

289289
$aliases = $builder->getAliases();
290-
$this->assertTrue(isset($aliases['bar']));
291-
$this->assertTrue(isset($aliases['foobar']));
290+
$this->assertArrayHasKey('bar', $aliases);
291+
$this->assertArrayHasKey('foobar', $aliases);
292292
}
293293

294294
public function testAddAliases()
@@ -298,8 +298,8 @@ public function testAddAliases()
298298
$builder->addAliases(array('foobar' => 'foo'));
299299

300300
$aliases = $builder->getAliases();
301-
$this->assertTrue(isset($aliases['bar']));
302-
$this->assertTrue(isset($aliases['foobar']));
301+
$this->assertArrayHasKey('bar', $aliases);
302+
$this->assertArrayHasKey('foobar', $aliases);
303303
}
304304

305305
public function testSetReplacesAlias()
@@ -562,7 +562,7 @@ public function testMerge()
562562
$this->assertEquals(array('service_container', 'foo', 'bar', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
563563

564564
$aliases = $container->getAliases();
565-
$this->assertTrue(isset($aliases['alias_for_foo']));
565+
$this->assertArrayHasKey('alias_for_foo', $aliases);
566566
$this->assertEquals('foo', (string) $aliases['alias_for_foo']);
567567

568568
$container = new ContainerBuilder();
@@ -969,7 +969,7 @@ public function testExtension()
969969
$container->setResourceTracking(false);
970970

971971
$container->registerExtension($extension = new \ProjectExtension());
972-
$this->assertTrue($container->getExtension('project') === $extension, '->registerExtension() registers an extension');
972+
$this->assertSame($container->getExtension('project'), $extension, '->registerExtension() registers an extension');
973973

974974
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('LogicException');
975975
$container->getExtension('no_registered');

src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function testLoadWithExternalEntitiesDisabled()
101101

102102
libxml_disable_entity_loader($disableEntities);
103103

104-
$this->assertTrue(count($containerBuilder->getParameterBag()->all()) > 0, 'Parameters can be read from the config file.');
104+
$this->assertGreaterThan(0, $containerBuilder->getParameterBag()->all(), 'Parameters can be read from the config file.');
105105
}
106106

107107
public function testLoadParameters()
@@ -191,7 +191,7 @@ public function testLoadAnonymousServices()
191191
$args = $services['foo']->getArguments();
192192
$this->assertCount(1, $args, '->load() references anonymous services as "normal" ones');
193193
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $args[0], '->load() converts anonymous services to references to "normal" services');
194-
$this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones');
194+
$this->assertArrayHasKey((string) $args[0], $services, '->load() makes a reference to the created ones');
195195
$inner = $services[(string) $args[0]];
196196
$this->assertEquals('BarClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
197197
$this->assertFalse($inner->isPublic());
@@ -200,7 +200,7 @@ public function testLoadAnonymousServices()
200200
$args = $inner->getArguments();
201201
$this->assertCount(1, $args, '->load() references anonymous services as "normal" ones');
202202
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $args[0], '->load() converts anonymous services to references to "normal" services');
203-
$this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones');
203+
$this->assertArrayHasKey((string) $args[0], $services, '->load() makes a reference to the created ones');
204204
$inner = $services[(string) $args[0]];
205205
$this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
206206
$this->assertFalse($inner->isPublic());
@@ -209,7 +209,7 @@ public function testLoadAnonymousServices()
209209
$properties = $services['foo']->getProperties();
210210
$property = $properties['p'];
211211
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $property, '->load() converts anonymous services to references to "normal" services');
212-
$this->assertTrue(isset($services[(string) $property]), '->load() makes a reference to the created ones');
212+
$this->assertArrayHasKey((string) $property, $services, '->load() makes a reference to the created ones');
213213
$inner = $services[(string) $property];
214214
$this->assertEquals('BuzClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
215215
$this->assertFalse($inner->isPublic());
@@ -260,7 +260,7 @@ public function testLoadServices()
260260
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
261261
$loader->load('services6.xml');
262262
$services = $container->getDefinitions();
263-
$this->assertTrue(isset($services['foo']), '->load() parses <service> elements');
263+
$this->assertArrayHasKey('foo', $services, '->load() parses <service> elements');
264264
$this->assertFalse($services['not_shared']->isShared(), '->load() parses shared flag');
265265
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts <service> element to Definition instances');
266266
$this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute');
@@ -277,10 +277,10 @@ public function testLoadServices()
277277
$this->assertSame(array(null, 'getInstance'), $services['new_factory4']->getFactory(), '->load() accepts factory tag without class');
278278

279279
$aliases = $container->getAliases();
280-
$this->assertTrue(isset($aliases['alias_for_foo']), '->load() parses <service> elements');
280+
$this->assertArrayHasKey('alias_for_foo', $aliases, '->load() parses <service> elements');
281281
$this->assertEquals('foo', (string) $aliases['alias_for_foo'], '->load() parses aliases');
282282
$this->assertTrue($aliases['alias_for_foo']->isPublic());
283-
$this->assertTrue(isset($aliases['another_alias_for_foo']));
283+
$this->assertArrayHasKey('another_alias_for_foo', $aliases);
284284
$this->assertEquals('foo', (string) $aliases['another_alias_for_foo']);
285285
$this->assertFalse($aliases['another_alias_for_foo']->isPublic());
286286

@@ -403,8 +403,8 @@ public function testExtensions()
403403
$services = $container->getDefinitions();
404404
$parameters = $container->getParameterBag()->all();
405405

406-
$this->assertTrue(isset($services['project.service.bar']), '->load() parses extension elements');
407-
$this->assertTrue(isset($parameters['project.parameter.bar']), '->load() parses extension elements');
406+
$this->assertArrayHasKey('project.service.bar', $services, '->load() parses extension elements');
407+
$this->assertArrayHasKey('project.parameter.bar', $parameters, '->load() parses extension elements');
408408

409409
$this->assertEquals('BAR', $services['project.service.foo']->getClass(), '->load() parses extension elements');
410410
$this->assertEquals('BAR', $parameters['project.parameter.foo'], '->load() parses extension elements');
@@ -419,8 +419,8 @@ public function testExtensions()
419419
$services = $container->getDefinitions();
420420
$parameters = $container->getParameterBag()->all();
421421

422-
$this->assertTrue(isset($services['project.service.bar']), '->load() parses extension elements');
423-
$this->assertTrue(isset($parameters['project.parameter.bar']), '->load() parses extension elements');
422+
$this->assertArrayHasKey('project.service.bar', $services, '->load() parses extension elements');
423+
$this->assertArrayHasKey('project.parameter.bar', $parameters, '->load() parses extension elements');
424424

425425
$this->assertEquals('BAR', $services['project.service.foo']->getClass(), '->load() parses extension elements');
426426
$this->assertEquals('BAR', $parameters['project.parameter.foo'], '->load() parses extension elements');
@@ -542,8 +542,8 @@ public function testXmlNamespaces()
542542
$loader->load('namespaces.xml');
543543
$services = $container->getDefinitions();
544544

545-
$this->assertTrue(isset($services['foo']), '->load() parses <srv:service> elements');
546-
$this->assertEquals(1, count($services['foo']->getTag('foo.tag')), '->load parses <srv:tag> elements');
545+
$this->assertArrayHasKey('foo', $services, '->load() parses <srv:service> elements');
546+
$this->assertCount(1, $services['foo']->getTag('foo.tag'), '->load parses <srv:tag> elements');
547547
$this->assertEquals(array(array('setBar', array('foo'))), $services['foo']->getMethodCalls(), '->load() parses the <srv:call> tag');
548548
}
549549

0 commit comments

Comments
 (0)