Skip to content

Commit 90fcbde

Browse files
committed
merged branch canni/fix_cs (PR symfony#3146)
Commits ------- 3cfaade [CS] Fix usage of assertCount Discussion ---------- [CS] Fix usage of assertCount Bug fix: no Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: - Todo: - [![Build Status](https://secure.travis-ci.org/canni/symfony.png)](http://travis-ci.org/canni/symfony)
2 parents c7ec49c + 3cfaade commit 90fcbde

31 files changed

+95
-95
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/ContainerAwareEventDispatcherTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function testGetListenersOnLazyLoad()
189189

190190
$this->assertTrue(isset($listeners['onEvent']));
191191

192-
$this->assertEquals(1, count($dispatcher->getListeners('onEvent')));
192+
$this->assertCount(1, $dispatcher->getListeners('onEvent'));
193193
}
194194
}
195195

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function testValidCollector()
7070

7171
// grab the method calls off of the "profiler" definition
7272
$methodCalls = $definition->getMethodCalls();
73-
$this->assertEquals(1, count($methodCalls));
73+
$this->assertCount(1, $methodCalls);
7474
$this->assertEquals('add', $methodCalls[0][0]); // grab the method part of the first call
7575
}
7676
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,11 @@ public function testValidationPaths()
226226
));
227227

228228
$yamlArgs = $container->getParameter('validator.mapping.loader.yaml_files_loader.mapping_files');
229-
$this->assertEquals(1, count($yamlArgs));
229+
$this->assertCount(1, $yamlArgs);
230230
$this->assertStringEndsWith('TestBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'validation.yml', $yamlArgs[0]);
231231

232232
$xmlArgs = $container->getParameter('validator.mapping.loader.xml_files_loader.mapping_files');
233-
$this->assertEquals(2, count($xmlArgs));
233+
$this->assertCount(2, $xmlArgs);
234234
$this->assertStringEndsWith('Component/Form/Resources/config/validation.xml', $xmlArgs[0]);
235235
$this->assertStringEndsWith('TestBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'validation.xml', $xmlArgs[1]);
236236
}

src/Symfony/Bundle/FrameworkBundle/Tests/Translation/PhpExtractorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testExtraction()
2828
$extractor->extract(__DIR__.'/../Fixtures/Resources/views/', $catalogue);
2929

3030
// Assert
31-
$this->assertEquals(1, count($catalogue->all('messages')), '->extract() should find 1 translation');
31+
$this->assertCount(1, $catalogue->all('messages'), '->extract() should find 1 translation');
3232
$this->assertTrue($catalogue->has('new key'), '->extract() should find at leat "new key" message');
3333
$this->assertEquals('prefixnew key', $catalogue->get('new key'), '->extract() should apply "prefix" as prefix');
3434
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testAccessRestrictedResourceWithForward($locale)
6464
$client->insulate();
6565

6666
$crawler = $client->request('GET', '/'.$locale.'/secure/');
67-
$this->assertEquals(1, count($crawler->selectButton('login')), (string) $client->getResponse());
67+
$this->assertCount(1, $crawler->selectButton('login'), (string) $client->getResponse());
6868
}
6969

7070
public function getLocales()

tests/Symfony/Tests/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPassTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testProcess()
4747

4848
$graph = $this->process($container);
4949

50-
$this->assertEquals(3, count($edges = $graph->getNode('b')->getInEdges()));
50+
$this->assertCount(3, $edges = $graph->getNode('b')->getInEdges());
5151
$this->assertSame($ref1, $edges[0]->getValue());
5252
$this->assertSame($ref4, $edges[1]->getValue());
5353
$this->assertSame($ref5, $edges[2]->getValue());
@@ -68,7 +68,7 @@ public function testProcessDetectsReferencesFromInlinedDefinitions()
6868

6969
$graph = $this->process($container);
7070

71-
$this->assertEquals(1, count($refs = $graph->getNode('a')->getInEdges()));
71+
$this->assertCount(1, $refs = $graph->getNode('a')->getInEdges());
7272
$this->assertSame($ref, $refs[0]->getValue());
7373
}
7474

