Exemplo n.º 1
0
 public function testRecordLoading()
 {
     $this->_initAdapter('User');
     $this->_adapter->expects($this->any())->method('getRecord')->will($this->onConsecutiveCalls(false, true));
     $this->_adapter->expects($this->once())->method('getNewRecord')->will($this->returnValue(false));
     $form = new CU_Form_Model(array('model' => 'User', 'adapter' => $this->_adapter));
     //First getRecord is set up to return false
     $this->assertFalse($form->getRecord());
     $user = array('login' => 'Login', 'password' => 'Password');
     $this->_adapter->expects($this->once())->method('setRecord')->with($this->equalTo($user));
     //NOTE: will cause a wrong value to be inputted into the password field!
     $this->_adapter->expects($this->any())->method('getRecordValue')->will($this->returnValue('Login'));
     $form->setRecord($user);
     //Second getRecord is set up to return true
     $this->assertTrue($form->getRecord());
     $this->assertEquals('Login', $form->getElementForColumn('login')->getValue());
 }