1 | <?php |
||
27 | class CmsFormsContext extends BehatContext { |
||
28 | protected $context; |
||
29 | |||
30 | /** |
||
31 | * Initializes context. |
||
32 | * Every scenario gets it's own context object. |
||
33 | * |
||
34 | * @param array $parameters context parameters (set them up through behat.yml) |
||
35 | */ |
||
36 | public function __construct(array $parameters) { |
||
40 | |||
41 | /** |
||
42 | * Get Mink session from MinkContext |
||
43 | */ |
||
44 | public function getSession($name = null) { |
||
47 | |||
48 | /** |
||
49 | * Returns fixed step argument (with \\" replaced back to "). |
||
50 | * Copied from {@see MinkContext} |
||
51 | * |
||
52 | * @param string $argument |
||
53 | * @return string |
||
54 | */ |
||
55 | protected function fixStepArgument($argument) { |
||
58 | |||
59 | /** |
||
60 | * @Then /^I should( not? |\s*)see an edit page form$/ |
||
61 | */ |
||
62 | public function stepIShouldSeeAnEditPageForm($negative) { |
||
72 | |||
73 | /** |
||
74 | * @When /^I fill in the "(?P<field>(?:[^"]|\\")*)" HTML field with "(?P<value>(?:[^"]|\\")*)"$/ |
||
75 | * @When /^I fill in "(?P<value>(?:[^"]|\\")*)" for the "(?P<field>(?:[^"]|\\")*)" HTML field$/ |
||
76 | */ |
||
77 | public function stepIFillInTheHtmlFieldWith($field, $value) { |
||
87 | |||
88 | /** |
||
89 | * @When /^I append "(?P<value>(?:[^"]|\\")*)" to the "(?P<field>(?:[^"]|\\")*)" HTML field$/ |
||
90 | */ |
||
91 | public function stepIAppendTotheHtmlField($field, $value) { |
||
101 | |||
102 | /** |
||
103 | * @Then /^the "(?P<locator>(?:[^"]|\\")*)" HTML field should(?P<negative> not? |\s*)contain "(?P<html>.*)"$/ |
||
104 | */ |
||
105 | public function theHtmlFieldShouldContain($locator, $negative, $html) { |
||
132 | |||
133 | // @codingStandardsIgnoreStart |
||
134 | /** |
||
135 | * Checks formatting in the HTML field, by analyzing the HTML node surrounding |
||
136 | * the text for certain properties. |
||
137 | * |
||
138 | * Example: Given "my text" in the "Content" HTML field should be right aligned |
||
139 | * Example: Given "my text" in the "Content" HTML field should not be bold |
||
140 | * |
||
141 | * @todo Use an actual DOM parser for more accurate assertions |
||
142 | * |
||
143 | * @Given /^"(?P<text>([^"]*))" in the "(?P<field>(?:[^"]|\\")*)" HTML field should(?P<negate>(?: not)?) be (?P<formatting>(.*))$/ |
||
144 | */ |
||
145 | public function stepContentInHtmlFieldShouldHaveFormatting($text, $field, $negate, $formatting) { |
||
172 | // @codingStandardsIgnoreEnd |
||
173 | |||
174 | /** |
||
175 | * Selects the first textual match in the HTML editor. Does not support |
||
176 | * selection across DOM node boundaries. |
||
177 | * |
||
178 | * @When /^I select "(?P<text>([^"]*))" in the "(?P<field>(?:[^"]|\\")*)" HTML field$/ |
||
179 | */ |
||
180 | public function stepIHighlightTextInHtmlField($text, $field) { |
||
212 | |||
213 | /** |
||
214 | * Example: I should see a "Submit" button |
||
215 | * Example: I should not see a "Delete" button |
||
216 | * |
||
217 | * @Given /^I should( not? |\s*)see a "([^"]*)" button$/ |
||
218 | */ |
||
219 | public function iShouldSeeAButton($negative, $text) { |
||
233 | |||
234 | /** |
||
235 | * @Given /^I should( not? |\s*)see a "([^"]*)" field$/ |
||
236 | */ |
||
237 | public function iShouldSeeAField($negative, $text) { |
||
251 | |||
252 | /** |
||
253 | * Locate a HTML editor field |
||
254 | * |
||
255 | * @param string $locator Raw html field identifier as passed from |
||
256 | * @return NodeElement |
||
257 | */ |
||
258 | protected function getHtmlField($locator) |
||
266 | |||
267 | } |
||
268 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.