Skip to content

Commit

Permalink
fixing route tests to not use the default db "new Model()" breaks tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Nov 28, 2012
1 parent d42d775 commit 2322aa8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Core/Routes/Model/Route.php
Expand Up @@ -20,6 +20,7 @@
*/

class Route extends RoutesAppModel {

/**
* belongs to relations
*
Expand Down Expand Up @@ -55,11 +56,10 @@ public function __construct($id = false, $table = null, $ds = null) {
$this->validate = array(
'name' => array(
'notEmpty' => array(
'required' => true,
'rule' => 'notEmpty',
'message' => __d('routes', 'Please enter a name for this route'),
'required' => true,
'on' => 'create',
'message' => __d('routes', 'Please enter a name for this route')
'on' => 'create'
),
'isUnique' => array(
'rule' => 'isUnique',
Expand Down
12 changes: 7 additions & 5 deletions Core/Routes/Test/Case/Model/RouteTest.php
Expand Up @@ -3,17 +3,23 @@
App::uses('Route', 'Routes.Model');

class RouteTest extends CakeTestCase {

/**
* Fixtures
*
* @var array
*/
public $fixtures = array(
'plugin.routes.route',
'plugin.themes.theme',
'plugin.installer.plugin'
);

/**
* @brief set up at the start
*/
public function setUp() {
parent::setUp();
$this->Route = new Route();
$this->Route = ClassRegistry::init('Routes.Route');
$this->Route->Behaviors->attach('Libs.Validation');
}
Expand Down Expand Up @@ -80,14 +86,11 @@ public function testRegex($data, $expected) {
* test getting the route out of the database formatted for InfinitasRouter::connect()
*/
public function testGetRoutes() {
//basic find
$routes = $this->Route->getRoutes();

//random checks
$this->assertTrue(isset($routes[7]));
$this->assertNotEmpty($routes[5]);

// advanced route
$expected = array(
'Route' => array(
'url' => '/p/:year/:month/:day',
Expand All @@ -109,7 +112,6 @@ public function testGetRoutes() {
);
$this->assertEqual($routes[9], $expected);

// admin route
$expected = array(
'Route' => array(
'url' => '/admin',
Expand Down
2 changes: 1 addition & 1 deletion Core/Routes/Test/Fixture/RouteFixture.php
Expand Up @@ -6,7 +6,7 @@
* @since 0.9b1
*/
class RouteFixture extends CakeTestFixture {
public $name = 'Route';

public $table = 'core_routes';

public $fields = array(
Expand Down

0 comments on commit 2322aa8

Please sign in to comment.