@@ 41-56 (lines=16) @@ | ||
38 | * |
|
39 | * @Then :name can :op content :content |
|
40 | */ |
|
41 | public function userCanContent($name, $op, $title) { |
|
42 | ||
43 | $op = strtr($op, array('edit' => 'update')); |
|
44 | $node = $this->loadNodeByName($title); |
|
45 | $account = user_load_by_name($name); |
|
46 | $access = $node->access($op, $account); |
|
47 | ||
48 | if (!$access) { |
|
49 | $params = array( |
|
50 | '@name' => $name, |
|
51 | '@op' => $op, |
|
52 | '@content' => $title, |
|
53 | ); |
|
54 | throw new \Exception(format_string("@name can not @op @content.", $params)); |
|
55 | } |
|
56 | } |
|
57 | ||
58 | /** |
|
59 | * Assert that given user cannot perform given operation on given content. |
|
@@ 74-88 (lines=15) @@ | ||
71 | * @Then :name can not :op content :content |
|
72 | * @Then :name cannot :op content :content |
|
73 | */ |
|
74 | public function userCanNotContent($name, $op, $title) { |
|
75 | $op = strtr($op, array('edit' => 'update')); |
|
76 | $node = $this->loadNodeByName($title); |
|
77 | $account = user_load_by_name($name); |
|
78 | $access = $node->access($op, $account); |
|
79 | ||
80 | if ($access) { |
|
81 | $params = array( |
|
82 | '@name' => $name, |
|
83 | '@op' => $op, |
|
84 | '@content' => $title, |
|
85 | ); |
|
86 | throw new \Exception(format_string("@name can @op @content but should not.", $params)); |
|
87 | } |
|
88 | } |
|
89 | ||
90 | /** |
|
91 | * Assert presence of content edit link given its name and content title. |