From bd8f836eafd891bd535ba1b30c54918b942b8669 Mon Sep 17 00:00:00 2001 From: Lucas Michot Date: Wed, 2 Mar 2016 12:38:56 +0100 Subject: [PATCH] Use assertCount --- tests/Container/ContainerTest.php | 2 +- tests/Cookie/Middleware/EncryptCookiesTest.php | 4 ++-- tests/Http/HttpRedirectResponseTest.php | 4 ++-- tests/Http/HttpResponseTest.php | 4 ++-- tests/Redis/RedisConnectionTest.php | 2 +- tests/Routing/RouteCollectionTest.php | 2 +- tests/Support/SupportCollectionTest.php | 8 ++++---- tests/Support/SupportMessageBagTest.php | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/Container/ContainerTest.php b/tests/Container/ContainerTest.php index 514249b4b1a0..494f6e2d2ae0 100755 --- a/tests/Container/ContainerTest.php +++ b/tests/Container/ContainerTest.php @@ -506,7 +506,7 @@ public function testContainerTags() $container = new Container; $container->tag(['ContainerImplementationStub', 'ContainerImplementationStubTwo'], ['foo']); - $this->assertEquals(2, count($container->tagged('foo'))); + $this->assertCount(2, $container->tagged('foo')); $this->assertInstanceOf('ContainerImplementationStub', $container->tagged('foo')[0]); $this->assertInstanceOf('ContainerImplementationStubTwo', $container->tagged('foo')[1]); diff --git a/tests/Cookie/Middleware/EncryptCookiesTest.php b/tests/Cookie/Middleware/EncryptCookiesTest.php index 79c03bb53b58..5f111ed79d7d 100644 --- a/tests/Cookie/Middleware/EncryptCookiesTest.php +++ b/tests/Cookie/Middleware/EncryptCookiesTest.php @@ -45,7 +45,7 @@ public function testSetCookieEncryption() $response = $this->router->dispatch(Request::create($this->setCookiePath, 'GET')); $cookies = $response->headers->getCookies(); - $this->assertEquals(2, count($cookies)); + $this->assertCount(2, $cookies); $this->assertEquals('encrypted_cookie', $cookies[0]->getName()); $this->assertNotEquals('value', $cookies[0]->getValue()); $this->assertEquals('unencrypted_cookie', $cookies[1]->getName()); @@ -62,7 +62,7 @@ public function testQueuedCookieEncryption() $response = $this->router->dispatch(Request::create($this->queueCookiePath, 'GET')); $cookies = $response->headers->getCookies(); - $this->assertEquals(2, count($cookies)); + $this->assertCount(2, $cookies); $this->assertEquals('encrypted_cookie', $cookies[0]->getName()); $this->assertNotEquals('value', $cookies[0]->getValue()); $this->assertEquals('unencrypted_cookie', $cookies[1]->getName()); diff --git a/tests/Http/HttpRedirectResponseTest.php b/tests/Http/HttpRedirectResponseTest.php index 353eeb72366f..c40803d3578e 100755 --- a/tests/Http/HttpRedirectResponseTest.php +++ b/tests/Http/HttpRedirectResponseTest.php @@ -35,10 +35,10 @@ public function testWithOnRedirect() public function testWithCookieOnRedirect() { $response = new RedirectResponse('foo.bar'); - $this->assertEquals(0, count($response->headers->getCookies())); + $this->assertCount(0, $response->headers->getCookies()); $this->assertEquals($response, $response->withCookie(new Symfony\Component\HttpFoundation\Cookie('foo', 'bar'))); $cookies = $response->headers->getCookies(); - $this->assertEquals(1, count($cookies)); + $this->assertCount(1, $cookies); $this->assertEquals('foo', $cookies[0]->getName()); $this->assertEquals('bar', $cookies[0]->getValue()); } diff --git a/tests/Http/HttpResponseTest.php b/tests/Http/HttpResponseTest.php index 01c6f77db00a..4ead3715cd28 100755 --- a/tests/Http/HttpResponseTest.php +++ b/tests/Http/HttpResponseTest.php @@ -51,10 +51,10 @@ public function testHeader() public function testWithCookie() { $response = new Illuminate\Http\Response(); - $this->assertEquals(0, count($response->headers->getCookies())); + $this->assertCount(0, $response->headers->getCookies()); $this->assertEquals($response, $response->withCookie(new Symfony\Component\HttpFoundation\Cookie('foo', 'bar'))); $cookies = $response->headers->getCookies(); - $this->assertEquals(1, count($cookies)); + $this->assertCount(1, $cookies); $this->assertEquals('foo', $cookies[0]->getName()); $this->assertEquals('bar', $cookies[0]->getValue()); } diff --git a/tests/Redis/RedisConnectionTest.php b/tests/Redis/RedisConnectionTest.php index 0030ed93a331..9d42c7406942 100644 --- a/tests/Redis/RedisConnectionTest.php +++ b/tests/Redis/RedisConnectionTest.php @@ -18,7 +18,7 @@ public function testRedisClusterNotCreateClusterAndOptionsServer() $redis = $this->getRedis(true); $client = $redis->connection(); - $this->assertEquals(1, $client->getConnection()->count()); + $this->assertCount(1, $client->getConnection()); } protected function getRedis($cluster = false) diff --git a/tests/Routing/RouteCollectionTest.php b/tests/Routing/RouteCollectionTest.php index 70f1c3b9b305..e1c311d38344 100644 --- a/tests/Routing/RouteCollectionTest.php +++ b/tests/Routing/RouteCollectionTest.php @@ -47,7 +47,7 @@ public function testRouteCollectionAddRouteChangesCount() 'uses' => 'FooController@index', 'as' => 'foo_index', ])); - $this->assertSame(1, $this->routeCollection->count()); + $this->assertCount(1, $this->routeCollection); } public function testRouteCollectionIsCountable() diff --git a/tests/Support/SupportCollectionTest.php b/tests/Support/SupportCollectionTest.php index 53da91097195..7f947ec251b9 100755 --- a/tests/Support/SupportCollectionTest.php +++ b/tests/Support/SupportCollectionTest.php @@ -535,7 +535,7 @@ public function testChunk() $this->assertInstanceOf('Illuminate\Support\Collection', $data); $this->assertInstanceOf('Illuminate\Support\Collection', $data[0]); - $this->assertEquals(4, $data->count()); + $this->assertCount(4, $data); $this->assertEquals([1, 2, 3], $data[0]->toArray()); $this->assertEquals([9 => 10], $data[3]->toArray()); } @@ -1077,21 +1077,21 @@ public function testZip() $this->assertInstanceOf('Illuminate\Support\Collection', $c[0]); $this->assertInstanceOf('Illuminate\Support\Collection', $c[1]); $this->assertInstanceOf('Illuminate\Support\Collection', $c[2]); - $this->assertEquals(3, $c->count()); + $this->assertCount(3, $c); $this->assertEquals([1, 4], $c[0]->all()); $this->assertEquals([2, 5], $c[1]->all()); $this->assertEquals([3, 6], $c[2]->all()); $c = new Collection([1, 2, 3]); $c = $c->zip([4, 5, 6], [7, 8, 9]); - $this->assertEquals(3, $c->count()); + $this->assertCount(3, $c); $this->assertEquals([1, 4, 7], $c[0]->all()); $this->assertEquals([2, 5, 8], $c[1]->all()); $this->assertEquals([3, 6, 9], $c[2]->all()); $c = new Collection([1, 2, 3]); $c = $c->zip([4, 5, 6], [7]); - $this->assertEquals(3, $c->count()); + $this->assertCount(3, $c); $this->assertEquals([1, 4, 7], $c[0]->all()); $this->assertEquals([2, 5, null], $c[1]->all()); $this->assertEquals([3, 6, null], $c[2]->all()); diff --git a/tests/Support/SupportMessageBagTest.php b/tests/Support/SupportMessageBagTest.php index 191a24980ad3..bc97541becd6 100755 --- a/tests/Support/SupportMessageBagTest.php +++ b/tests/Support/SupportMessageBagTest.php @@ -123,13 +123,13 @@ public function testMessageBagReturnsExpectedJson() public function testCountReturnsCorrectValue() { $container = new MessageBag; - $this->assertEquals(0, $container->count()); + $this->assertCount(0, $container); $container->add('foo', 'bar'); $container->add('foo', 'baz'); $container->add('boom', 'baz'); - $this->assertEquals(3, $container->count()); + $this->assertCount(3, $container); } public function testCountable()