testing - CakePHP - Basic Unit Test Failing but app works? -


since i've been scratching head on hour - i'm guessing pretty minor , i'm being stupid. i'm testing model method app, , worked 2 hours ago - , added more tests , they've been failing since, when went original basic one:

my fixture:

class userfixture extends caketestfixture {     var $name = 'user'; } var $fields = array(     'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),     'group_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'index'),     'username' => array('type' => 'string', 'null' => false, 'length' => 16, 'key' => 'unique', 'collate' => 'utf8_unicode_ci', 'charset' => 'utf8'),     'password' => array('type' => 'string', 'null' => false, 'length' => 64, 'collate' => 'utf8_unicode_ci', 'charset' => 'utf8'),     'email' => array('type' => 'string', 'null' => false, 'length' => 128, 'key' => 'unique', 'collate' => 'utf8_unicode_ci', 'charset' => 'utf8'),     'status' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 1),     'created' => array('type' => 'datetime', 'null' => true, 'default' => null),     'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),     'indexes' => array('primary' => array('column' => 'id', 'unique' => 1), 'username' => array('column' => 'username', 'unique' => 1), 'email' => array('column' => 'email', 'unique' => 1), 'group_id' => array('column' => 'group_id', 'unique' => 0)),     'tableparameters' => array('charset' => 'utf8', 'collate' => 'utf8_unicode_ci', 'engine' => 'innodb') ); 

my test:

function starttest() {     $this->user =& classregistry::init('user'); }  function endtest() {     unset($this->user);     classregistry::flush(); }  function testnewuser(){     $data = array('user' => array('username' => 'johndoe', 'password' => 'john', 'email' => 'john@doe.com'));      $result = $this->user->newuser($data);     $expected = array(         'user' => array(             'id' => 1,             'group_id' => 3,             'username' => 'johndoe',             'password' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', //replaced hashed password x's posting             'email' => 'john@doe.com',             'status' => 0,             'created' => date('y-m-d h:i:s'),             'modified' => date('y-m-d h:i:s'),         )     );     $this->assertequal($result, $expected); } 

the model method i'm trying test:

function newuser($data, $group = null){     $this->create();     $user['user']['username'] = $data['user']['username'];     $user['user']['password'] = $data['user']['password'];     $user['user']['email'] = $data['user']['email'];     $user['user']['status'] = 0;     $group = empty($group) ? 3 : $group;     $user['user']['group_id'] = $group;     //return true;     return $this->save($user); } 

the error:

failed equal expectation fails [boolean: false] not match [array: 1 items]  @ [/users/shaz/sites/cakeapp/tests/cases/models/user.test.php line 36]  /users/shaz/sites/cakeapp/tests/cases/models/user.test.php -> usertestcase -> testnewuser 

the false, i'm assuming, coming $this->save($user) not saving , returning false; , i'm not sure why works in app via controller ($this->data form).


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -