public function Test_of_newRecord() { $User = new AkTestUser(); $User->newRecord('last_name->', 'Ferrer', 'date->', '1978-06-16', 'expires_on->', '2120-06-16'); $User->set('first_name', 'Bermi'); $User->set('last_name', $User->get('last_name') . ' Martínez'); $this->assertEqual($User->getAttributes(), array('id' => null, 'user_name' => null, 'first_name' => 'Bermi', 'last_name' => 'Ferrer Martínez', 'email' => null, 'country' => null, 'password' => '*********', 'created_at' => null, 'updated_at' => null, 'expires_on' => '2120-06-16')); $this->assertTrue($User->isNewRecord()); $User = new AkTestUser(); $User->addCombinedAttributeConfiguration('name', "%s %s", 'first_name', 'last_name'); $User->newRecord(array('first_name' => 'Bermi', 'last_name' => 'Ferrer', 'date' => '1978-06-16', 'expires_on' => '2120-06-16')); $this->assertEqual($User->getAttributes(), array('id' => null, 'user_name' => null, 'first_name' => 'Bermi', 'last_name' => 'Ferrer', 'email' => null, 'country' => null, 'password' => '*********', 'created_at' => null, 'updated_at' => null, 'expires_on' => '2120-06-16', 'name' => 'Bermi Ferrer')); $this->assertFalse(empty($User->_newRecord)); }
function Test_of_setAttribute() { $User = new AkTestUser(); $User->setAttribute('first_name', 'Bermi'); $User->setAttribute('password', 'pass'); $this->assertEqual($User->first_name, 'Bermi'); $this->assertFalse($User->setAttribute('_columns', array())); $this->assertFalse(empty($User->_columns)); $this->assertEqual($User->get('password'), '*********'); $User->set('password', 'bermi'); $this->assertEqual($User->getAttributeBeforeTypeCast('password'), 'c6dd746a20f85fecb18591f29508d42d'); }