Я пытаюсь достичь 100% покрытия кода, но не могу определить, как охватить строки, подобные # 57 ниже. Это просто конец}. У меня есть эти строки во всем моем коде, а также такие строки, как,} else {, но они не покрыты и не помечены как мертвый код.
Как бы я написал тест, чтобы охватить эти строки?
34 : public function addAction() {
35 :
36 2 : $form = new Roles_Form_Add();
37 :
38 2 : if ($this->getRequest()->isPost()) {
39 :
40 1 : if ($form->isValid($this->getRequest()->getPost())) {
41 :
42 1 : $clean = $form->getValues();
43 :
44 1 : $roleService = new Roles_Service_Role();
45 :
46 1 : $role = $roleService->fetchNew();
47 1 : $role->setFromArray($clean)
48 1 : ->save();
49 :
50 1 : $this->_helper->flashMessenger('A new role has been added.');
51 :
52 1 : $this->_helper->redirector('view','role','roles',array('id'=>$role->id));
53 1 : return;
54 :
55 : }
56 :
57 0 : }
58 :
59 1 : $form->setAction($this->_helper->url('add','role','roles'));
60 :
61 1 : $this->view->addRoleForm = $form;
62 :
63 1 : }
64 :
public function testAddAction() {
$this->dispatch('/roles/role/add');
$this->assertModule('roles');
$this->assertController('role');
$this->assertAction('add');
$this->assertQuery('form#addRole input#name');
}
public function testAddActionWithPost() {
$this->getRequest()->setMethod('POST')
->setPost('name','Test');
$this->dispatch('/roles/role/add');
$this->assertRedirectTo('/roles/role/view/id/1');
}