Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixing tests/cases models ws errors

  • Loading branch information...
commit 3dca349939609cc37b7af495f47c1c0377ceafe6 1 parent fea5254
@m4rcsch m4rcsch authored
Showing with 144 additions and 136 deletions.
  1. +106 −100 tests/cases/models/MinervaModelTest.php
  2. +38 −36 tests/cases/models/UserTest.php
View
206 tests/cases/models/MinervaModelTest.php
@@ -4,111 +4,117 @@
*
* @copyright Copyright 2010-2011, Shift8Creative (http://www.shift8creative.com)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
-*/
+ */
+
namespace minerva\tests\cases\models;
use minerva\models\User;
use minerva\models\MinervaModel;
class MinervaModelTest extends \lithium\test\Unit {
-
- public function setUp() {}
-
- public function tearDown() {
- }
-
- public function testDisplayName() {
- $result = User::displayName();
- $this->assertEqual('User', $result);
-
- $name = 'Cool Pages!';
- MinervaModel::displayName($name);
- $result = MinervaModel::displayName();
- $this->assertEqual($name, $result);
- }
-
- public function testLibraryName() {
- $result = MinervaModel::libraryName();
- $this->assertEqual('minerva', $result);
- }
-
- public function testValidationRules() {
- $result = MinervaModel::validationRules();
- $this->assertTrue(is_array($result));
-
- $custom_rules = array('title' => array(array('notEmpty', 'message' => 'Title cannot be empty')));
- MinervaModel::validationRules($custom_rules);
- $result = MinervaModel::validationRules();
- $this->assertEqual($custom_rules, $result);
- }
-
- public function testAccessRules() {
- $result = MinervaModel::accessRules();
- $this->assertTrue(is_array($result));
-
- $custom_rules = array('index' => array('action' => array(array('rule' => 'denyAll'))));
- MinervaModel::accessRules($custom_rules);
- $result = MinervaModel::accessRules();
- $this->assertEqual($custom_rules, $result);
- }
-
- public function testActionRedirects() {
- $result = MinervaModel::actionRedirects();
- $this->assertTrue(is_array($result));
-
- $custom_redirects = array('index' => '/');
- MinervaModel::actionRedirects($custom_redirects);
- $result = MinervaModel::actionRedirects();
- $this->assertEqual($custom_redirects, $result);
- }
-
- public function testUrlField() {
- $result = User::urlField();
- $this->assertEqual(array('first_name', 'last_name'), $result);
-
- $field = 'title';
- MinervaModel::urlField($field);
- $result = MinervaModel::urlField();
- $this->assertEqual($field, $result);
-
- $field = array('first_name', 'last_name');
- MinervaModel::urlField($field);
- $result = MinervaModel::urlField();
- $this->assertEqual($field, $result);
- }
-
- public function testUrlSeparator() {
- $result = MinervaModel::urlSeparator();
- $this->assertEqual('-', $result);
-
- $separator = '_';
- MinervaModel::urlSeparator($separator);
- $result = MinervaModel::urlSeparator();
- $this->assertEqual($separator, $result);
- }
-
- public function testSearchSchema() {
- $result = MinervaModel::searchSchema();
- $this->assertTrue(is_array($result));
-
- $schema = array('title' => array('weight' => 1));
- MinervaModel::searchSchema($schema);
- $result = MinervaModel::searchSchema();
- $this->assertEqual($schema, $result);
- }
-
- public function testGetMineraModel() {
- $result = MinervaModel::getMinervaModel('page');
- $this->assertEqual('minerva\models\Page', $result);
-
- $result = MinervaModel::getMinervaModel('page', 'minerva');
- $this->assertEqual('minerva\models\Page', $result);
- }
-
- public function testGetAllMinervaModels() {
- $result = MinervaModel::getAllMinervaModels();
- $this->assertTrue(is_null($result) || is_array($result));
- }
-
+
+ public function setUp() {
+
+ }
+
+ public function tearDown() {
+
+ }
+
+ public function testDisplayName() {
+ $result = User::displayName();
+ $this->assertEqual('User', $result);
+
+ $name = 'Cool Pages!';
+ MinervaModel::displayName($name);
+ $result = MinervaModel::displayName();
+ $this->assertEqual($name, $result);
+ }
+
+ public function testLibraryName() {
+ $result = MinervaModel::libraryName();
+ $this->assertEqual('minerva', $result);
+ }
+
+ public function testValidationRules() {
+ $result = MinervaModel::validationRules();
+ $this->assertTrue(is_array($result));
+
+ $custom_rules = array('title' => array(
+ array('notEmpty', 'message' => 'Title cannot be empty')
+ ));
+ MinervaModel::validationRules($custom_rules);
+ $result = MinervaModel::validationRules();
+ $this->assertEqual($custom_rules, $result);
+ }
+
+ public function testAccessRules() {
+ $result = MinervaModel::accessRules();
+ $this->assertTrue(is_array($result));
+
+ $custom_rules = array('index' => array('action' => array(array('rule' => 'denyAll'))));
+ MinervaModel::accessRules($custom_rules);
+ $result = MinervaModel::accessRules();
+ $this->assertEqual($custom_rules, $result);
+ }
+
+ public function testActionRedirects() {
+ $result = MinervaModel::actionRedirects();
+ $this->assertTrue(is_array($result));
+
+ $custom_redirects = array('index' => '/');
+ MinervaModel::actionRedirects($custom_redirects);
+ $result = MinervaModel::actionRedirects();
+ $this->assertEqual($custom_redirects, $result);
+ }
+
+ public function testUrlField() {
+ $result = User::urlField();
+ $this->assertEqual(array('first_name', 'last_name'), $result);
+
+ $field = 'title';
+ MinervaModel::urlField($field);
+ $result = MinervaModel::urlField();
+ $this->assertEqual($field, $result);
+
+ $field = array('first_name', 'last_name');
+ MinervaModel::urlField($field);
+ $result = MinervaModel::urlField();
+ $this->assertEqual($field, $result);
+ }
+
+ public function testUrlSeparator() {
+ $result = MinervaModel::urlSeparator();
+ $this->assertEqual('-', $result);
+
+ $separator = '_';
+ MinervaModel::urlSeparator($separator);
+ $result = MinervaModel::urlSeparator();
+ $this->assertEqual($separator, $result);
+ }
+
+ public function testSearchSchema() {
+ $result = MinervaModel::searchSchema();
+ $this->assertTrue(is_array($result));
+
+ $schema = array('title' => array('weight' => 1));
+ MinervaModel::searchSchema($schema);
+ $result = MinervaModel::searchSchema();
+ $this->assertEqual($schema, $result);
+ }
+
+ public function testGetMineraModel() {
+ $result = MinervaModel::getMinervaModel('page');
+ $this->assertEqual('minerva\models\Page', $result);
+
+ $result = MinervaModel::getMinervaModel('page', 'minerva');
+ $this->assertEqual('minerva\models\Page', $result);
+ }
+
+ public function testGetAllMinervaModels() {
+ $result = MinervaModel::getAllMinervaModels();
+ $this->assertTrue(is_null($result) || is_array($result));
+ }
}
+
?>
View
74 tests/cases/models/UserTest.php
@@ -4,7 +4,8 @@
*
* @copyright Copyright 2010-2011, Shift8Creative (http://www.shift8creative.com)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
-*/
+ */
+
namespace minerva\tests\cases\models;
use lithium\storage\Cache;
@@ -13,40 +14,41 @@
use minerva\tests\mocks\data\MockFacebookUser;
class UserTest extends \lithium\test\Unit {
-
- public function setUp() {}
-
- public function tearDown() {
- Cache::delete('default', '100');
- Cache::delete('default', 'xxxxx99999');
- }
-
- public function testDefaultRoles() {
- $this->assertEqual(
- array(
- 'administrator' => 'Administrator',
- 'content_editor' => 'Content Editor',
- 'registered_user' => 'Registered User'
- ),
- User::user_roles()
- );
- }
-
- public function testLoginRedirect() {
- $this->assertFalse(User::get_login_redirect());
- $this->assertEqual('/home', MockUser::get_login_redirect());
- }
-
- public function testGetName() {
- // from facebook public API
- $this->assertTrue(is_string(User::get_name_from_facebook('100')));
- $this->assertFalse(User::get_name_from_facebook('xxxxx99999'));
- $this->assertFalse(User::get_name_from_facebook(null));
-
- // from local data source
- $this->assertEqual(MockUser::get_name(1), 'John Doe');
- $this->assertTrue(is_string(MockFacebookUser::get_name(1)));
- }
-
+
+ public function setUp() {
+
+ }
+
+ public function tearDown() {
+ Cache::delete('default', '100');
+ Cache::delete('default', 'xxxxx99999');
+ }
+
+ public function testDefaultRoles() {
+ $this->assertEqual(
+ array(
+ 'administrator' => 'Administrator',
+ 'content_editor' => 'Content Editor',
+ 'registered_user' => 'Registered User'
+ ), User::user_roles()
+ );
+ }
+
+ public function testLoginRedirect() {
+ $this->assertFalse(User::get_login_redirect());
+ $this->assertEqual('/home', MockUser::get_login_redirect());
+ }
+
+ public function testGetName() {
+ // from facebook public API
+ $this->assertTrue(is_string(User::get_name_from_facebook('100')));
+ $this->assertFalse(User::get_name_from_facebook('xxxxx99999'));
+ $this->assertFalse(User::get_name_from_facebook(null));
+
+ // from local data source
+ $this->assertEqual(MockUser::get_name(1), 'John Doe');
+ $this->assertTrue(is_string(MockFacebookUser::get_name(1)));
+ }
}
+
?>
Please sign in to comment.
Something went wrong with that request. Please try again.