Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Commit

Permalink
minor #1580 Refactoring tests (carusogabriel)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.2.x-dev branch.

Discussion
----------

Refactoring tests

I've refactored some tests, using:
- `assertCount` instead of `count` function;
- `assertFalse` instead of strict comparison with `false` keyword;
- `assertArrayHasKey` instead of `isset` function.

Commits
-------

b163e44 Refactoring tests
  • Loading branch information
fabpot committed Dec 14, 2017
2 parents 4e7fa22 + b163e44 commit bc3eec7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions tests/Silex/Tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testGetRoutesWithNoRoutes()

$routes = $app['routes'];
$this->assertInstanceOf('Symfony\Component\Routing\RouteCollection', $routes);
$this->assertEquals(0, count($routes->all()));
$this->assertCount(0, $routes->all());
}

public function testGetRoutesWithRoutes()
Expand All @@ -105,9 +105,9 @@ public function testGetRoutesWithRoutes()

$routes = $app['routes'];
$this->assertInstanceOf('Symfony\Component\Routing\RouteCollection', $routes);
$this->assertEquals(0, count($routes->all()));
$this->assertCount(0, $routes->all());
$app->flush();
$this->assertEquals(2, count($routes->all()));
$this->assertCount(2, $routes->all());
}

public function testOnCoreController()
Expand Down
4 changes: 2 additions & 2 deletions tests/Silex/Tests/ControllerCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testGetRouteCollectionWithNoRoutes()
{
$controllers = new ControllerCollection(new Route());
$routes = $controllers->flush();
$this->assertEquals(0, count($routes->all()));
$this->assertCount(0, $routes->all());
}

public function testGetRouteCollectionWithRoutes()
Expand All @@ -40,7 +40,7 @@ public function testGetRouteCollectionWithRoutes()
$controllers->match('/bar', function () {});

$routes = $controllers->flush();
$this->assertEquals(2, count($routes->all()));
$this->assertCount(2, $routes->all());
}

public function testControllerFreezing()
Expand Down
2 changes: 1 addition & 1 deletion tests/Silex/Tests/Provider/DoctrineServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testLoggerLoading()
}

$app = new Application();
$this->assertTrue(isset($app['logger']));
$this->assertArrayHasKey('logger', $app);
$this->assertNull($app['logger']);
$app->register(new DoctrineServiceProvider(), array(
'dbs.options' => array(
Expand Down
4 changes: 2 additions & 2 deletions tests/Silex/Tests/Provider/ValidatorServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public function testValidatorConstraint($email, $isValid, $nbGlobalError, $nbEma
$form->submit(array('email' => $email));

$this->assertEquals($isValid, $form->isValid());
$this->assertEquals($nbGlobalError, count($form->getErrors()));
$this->assertEquals($nbEmailError, count($form->offsetGet('email')->getErrors()));
$this->assertCount($nbGlobalError, $form->getErrors());
$this->assertCount($nbEmailError, $form->offsetGet('email')->getErrors());
}

public function testValidatorWillNotAddNonexistentTranslationFiles()
Expand Down
2 changes: 1 addition & 1 deletion tests/Silex/Tests/StreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testStreamReturnsStreamingResponse()

$response = $app->stream();
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response);
$this->assertSame(false, $response->getContent());
$this->assertFalse($response->getContent());
}

public function testStreamActuallyStreams()
Expand Down

0 comments on commit bc3eec7

Please sign in to comment.