What is the best way to split my data level and limit the scope of my unit tests?

I understand unit testing and find out how to split my code into test bits, but I don’t understand how I can write my own code of a higher level, for example, my controller so that testing the controller does not require passing the actual data level (which is independently tested in another place of my test suite).

For example, I have a user check that accepts a username / password and checks their account and returns login success / failure:

class Api_AuthController extends Zend_Controller_Action
{
  public function validateUserAction()
  {
    // extract, clean and validate $username from POSTed data
    // extract, clean and validate $password from POSTed data

    // access the data layer
    $accountMapper = new Application_Model_Mapper_Account();
    $accounts = $accountMapper(find(array('username' => $username, 'password' => $password));

    if (count($accounts) == 1) {
      // success
    } else {
      // failure
    }
  }
}

, Application_Model_Mapper_Account find() unit test, (, , - , , ) , , , - .

- mocks mapper model , validateUserAction?

+3
1

.net, Control, . , , , , .

+1

All Articles