Skip to content

Commit

Permalink
Routes test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcobraghim committed May 22, 2017
1 parent 1e315e7 commit 41e092c
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 0 deletions.
49 changes: 49 additions & 0 deletions test/SuitUp8ConstTest.php
@@ -0,0 +1,49 @@
<?php
/**
* The MIT License (MIT)
*
* Copyright (c) 2016 Braghim Sistemas
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace SuitUpTest;

use SuitUp\Enum;

class SuitUp8ConstTest extends \PHPUnit_Framework_TestCase
{
public function testMsgTypes()
{
$this->assertEquals('success', Enum\MsgType::SUCCESS);
$this->assertEquals('danger', Enum\MsgType::DANGER);
$this->assertEquals('info', Enum\MsgType::INFO);
$this->assertEquals('warning', Enum\MsgType::WARNING);
}

public function testStatuses()
{
$this->assertEquals(0, Enum\Status::INATIVO);
$this->assertEquals(1, Enum\Status::ATIVO);
$this->assertEquals(2, Enum\Status::NAO_APROVADO);
}
}




69 changes: 69 additions & 0 deletions test/SuitUp9RoutesTest.php
@@ -0,0 +1,69 @@
<?php
/**
* The MIT License (MIT)
*
* Copyright (c) 2016 Braghim Sistemas
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace SuitUpTest;

use SuitUp\Routes\Routes;
use SuitUpStart;

class SuitUp9RoutesTest extends \PHPUnit_Framework_TestCase
{
protected $app;
protected $routes;

public function __construct()
{
$this->app = new SuitUpStart(__DIR__ . '/modulestest');

$this->routes = Routes::getInstance();
}

public function testConsts()
{
$this->assertEquals('reverse', Routes::TYPE_REVERSE);
$this->assertEquals('linear', Routes::TYPE_LINEAR);
}

public function testInstance()
{
$this->assertInstanceof('\SuitUp\Routes\Routes', $this->routes);
}

public function testParams()
{
$this->assertCount(0, $this->routes->getParams());
$this->assertEquals('default', $this->routes->getModuleName());
$this->assertEquals('index', $this->routes->getControllerName());
$this->assertEquals('index', $this->routes->getActionName());
}

}








39 changes: 39 additions & 0 deletions test/config/default.routes.php
@@ -0,0 +1,39 @@
<?php
/**
* The MIT License (MIT)
*
* Copyright (c) 2016 Braghim Sistemas
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
return array(
'dashboard.html' => array(
'controller' => 'index',
'action' => 'index',
'type' => \SuitUp\Routes\Routes::TYPE_REVERSE,
'params' => array(
'test' => 'ok',
),
),
'profile.html' => array(
'controller' => 'user',
'action' => 'index',
'type' => \SuitUp\Routes\Routes::TYPE_LINEAR,
),
);

0 comments on commit 41e092c

Please sign in to comment.