Skip to content

Commit

Permalink
Added tests for Mvc\Router\Group.
Browse files Browse the repository at this point in the history
  • Loading branch information
SidRoberts committed Apr 18, 2019
1 parent 4511656 commit 016b443
Show file tree
Hide file tree
Showing 8 changed files with 346 additions and 30 deletions.
47 changes: 44 additions & 3 deletions tests/integration/Mvc/Router/Group/AddDeleteCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,64 @@
namespace Phalcon\Test\Integration\Mvc\Router\Group;

use IntegrationTester;
use Phalcon\Mvc\Router;
use Phalcon\Mvc\Router\Group;
use Phalcon\Test\Fixtures\Traits\RouterTrait;

/**
* Class AddDeleteCest
*/
class AddDeleteCest
{
use RouterTrait;

/**
* Tests Phalcon\Mvc\Router\Group :: addDelete()
*
* @param IntegrationTester $I
*
* @author Phalcon Team <[email protected]>
* @since 2018-11-13
* @author Sid Roberts <[email protected]>
* @since 2019-04-17
*/
public function mvcRouterGroupAddDelete(IntegrationTester $I)
{
$I->wantToTest('Mvc\Router\Group - addDelete()');
$I->skipTest('Need implementation');

$router = $this->getRouter(false);

$group = new Group();

$group->addDelete(
'/docs/index',
[
'controller' => 'documentation6',
'action' => 'index',
]
);

$router->mount($group);



$_SERVER['REQUEST_METHOD'] = 'DELETE';

$router->handle('/docs/index');



$I->assertEquals(
'documentation6',
$router->getControllerName()
);

$I->assertEquals(
'index',
$router->getActionName()
);

$I->assertEquals(
[],
$router->getParams()
);
}
}
49 changes: 45 additions & 4 deletions tests/integration/Mvc/Router/Group/AddGetCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,64 @@
namespace Phalcon\Test\Integration\Mvc\Router\Group;

use IntegrationTester;
use Phalcon\Mvc\Router;
use Phalcon\Mvc\Router\Group;
use Phalcon\Test\Fixtures\Traits\RouterTrait;

/**
* Class AddGetCest
*/
class AddGetCest
{
use RouterTrait;

/**
* Tests Phalcon\Mvc\Router\Group :: addGet()
*
* @param IntegrationTester $I
*
* @author Phalcon Team <[email protected]>
* @since 2018-11-13
* @author Sid Roberts <[email protected]>
* @since 2019-04-17
*/
public function mvcRouterGroupAddGet(IntegrationTester $I)
{
$I->wantToTest('Mvc\Router\Group - addGet()');
$I->skipTest('Need implementation');
$I->wantToTest('Mvc\Router - addGet()');

$router = $this->getRouter(false);

$group = new Group();

$group->addGet(
'/docs/index',
[
'controller' => 'documentation4',
'action' => 'index',
]
);

$router->mount($group);



$_SERVER['REQUEST_METHOD'] = 'GET';

$router->handle('/docs/index');



$I->assertEquals(
'documentation4',
$router->getControllerName()
);

$I->assertEquals(
'index',
$router->getActionName()
);

$I->assertEquals(
[],
$router->getParams()
);
}
}
49 changes: 45 additions & 4 deletions tests/integration/Mvc/Router/Group/AddHeadCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,64 @@
namespace Phalcon\Test\Integration\Mvc\Router\Group;

use IntegrationTester;
use Phalcon\Mvc\Router;
use Phalcon\Mvc\Router\Group;
use Phalcon\Test\Fixtures\Traits\RouterTrait;

/**
* Class AddHeadCest
*/
class AddHeadCest
{
use RouterTrait;

/**
* Tests Phalcon\Mvc\Router\Group :: addHead()
*
* @param IntegrationTester $I
*
* @author Phalcon Team <[email protected]>
* @since 2018-11-13
* @author Sid Roberts <[email protected]>
* @since 2019-04-17
*/
public function mvcRouterGroupAddHead(IntegrationTester $I)
{
$I->wantToTest('Mvc\Router\Group - addHead()');
$I->skipTest('Need implementation');
$I->wantToTest('Mvc\Router - addHead()');

$router = $this->getRouter(false);

$group = new Group();

$group->addHead(
'/docs/index',
[
'controller' => 'documentation8',
'action' => 'index',
]
);

$router->mount($group);



$_SERVER['REQUEST_METHOD'] = 'HEAD';

$router->handle('/docs/index');



$I->assertEquals(
'documentation8',
$router->getControllerName()
);

$I->assertEquals(
'index',
$router->getActionName()
);

$I->assertEquals(
[],
$router->getParams()
);
}
}
49 changes: 45 additions & 4 deletions tests/integration/Mvc/Router/Group/AddOptionsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,64 @@
namespace Phalcon\Test\Integration\Mvc\Router\Group;

use IntegrationTester;
use Phalcon\Mvc\Router;
use Phalcon\Mvc\Router\Group;
use Phalcon\Test\Fixtures\Traits\RouterTrait;

/**
* Class AddOptionsCest
*/
class AddOptionsCest
{
use RouterTrait;

/**
* Tests Phalcon\Mvc\Router\Group :: addOptions()
*
* @param IntegrationTester $I
*
* @author Phalcon Team <[email protected]>
* @since 2018-11-13
* @author Sid Roberts <[email protected]>
* @since 2019-04-17
*/
public function mvcRouterGroupAddOptions(IntegrationTester $I)
{
$I->wantToTest('Mvc\Router\Group - addOptions()');
$I->skipTest('Need implementation');
$I->wantToTest('Mvc\Router - addOptions()');

$router = $this->getRouter(false);

$group = new Group();

$group->addOptions(
'/docs/index',
[
'controller' => 'documentation7',
'action' => 'index',
]
);

$router->mount($group);



$_SERVER['REQUEST_METHOD'] = 'OPTIONS';

$router->handle('/docs/index');



$I->assertEquals(
'documentation7',
$router->getControllerName()
);

$I->assertEquals(
'index',
$router->getActionName()
);

$I->assertEquals(
[],
$router->getParams()
);
}
}
49 changes: 45 additions & 4 deletions tests/integration/Mvc/Router/Group/AddPatchCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,64 @@
namespace Phalcon\Test\Integration\Mvc\Router\Group;

use IntegrationTester;
use Phalcon\Mvc\Router;
use Phalcon\Mvc\Router\Group;
use Phalcon\Test\Fixtures\Traits\RouterTrait;

/**
* Class AddPatchCest
*/
class AddPatchCest
{
use RouterTrait;

/**
* Tests Phalcon\Mvc\Router\Group :: addPatch()
*
* @param IntegrationTester $I
*
* @author Phalcon Team <[email protected]>
* @since 2018-11-13
* @author Sid Roberts <[email protected]>
* @since 2019-04-17
*/
public function mvcRouterGroupAddPatch(IntegrationTester $I)
{
$I->wantToTest('Mvc\Router\Group - addPatch()');
$I->skipTest('Need implementation');
$I->wantToTest('Mvc\Router - addPatch()');

$router = $this->getRouter(false);

$group = new Group();

$group->addPatch(
'/docs/index',
[
'controller' => 'documentation4',
'action' => 'index',
]
);

$router->mount($group);



$_SERVER['REQUEST_METHOD'] = 'PATCH';

$router->handle('/docs/index');



$I->assertEquals(
'documentation4',
$router->getControllerName()
);

$I->assertEquals(
'index',
$router->getActionName()
);

$I->assertEquals(
[],
$router->getParams()
);
}
}
Loading

0 comments on commit 016b443

Please sign in to comment.