Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
write tests for routing config
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas GASC committed Sep 22, 2017
1 parent 1ecbbe9 commit d2914d2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 33 deletions.
50 changes: 17 additions & 33 deletions src/Resources/config/routing.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,27 @@

$collection = new RouteCollection();

$collection->add(
'lapresselibre_verification',
new Route(
'/verification',
['_controller' => 'mediapart_lapresselibre.controller:executeAction'],
[],
[],
'',
['https'],
['GET']
)
$route = new Route(
'/verification',
['_controller' => 'mediapart_lapresselibre.controller:executeAction']
);
$route->setMethods(['GET']);
$collection->add('lapresselibre_verification', $route);

$collection->add(
'lapresselibre_account_creation',
new Route(
'/account-creation',
['_controller' => 'mediapart_lapresselibre.controller:executeAction'],
[],
[],
'',
['https'],
['POST']
)
$route = new Route(
'/account-creation',
['_controller' => 'mediapart_lapresselibre.controller:executeAction']
);
$route->setMethods(['POST']);
$collection->add('lapresselibre_account_creation', $route);

$collection->add(
'lapresselibre_account_updates',
new Route(
'/account-updates',
['_controller' => 'mediapart_lapresselibre.controller:executeAction'],
[],
[],
'',
['https'],
['PUT']
)
$route = new Route(
'/account-update',
['_controller' => 'mediapart_lapresselibre.controller:executeAction']
);
$route->setMethods(['PUT']);
$collection->add('lapresselibre_account_update', $route);

$collection->setSchemes(['https']);

return $collection;
41 changes: 41 additions & 0 deletions tests/Unit/Resources/RoutingTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Mediapart\Bundle\LaPresseLibreBundle\Test\Unit\Resources;

use PHPUnit\Framework\TestCase;

class RoutingTest extends TestCase
{
public function testAllRoutesHasHTTPSSchemeOnly()
{
$collection = require 'src/Resources/config/routing.php';

foreach ($collection->getIterator() as $route) {
$this->assertEquals(['https'], $route->getSchemes());
}
}

public function testVerificationRouteMethodIsGET()
{
$collection = require 'src/Resources/config/routing.php';
$verification = $collection->get('lapresselibre_verification');

$this->assertEquals(['GET'], $verification->getMethods());
}

public function testAccountCreationRouteMethodIsPOST()
{
$collection = require 'src/Resources/config/routing.php';
$account_creation = $collection->get('lapresselibre_account_creation');

$this->assertEquals(['POST'], $account_creation->getMethods());
}

public function testAccountUpdateRouteMethodIsPUT()
{
$collection = require 'src/Resources/config/routing.php';
$account_update = $collection->get('lapresselibre_account_update');

$this->assertEquals(['PUT'], $account_update->getMethods());
}
}

0 comments on commit d2914d2

Please sign in to comment.