@@ -87,7 +87,7 @@ public function testProcessDoesNotSaveDuplicateReferences()
8787

8888
$graph = $this->process($container);
8989

90-
$this->assertEquals(2, count($graph->getNode('a')->getInEdges()));
90+
$this->assertCount(2, $graph->getNode('a')->getInEdges());
9191
}
9292

9393
protected function process(ContainerBuilder $container)

tests/Symfony/Tests/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testProcess()
3131

3232
$arguments = $def->getArguments();
3333
$this->assertNull($arguments[0]);
34-
$this->assertEquals(0, count($def->getMethodCalls()));
34+
$this->assertCount(0, $def->getMethodCalls());
3535
}
3636

3737
public function testProcessIgnoreNonExistentServices()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public function testGetAliases()
174174

175175
$builder->set('foobar', 'stdClass');
176176
$builder->set('moo', 'stdClass');
177-
$this->assertEquals(0, count($builder->getAliases()), '->getAliases() does not return aliased services that have been overridden');
177+
$this->assertCount(0, $builder->getAliases(), '->getAliases() does not return aliased services that have been overridden');
178178
}
179179

180180
/**

tests/Symfony/Tests/Component/DomCrawler/CrawlerTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testAddHtmlContentWithErrors()
9090
, 'UTF-8');
9191

9292
$errors = libxml_get_errors();
93-
$this->assertEquals(1, count($errors));
93+
$this->assertCount(1, $errors);
9494
$this->assertEquals("Tag nav invalid\n", $errors[0]->message);
9595

9696
libxml_clear_errors();
@@ -226,7 +226,7 @@ public function testEq()
226226
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->eq() returns a new instance of a crawler');
227227

228228
$this->assertEquals('Two', $crawler->eq(1)->text(), '->eq() returns the nth node of the list');
229-
$this->assertEquals(0, count($crawler->eq(100)), '->eq() returns an empty crawler if the nth node does not exist');
229+
$this->assertCount(0, $crawler->eq(100), '->eq() returns an empty crawler if the nth node does not exist');
230230
}
231231

232232
public function testEach()
@@ -297,7 +297,7 @@ public function testFilterXPath()
297297

298298
$crawler = $this->createTestCrawler()->filter('ul');
299299

300-
$this->assertEquals(6, count($crawler->filterXPath('//li')), '->filterXPath() filters the node list with the XPath expression');
300+
$this->assertCount(6, $crawler->filterXPath('//li'), '->filterXPath() filters the node list with the XPath expression');
301301
}
302302

303303
/**
@@ -311,7 +311,7 @@ public function testFilter()
311311

312312
$crawler = $this->createTestCrawler()->filter('ul');
313313

314-
$this->assertEquals(6, count($crawler->filter('li')), '->filter() filters the node list with the CSS selector');
314+
$this->assertCount(6, $crawler->filter('li'), '->filter() filters the node list with the CSS selector');
315315
}
316316

317317
public function testSelectLink()
@@ -320,17 +320,17 @@ public function testSelectLink()
320320
$this->assertNotSame($crawler, $crawler->selectLink('Foo'), '->selectLink() returns a new instance of a crawler');
321321
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->selectLink() returns a new instance of a crawler');
322322

323-
$this->assertEquals(1, count($crawler->selectLink('Fabien\'s Foo')), '->selectLink() selects links by the node values');
324-
$this->assertEquals(1, count($crawler->selectLink('Fabien\'s Bar')), '->selectLink() selects links by the alt attribute of a clickable image');
323+
$this->assertCount(1, $crawler->selectLink('Fabien\'s Foo'), '->selectLink() selects links by the node values');
324+
$this->assertCount(1, $crawler->selectLink('Fabien\'s Bar'), '->selectLink() selects links by the alt attribute of a clickable image');
325325

326-
$this->assertEquals(2, count($crawler->selectLink('Fabien"s Foo')), '->selectLink() selects links by the node values');
327-
$this->assertEquals(2, count($crawler->selectLink('Fabien"s Bar')), '->selectLink() selects links by the alt attribute of a clickable image');
326+
$this->assertCount(2, $crawler->selectLink('Fabien"s Foo'), '->selectLink() selects links by the node values');
327+
$this->assertCount(2, $crawler->selectLink('Fabien"s Bar'), '->selectLink() selects links by the alt attribute of a clickable image');
328328

329-
$this->assertEquals(1, count($crawler->selectLink('\' Fabien"s Foo')), '->selectLink() selects links by the node values');
330-
$this->assertEquals(1, count($crawler->selectLink('\' Fabien"s Bar')), '->selectLink() selects links by the alt attribute of a clickable image');
329+
$this->assertCount(1, $crawler->selectLink('\' Fabien"s Foo'), '->selectLink() selects links by the node values');
330+
$this->assertCount(1, $crawler->selectLink('\' Fabien"s Bar'), '->selectLink() selects links by the alt attribute of a clickable image');
331331

332-
$this->assertEquals(4, count($crawler->selectLink('Foo')), '->selectLink() selects links by the node values');
333-
$this->assertEquals(4, count($crawler->selectLink('Bar')), '->selectLink() selects links by the node values');
332+
$this->assertCount(4, $crawler->selectLink('Foo'), '->selectLink() selects links by the node values');
333+
$this->assertCount(4, $crawler->selectLink('Bar'), '->selectLink() selects links by the node values');
334334
}
335335

336336
public function testSelectButton()
@@ -371,7 +371,7 @@ public function testLinks()
371371
$crawler = $this->createTestCrawler('http://example.com/bar/')->selectLink('Foo');
372372
$this->assertInternalType('array', $crawler->links(), '->links() returns an array');
373373

374-
$this->assertEquals(4, count($crawler->links()), '->links() returns an array');
374+
$this->assertCount(4, $crawler->links(), '->links() returns an array');
375375
$links = $crawler->links();
376376
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Link', $links[0], '->links() returns an array of Link instances');
377377

tests/Symfony/Tests/Component/EventDispatcher/EventDispatcherTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public function testAddListener()
5252
$this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
5353
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
5454
$this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
55-
$this->assertEquals(1, count($this->dispatcher->getListeners(self::preFoo)));
56-
$this->assertEquals(1, count($this->dispatcher->getListeners(self::postFoo)));
57-
$this->assertEquals(2, count($this->dispatcher->getListeners()));
55+
$this->assertCount(1, $this->dispatcher->getListeners(self::preFoo));
56+
$this->assertCount(1, $this->dispatcher->getListeners(self::postFoo));
57+
$this->assertCount(2, $this->dispatcher->getListeners());
5858
}
5959

6060
public function testGetListenersSortsByPriority()
@@ -187,7 +187,7 @@ public function testAddSubscriberWithPriorities()
187187

188188
$listeners = $this->dispatcher->getListeners('pre.foo');
189189
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
190-
$this->assertEquals(2, count($listeners));
190+
$this->assertCount(2, $listeners);
191191
$this->assertInstanceOf('Symfony\Tests\Component\EventDispatcher\TestEventSubscriberWithPriorities', $listeners[0][0]);
192192
}
193193

@@ -198,7 +198,7 @@ public function testAddSubscriberWithMultipleListeners()
198198

199199
$listeners = $this->dispatcher->getListeners('pre.foo');
200200
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
201-
$this->assertEquals(2, count($listeners));
201+
$this->assertCount(2, $listeners);
202202
$this->assertEquals('preFoo2', $listeners[0][1]);
203203
}
204204

@@ -227,7 +227,7 @@ public function testRemoveSubscriberWithMultipleListeners()
227227
$eventSubscriber = new TestEventSubscriberWithMultipleListeners();
228228
$this->dispatcher->addSubscriber($eventSubscriber);
229229
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
230-
$this->assertEquals(2, count($this->dispatcher->getListeners(self::preFoo)));
230+
$this->assertCount(2, $this->dispatcher->getListeners(self::preFoo));
231231
$this->dispatcher->removeSubscriber($eventSubscriber);
232232
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
233233
}

0 commit comments

Comments
 (0)