Skip to content

Commit

Permalink
adding a new test for module routes and moving the other tests to the…
Browse files Browse the repository at this point in the history
… same place back puts them
  • Loading branch information
dogmatic69 committed Jun 22, 2012
1 parent 45aa7a4 commit da89ae4
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 2 deletions.
17 changes: 16 additions & 1 deletion Core/Modules/Model/ModulesRoute.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<?php
class ModulesRoute extends ModulesAppModel{
class ModulesRoute extends ModulesAppModel {
public function __construct($id = false, $table = null, $ds = null) {
parent::__construct($id, $table, $ds);

$this->validate = array(
'module_id' => array(
'validateRecordExists' => array(
'required' => true,
'rule' => 'validateRecordExists',
'message' => __d('modules', 'The selected module is not valid'))),
'route_id' => array(
'validateRecordExists' => array(
'required' => true,
'rule' => 'validateRecordExists',
'message' => __d('modules', 'The selected route is not valid')
)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function testFind() {
*/
public function validationFailData() {
return array(
1 => array(
array(
array(),
array(
'name' => array('Please enter a name for this module'),
Expand Down
66 changes: 66 additions & 0 deletions Core/Modules/Test/Case/Model/ModulesRouteTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
App::uses('ModulesRoute', 'Modules.Model');

/**
* ModulesRoute Test Case
*
*/
class ModulesRouteTest extends CakeTestCase {

/**
* Fixtures
*
* @var array
*/
public $fixtures = array(
'plugin.modules.modules_route'
);

/**
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();
$this->ModulesRoute = ClassRegistry::init('Modules.ModulesRoute');
}

/**
* tearDown method
*
* @return void
*/
public function tearDown() {
unset($this->ModulesRoute);

parent::tearDown();
}

/**
* @brief test validation
*
* @dataProvider validationDataBad
*/
public function testValidationFails($data, $expected) {
$this->ModulesRoute->create();
$this->ModulesRoute->set($data);
$this->ModulesRoute->validates();
$this->assertEquals($expected, $this->ModulesRoute->validationErrors);
}

/**
* @brief validationDataBad data provider
*/
public function validationDataBad() {
return array(
array(
array(),
array(
'position_id' => array('Please select the position this module will show in'),
'module_id' => array('Please select the position this module will show in'),
)
),
);
}
}

0 comments on commit da89ae4

Please sign in to comment.