-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding a new test for module routes and moving the other tests to the…
… same place back puts them
- Loading branch information
1 parent
45aa7a4
commit da89ae4
Showing
4 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
))); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | ||
) | ||
), | ||
); | ||
} | ||
} |