I am writing unit test case for service in zend2. I have experience in zend2_ dcotrine2 But I am beginner in writing unit test cases.
Method in service for which I have to write unit test cases.
//function create repository
public function createrepo($clientId, $projectId, $username,$password)
{
if (0 === (int)$client) throw new InvalidArgumentException('CientId must be an integer value.');
if ('' === $username) throw new InvalidArgumentException('USername can not be empty.');
// Decode client's/project Id
$clientId = base64_decode($clientId);
$projectId = base64_decode($projectId);
// Make project's directory
$this->createProjectDir($clientId, $projectId);
// Initialize Git within same project's directory
$this->initGitForProjectDir($clientId, $projectId);
// Add user in Apache's known user list
$this->genHtPasswdFileForProjectDir($clientId, $username, $password);
// Make HTTP Auth overridable from within project
$this->genHtAccessFileForProjectDir($clientId, $projectId);
return true;
}
My test cases are: a) Client id must be integer b) Username should not be empty. c) Function must return true.
I am not using any entity or entity repository in this project because it is not required in this application. I am using this function in Application/Service/Repository. Please give me an idea on code level.
Aucun commentaire:
Enregistrer un commentaire