public function testCreatingDevelopmentRole()
{
$application = $this->getApplication();
$application->add($this->command);
$command = $this->getApplication()->find($this->commandName);
$this->roleModel->expects($this->once())->method('load')->with('Development', 'role_name')->will($this->returnValue($this->roleModel));
$this->roleModel->expects($this->at(1))->method('getId')->will($this->returnValue(null));
$this->roleModel->expects($this->once())->method('setName')->with('Development')->will($this->returnValue($this->roleModel));
$this->roleModel->expects($this->once())->method('setRoleType')->with('G')->will($this->returnValue($this->roleModel));
$this->roleModel->expects($this->once())->method('save');
$this->roleModel->expects($this->at(5))->method('getId')->will($this->returnValue(5));
$this->rulesModel->expects($this->once())->method('setRoleId')->with(5)->will($this->returnValue($this->rulesModel));
$this->rulesModel->expects($this->once())->method('setResources')->with(array('all'))->will($this->returnValue($this->rulesModel));
$this->rulesModel->expects($this->once())->method('saveRel');
$this->userModel->expects($this->at(0))->method('setData')->with(array('username' => 'aydin', 'firstname' => 'Aydin', 'lastname' => 'Hassan', 'email' => '[email protected]', 'password' => 'p4ssw0rd', 'is_active' => 1))->will($this->returnValue($this->userModel));
$this->userModel->expects($this->once())->method('save')->will($this->returnValue($this->userModel));
$this->roleModel->expects($this->at(6))->method('getId')->will($this->returnValue(5));
$this->userModel->expects($this->once(2))->method('setRoleIds')->with(array(5))->will($this->returnValue($this->userModel));
$this->userModel->expects($this->at(3))->method('getUserId')->will($this->returnValue(2));
$this->userModel->expects($this->once())->method('setRoleUserId')->with(2)->will($this->returnValue($this->userModel));
$this->userModel->expects($this->once())->method('saveRelations');
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName(), 'username' => 'aydin', 'firstname' => 'Aydin', 'lastname' => 'Hassan', 'email' => '[email protected]', 'password' => 'p4ssw0rd'));
$this->assertContains('The role Development was automatically created', $commandTester->getDisplay());
$this->assertContains('User aydin successfully created', $commandTester->getDisplay());
}