@@ -11,204 +11,204 @@ |
||
11 | 11 | */ |
12 | 12 | class CwpSearchResult extends ViewableData |
13 | 13 | { |
14 | - private static $casting = [ |
|
15 | - 'Original' => 'Text', |
|
16 | - 'OriginalLink' => 'Text', |
|
17 | - 'Suggestion' => 'Text', |
|
18 | - 'SuggestionLink' => 'Text', |
|
19 | - 'Query' => 'Text', |
|
20 | - 'SearchLink' => 'Text', |
|
21 | - 'RSSLink' => 'Text', |
|
22 | - 'AtomLink' => 'Text', |
|
23 | - ]; |
|
24 | - |
|
25 | - /** |
|
26 | - * List of results |
|
27 | - * |
|
28 | - * @var PaginatedList |
|
29 | - */ |
|
30 | - protected $matches; |
|
31 | - |
|
32 | - /** |
|
33 | - * Search terms for these results |
|
34 | - * |
|
35 | - * @var string |
|
36 | - */ |
|
37 | - protected $query; |
|
38 | - |
|
39 | - /** |
|
40 | - * Suggested search keywords |
|
41 | - * Used when this search has suggested terms, but following suggestions isn't enabled |
|
42 | - * |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - protected $suggestion; |
|
46 | - |
|
47 | - /** |
|
48 | - * Original terms superceded by these result. |
|
49 | - * Used when a prior search had suggested terms, and follow suggestions is enabled. |
|
50 | - * |
|
51 | - * @var PaginatedList |
|
52 | - */ |
|
53 | - protected $original; |
|
54 | - |
|
55 | - /** |
|
56 | - * Create a new CwpSearchResult |
|
57 | - * |
|
58 | - * @param string $terms |
|
59 | - * @param ArrayData $results Result from SolrIndex |
|
60 | - */ |
|
61 | - public function __construct($terms = '', ArrayData $results = null) |
|
62 | - { |
|
63 | - $this->query = $terms; |
|
64 | - if ($results) { |
|
65 | - // Clean up the results. |
|
66 | - $matches = $results->Matches; |
|
67 | - foreach ($matches as $result) { |
|
68 | - if (!$result->canView()) { |
|
69 | - $matches->remove($result); |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - $this->matches = $matches; |
|
74 | - $this->suggestion = $results->SuggestionNice; |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Get search results |
|
80 | - * |
|
81 | - * @return PaginatedList |
|
82 | - */ |
|
83 | - public function getResults() |
|
84 | - { |
|
85 | - return $this->matches; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Check if there are found results |
|
90 | - * |
|
91 | - * @return bool |
|
92 | - */ |
|
93 | - public function hasResults() |
|
94 | - { |
|
95 | - return $this->matches && $this->matches->exists(); |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Get search keywords matching these results |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function getQuery() |
|
104 | - { |
|
105 | - return $this->query; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Get suggested search keywords |
|
110 | - * |
|
111 | - * @return string |
|
112 | - */ |
|
113 | - public function getSuggestion() |
|
114 | - { |
|
115 | - return $this->suggestion; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Get original search keywords superceded by these results |
|
120 | - * |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function getOriginal() |
|
124 | - { |
|
125 | - return $this->original; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * Set original keywords |
|
130 | - * |
|
131 | - * @param string $original |
|
132 | - */ |
|
133 | - public function setOriginal($original) |
|
134 | - { |
|
135 | - $this->original = $original; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * Get the link to the suggested search |
|
140 | - * |
|
141 | - * @param string $format Optional output format |
|
142 | - * @return string |
|
143 | - */ |
|
144 | - public function getSuggestionLink($format = null) |
|
145 | - { |
|
146 | - return $this->getLink($this->suggestion, $format); |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * Gets the link to the given search |
|
151 | - * |
|
152 | - * @param string $format Optional output format |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - public function getSearchLink($format = null) |
|
156 | - { |
|
157 | - return $this->getLink($this->query, $format); |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Gets the link to the original search, with suggestions disabled |
|
162 | - * |
|
163 | - * @param string $format Optional output format |
|
164 | - * @return string |
|
165 | - */ |
|
166 | - public function getOriginalLink($format = null) |
|
167 | - { |
|
168 | - return $this->getLink($this->original, $format) . "&suggestions=0"; |
|
169 | - } |
|
170 | - |
|
171 | - /** |
|
172 | - * Get link to these results in RSS format |
|
173 | - * |
|
174 | - * @return string |
|
175 | - */ |
|
176 | - public function getRSSLink() |
|
177 | - { |
|
178 | - return $this->getLink($this->query, 'rss'); |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * Get link to these results in atom format |
|
183 | - * |
|
184 | - * @return string |
|
185 | - */ |
|
186 | - public function getAtomLink() |
|
187 | - { |
|
188 | - return $this->getLink($this->query, 'atom'); |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Get a search link for given terms |
|
193 | - * |
|
194 | - * @param string $terms |
|
195 | - * @return string|null |
|
196 | - */ |
|
197 | - protected function getLink($terms, $format = null) |
|
198 | - { |
|
199 | - if (!$terms) { |
|
200 | - return null; |
|
201 | - } |
|
202 | - $link = 'search/SearchForm?Search='.rawurlencode($terms); |
|
203 | - if ($format) { |
|
204 | - $link .= '&format='.rawurlencode($format); |
|
205 | - } |
|
206 | - return $link; |
|
207 | - } |
|
208 | - |
|
209 | - public function hasField($field) |
|
210 | - { |
|
211 | - // Fix customise not detecting custom field getters |
|
212 | - return array_key_exists($field, $this->config()->casting); |
|
213 | - } |
|
14 | + private static $casting = [ |
|
15 | + 'Original' => 'Text', |
|
16 | + 'OriginalLink' => 'Text', |
|
17 | + 'Suggestion' => 'Text', |
|
18 | + 'SuggestionLink' => 'Text', |
|
19 | + 'Query' => 'Text', |
|
20 | + 'SearchLink' => 'Text', |
|
21 | + 'RSSLink' => 'Text', |
|
22 | + 'AtomLink' => 'Text', |
|
23 | + ]; |
|
24 | + |
|
25 | + /** |
|
26 | + * List of results |
|
27 | + * |
|
28 | + * @var PaginatedList |
|
29 | + */ |
|
30 | + protected $matches; |
|
31 | + |
|
32 | + /** |
|
33 | + * Search terms for these results |
|
34 | + * |
|
35 | + * @var string |
|
36 | + */ |
|
37 | + protected $query; |
|
38 | + |
|
39 | + /** |
|
40 | + * Suggested search keywords |
|
41 | + * Used when this search has suggested terms, but following suggestions isn't enabled |
|
42 | + * |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + protected $suggestion; |
|
46 | + |
|
47 | + /** |
|
48 | + * Original terms superceded by these result. |
|
49 | + * Used when a prior search had suggested terms, and follow suggestions is enabled. |
|
50 | + * |
|
51 | + * @var PaginatedList |
|
52 | + */ |
|
53 | + protected $original; |
|
54 | + |
|
55 | + /** |
|
56 | + * Create a new CwpSearchResult |
|
57 | + * |
|
58 | + * @param string $terms |
|
59 | + * @param ArrayData $results Result from SolrIndex |
|
60 | + */ |
|
61 | + public function __construct($terms = '', ArrayData $results = null) |
|
62 | + { |
|
63 | + $this->query = $terms; |
|
64 | + if ($results) { |
|
65 | + // Clean up the results. |
|
66 | + $matches = $results->Matches; |
|
67 | + foreach ($matches as $result) { |
|
68 | + if (!$result->canView()) { |
|
69 | + $matches->remove($result); |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + $this->matches = $matches; |
|
74 | + $this->suggestion = $results->SuggestionNice; |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Get search results |
|
80 | + * |
|
81 | + * @return PaginatedList |
|
82 | + */ |
|
83 | + public function getResults() |
|
84 | + { |
|
85 | + return $this->matches; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Check if there are found results |
|
90 | + * |
|
91 | + * @return bool |
|
92 | + */ |
|
93 | + public function hasResults() |
|
94 | + { |
|
95 | + return $this->matches && $this->matches->exists(); |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Get search keywords matching these results |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + public function getQuery() |
|
104 | + { |
|
105 | + return $this->query; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Get suggested search keywords |
|
110 | + * |
|
111 | + * @return string |
|
112 | + */ |
|
113 | + public function getSuggestion() |
|
114 | + { |
|
115 | + return $this->suggestion; |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Get original search keywords superceded by these results |
|
120 | + * |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function getOriginal() |
|
124 | + { |
|
125 | + return $this->original; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * Set original keywords |
|
130 | + * |
|
131 | + * @param string $original |
|
132 | + */ |
|
133 | + public function setOriginal($original) |
|
134 | + { |
|
135 | + $this->original = $original; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * Get the link to the suggested search |
|
140 | + * |
|
141 | + * @param string $format Optional output format |
|
142 | + * @return string |
|
143 | + */ |
|
144 | + public function getSuggestionLink($format = null) |
|
145 | + { |
|
146 | + return $this->getLink($this->suggestion, $format); |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * Gets the link to the given search |
|
151 | + * |
|
152 | + * @param string $format Optional output format |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + public function getSearchLink($format = null) |
|
156 | + { |
|
157 | + return $this->getLink($this->query, $format); |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Gets the link to the original search, with suggestions disabled |
|
162 | + * |
|
163 | + * @param string $format Optional output format |
|
164 | + * @return string |
|
165 | + */ |
|
166 | + public function getOriginalLink($format = null) |
|
167 | + { |
|
168 | + return $this->getLink($this->original, $format) . "&suggestions=0"; |
|
169 | + } |
|
170 | + |
|
171 | + /** |
|
172 | + * Get link to these results in RSS format |
|
173 | + * |
|
174 | + * @return string |
|
175 | + */ |
|
176 | + public function getRSSLink() |
|
177 | + { |
|
178 | + return $this->getLink($this->query, 'rss'); |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * Get link to these results in atom format |
|
183 | + * |
|
184 | + * @return string |
|
185 | + */ |
|
186 | + public function getAtomLink() |
|
187 | + { |
|
188 | + return $this->getLink($this->query, 'atom'); |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Get a search link for given terms |
|
193 | + * |
|
194 | + * @param string $terms |
|
195 | + * @return string|null |
|
196 | + */ |
|
197 | + protected function getLink($terms, $format = null) |
|
198 | + { |
|
199 | + if (!$terms) { |
|
200 | + return null; |
|
201 | + } |
|
202 | + $link = 'search/SearchForm?Search='.rawurlencode($terms); |
|
203 | + if ($format) { |
|
204 | + $link .= '&format='.rawurlencode($format); |
|
205 | + } |
|
206 | + return $link; |
|
207 | + } |
|
208 | + |
|
209 | + public function hasField($field) |
|
210 | + { |
|
211 | + // Fix customise not detecting custom field getters |
|
212 | + return array_key_exists($field, $this->config()->casting); |
|
213 | + } |
|
214 | 214 | } |
@@ -199,9 +199,9 @@ |
||
199 | 199 | if (!$terms) { |
200 | 200 | return null; |
201 | 201 | } |
202 | - $link = 'search/SearchForm?Search='.rawurlencode($terms); |
|
202 | + $link = 'search/SearchForm?Search=' . rawurlencode($terms); |
|
203 | 203 | if ($format) { |
204 | - $link .= '&format='.rawurlencode($format); |
|
204 | + $link .= '&format=' . rawurlencode($format); |
|
205 | 205 | } |
206 | 206 | return $link; |
207 | 207 | } |
@@ -8,9 +8,9 @@ |
||
8 | 8 | class TaxonomyTermExtension extends DataExtension |
9 | 9 | { |
10 | 10 | |
11 | - private static $api_access = true; |
|
11 | + private static $api_access = true; |
|
12 | 12 | |
13 | - private static $belongs_many_many = array( |
|
14 | - 'Pages' => BasePage::class |
|
15 | - ); |
|
13 | + private static $belongs_many_many = array( |
|
14 | + 'Pages' => BasePage::class |
|
15 | + ); |
|
16 | 16 | } |
@@ -75,7 +75,7 @@ |
||
75 | 75 | ); |
76 | 76 | |
77 | 77 | // strip comments (lines beginning with "#") |
78 | - $lines = array_filter($lines, function ($line) { |
|
78 | + $lines = array_filter($lines, function($line) { |
|
79 | 79 | $line = trim($line); |
80 | 80 | |
81 | 81 | return !empty($line) && $line[0] !== '#'; |
@@ -6,154 +6,154 @@ |
||
6 | 6 | |
7 | 7 | class SynonymValidator extends Validator |
8 | 8 | { |
9 | - /** |
|
10 | - * @var array |
|
11 | - */ |
|
12 | - protected $fieldNames; |
|
13 | - |
|
14 | - /** |
|
15 | - * @inheritdoc |
|
16 | - * |
|
17 | - * @param array $fieldNames |
|
18 | - */ |
|
19 | - public function __construct(array $fieldNames) |
|
20 | - { |
|
21 | - $this->fieldNames = $fieldNames; |
|
22 | - |
|
23 | - parent::__construct(); |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * @inheritdoc |
|
28 | - * |
|
29 | - * @param array $data |
|
30 | - * |
|
31 | - * @return mixed |
|
32 | - */ |
|
33 | - public function php($data) |
|
34 | - { |
|
35 | - foreach ($this->fieldNames as $fieldName) { |
|
36 | - if (empty($data[$fieldName])) { |
|
37 | - return; |
|
38 | - } |
|
39 | - |
|
40 | - $this->validateField($fieldName, $data[$fieldName]); |
|
41 | - } |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Validate field values, raising errors if the values are invalid. |
|
46 | - * |
|
47 | - * @param string $fieldName |
|
48 | - * @param mixed $value |
|
49 | - */ |
|
50 | - protected function validateField($fieldName, $value) |
|
51 | - { |
|
52 | - if (!$this->validateValue($value)) { |
|
53 | - $this->validationError( |
|
54 | - $fieldName, |
|
55 | - _t( |
|
56 | - __CLASS__ . '.InvalidValue', |
|
57 | - 'Synonyms cannot contain words separated by spaces' |
|
58 | - ) |
|
59 | - ); |
|
60 | - } |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Check field values to see that they doesn't contain spaces between words. |
|
65 | - * |
|
66 | - * @param mixed $value |
|
67 | - * |
|
68 | - * @return bool |
|
69 | - */ |
|
70 | - protected function validateValue($value) |
|
71 | - { |
|
72 | - // strip empty lines |
|
73 | - $lines = array_filter( |
|
74 | - explode("\n", $value) |
|
75 | - ); |
|
76 | - |
|
77 | - // strip comments (lines beginning with "#") |
|
78 | - $lines = array_filter($lines, function ($line) { |
|
79 | - $line = trim($line); |
|
80 | - |
|
81 | - return !empty($line) && $line[0] !== '#'; |
|
82 | - }); |
|
83 | - |
|
84 | - // validate each line |
|
85 | - foreach ($lines as $line) { |
|
86 | - if (!$this->validateLine($line)) { |
|
87 | - return false; |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - return true; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Check each line to see that it doesn't contain spaces between words. |
|
96 | - * |
|
97 | - * @param string $line |
|
98 | - * |
|
99 | - * @return bool |
|
100 | - */ |
|
101 | - protected function validateLine($line) |
|
102 | - { |
|
103 | - $line = trim($line); |
|
104 | - |
|
105 | - $parts = explode(',', $line); |
|
106 | - $parts = array_filter($parts); |
|
107 | - |
|
108 | - foreach ($parts as $part) { |
|
109 | - if (!$this->validatePart($part)) { |
|
110 | - return false; |
|
111 | - } |
|
112 | - } |
|
113 | - |
|
114 | - return true; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * Check each part of the line doesn't contain spaces between words. |
|
119 | - * |
|
120 | - * @param string $part |
|
121 | - * |
|
122 | - * @return bool |
|
123 | - */ |
|
124 | - protected function validatePart($part) |
|
125 | - { |
|
126 | - if (strpos($part, '=>') !== false) { |
|
127 | - $subs = explode('=>', $part); |
|
128 | - $subs = array_filter($subs); |
|
129 | - |
|
130 | - foreach ($subs as $sub) { |
|
131 | - if (!$this->validateNoSpaces($sub)) { |
|
132 | - return false; |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - return true; |
|
137 | - } |
|
138 | - |
|
139 | - return $this->validateNoSpaces($part); |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * @param string $value |
|
144 | - * |
|
145 | - * @return bool |
|
146 | - */ |
|
147 | - protected function validateNoSpaces($value) |
|
148 | - { |
|
149 | - // allow spaces at the beginning and end of the value |
|
150 | - $value = trim($value); |
|
151 | - |
|
152 | - // does the value contain 1 or more whitespace characters? |
|
153 | - if (preg_match('/\s+/', $value)) { |
|
154 | - return false; |
|
155 | - } |
|
156 | - |
|
157 | - return true; |
|
158 | - } |
|
9 | + /** |
|
10 | + * @var array |
|
11 | + */ |
|
12 | + protected $fieldNames; |
|
13 | + |
|
14 | + /** |
|
15 | + * @inheritdoc |
|
16 | + * |
|
17 | + * @param array $fieldNames |
|
18 | + */ |
|
19 | + public function __construct(array $fieldNames) |
|
20 | + { |
|
21 | + $this->fieldNames = $fieldNames; |
|
22 | + |
|
23 | + parent::__construct(); |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * @inheritdoc |
|
28 | + * |
|
29 | + * @param array $data |
|
30 | + * |
|
31 | + * @return mixed |
|
32 | + */ |
|
33 | + public function php($data) |
|
34 | + { |
|
35 | + foreach ($this->fieldNames as $fieldName) { |
|
36 | + if (empty($data[$fieldName])) { |
|
37 | + return; |
|
38 | + } |
|
39 | + |
|
40 | + $this->validateField($fieldName, $data[$fieldName]); |
|
41 | + } |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Validate field values, raising errors if the values are invalid. |
|
46 | + * |
|
47 | + * @param string $fieldName |
|
48 | + * @param mixed $value |
|
49 | + */ |
|
50 | + protected function validateField($fieldName, $value) |
|
51 | + { |
|
52 | + if (!$this->validateValue($value)) { |
|
53 | + $this->validationError( |
|
54 | + $fieldName, |
|
55 | + _t( |
|
56 | + __CLASS__ . '.InvalidValue', |
|
57 | + 'Synonyms cannot contain words separated by spaces' |
|
58 | + ) |
|
59 | + ); |
|
60 | + } |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Check field values to see that they doesn't contain spaces between words. |
|
65 | + * |
|
66 | + * @param mixed $value |
|
67 | + * |
|
68 | + * @return bool |
|
69 | + */ |
|
70 | + protected function validateValue($value) |
|
71 | + { |
|
72 | + // strip empty lines |
|
73 | + $lines = array_filter( |
|
74 | + explode("\n", $value) |
|
75 | + ); |
|
76 | + |
|
77 | + // strip comments (lines beginning with "#") |
|
78 | + $lines = array_filter($lines, function ($line) { |
|
79 | + $line = trim($line); |
|
80 | + |
|
81 | + return !empty($line) && $line[0] !== '#'; |
|
82 | + }); |
|
83 | + |
|
84 | + // validate each line |
|
85 | + foreach ($lines as $line) { |
|
86 | + if (!$this->validateLine($line)) { |
|
87 | + return false; |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + return true; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Check each line to see that it doesn't contain spaces between words. |
|
96 | + * |
|
97 | + * @param string $line |
|
98 | + * |
|
99 | + * @return bool |
|
100 | + */ |
|
101 | + protected function validateLine($line) |
|
102 | + { |
|
103 | + $line = trim($line); |
|
104 | + |
|
105 | + $parts = explode(',', $line); |
|
106 | + $parts = array_filter($parts); |
|
107 | + |
|
108 | + foreach ($parts as $part) { |
|
109 | + if (!$this->validatePart($part)) { |
|
110 | + return false; |
|
111 | + } |
|
112 | + } |
|
113 | + |
|
114 | + return true; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * Check each part of the line doesn't contain spaces between words. |
|
119 | + * |
|
120 | + * @param string $part |
|
121 | + * |
|
122 | + * @return bool |
|
123 | + */ |
|
124 | + protected function validatePart($part) |
|
125 | + { |
|
126 | + if (strpos($part, '=>') !== false) { |
|
127 | + $subs = explode('=>', $part); |
|
128 | + $subs = array_filter($subs); |
|
129 | + |
|
130 | + foreach ($subs as $sub) { |
|
131 | + if (!$this->validateNoSpaces($sub)) { |
|
132 | + return false; |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + return true; |
|
137 | + } |
|
138 | + |
|
139 | + return $this->validateNoSpaces($part); |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * @param string $value |
|
144 | + * |
|
145 | + * @return bool |
|
146 | + */ |
|
147 | + protected function validateNoSpaces($value) |
|
148 | + { |
|
149 | + // allow spaces at the beginning and end of the value |
|
150 | + $value = trim($value); |
|
151 | + |
|
152 | + // does the value contain 1 or more whitespace characters? |
|
153 | + if (preg_match('/\s+/', $value)) { |
|
154 | + return false; |
|
155 | + } |
|
156 | + |
|
157 | + return true; |
|
158 | + } |
|
159 | 159 | } |
@@ -12,37 +12,37 @@ |
||
12 | 12 | */ |
13 | 13 | class CwpWorkflowDefinitionExtension extends DataExtension |
14 | 14 | { |
15 | - /** |
|
16 | - * Create the default 'Two-step Workflow' when this extension is loaded |
|
17 | - * |
|
18 | - * @config |
|
19 | - * @var boolean |
|
20 | - */ |
|
21 | - private static $create_default_workflow = true; |
|
15 | + /** |
|
16 | + * Create the default 'Two-step Workflow' when this extension is loaded |
|
17 | + * |
|
18 | + * @config |
|
19 | + * @var boolean |
|
20 | + */ |
|
21 | + private static $create_default_workflow = true; |
|
22 | 22 | |
23 | - public function requireDefaultRecords() |
|
24 | - { |
|
25 | - if (Config::inst()->get(CwpWorkflowDefinitionExtension::class, 'create_default_workflow')) { |
|
26 | - // Only proceed if a definition using this template has not been created yet |
|
27 | - $definition = WorkflowDefinition::get()->filter("Template", "Review and Approve")->First(); |
|
28 | - if ($definition && $definition->exists()) { |
|
29 | - return; |
|
30 | - } |
|
23 | + public function requireDefaultRecords() |
|
24 | + { |
|
25 | + if (Config::inst()->get(CwpWorkflowDefinitionExtension::class, 'create_default_workflow')) { |
|
26 | + // Only proceed if a definition using this template has not been created yet |
|
27 | + $definition = WorkflowDefinition::get()->filter("Template", "Review and Approve")->First(); |
|
28 | + if ($definition && $definition->exists()) { |
|
29 | + return; |
|
30 | + } |
|
31 | 31 | |
32 | - //generate from the template, which happens after we write the definition |
|
33 | - $definition = WorkflowDefinition::create(); |
|
34 | - $definition->Template = "Review and Approve"; |
|
35 | - $definition->write(); |
|
32 | + //generate from the template, which happens after we write the definition |
|
33 | + $definition = WorkflowDefinition::create(); |
|
34 | + $definition->Template = "Review and Approve"; |
|
35 | + $definition->write(); |
|
36 | 36 | |
37 | - //change the title, description, and reminder days |
|
38 | - $definition->update(array( |
|
39 | - 'Title' => "Two-step Workflow", |
|
40 | - 'Description' => "Content Authors can write content and Content Publishers can approve/reject.", |
|
41 | - 'RemindDays' => 3, |
|
42 | - )); |
|
43 | - $definition->write(); |
|
37 | + //change the title, description, and reminder days |
|
38 | + $definition->update(array( |
|
39 | + 'Title' => "Two-step Workflow", |
|
40 | + 'Description' => "Content Authors can write content and Content Publishers can approve/reject.", |
|
41 | + 'RemindDays' => 3, |
|
42 | + )); |
|
43 | + $definition->write(); |
|
44 | 44 | |
45 | - DB::alteration_message("Added default workflow definition to WorkflowDefinition table", "created"); |
|
46 | - } |
|
47 | - } |
|
45 | + DB::alteration_message("Added default workflow definition to WorkflowDefinition table", "created"); |
|
46 | + } |
|
47 | + } |
|
48 | 48 | } |
@@ -8,42 +8,42 @@ |
||
8 | 8 | |
9 | 9 | class BasePageTest extends SapphireTest |
10 | 10 | { |
11 | - protected static $fixture_file = 'BasePageTest.yml'; |
|
12 | - |
|
13 | - protected function setUp() |
|
14 | - { |
|
15 | - parent::setUp(); |
|
16 | - |
|
17 | - Config::modify()->set(BasePage::class, 'pdf_export', true); |
|
18 | - Config::modify()->set(BasePage::class, 'generated_pdf_path', 'assets/_generated_pdfs'); |
|
19 | - } |
|
20 | - |
|
21 | - public function testPdfFilename() |
|
22 | - { |
|
23 | - $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
24 | - $this->assertContains( |
|
25 | - 'assets/_generated_pdfs/test-page-one-1.pdf', |
|
26 | - $page->getPdfFilename(), |
|
27 | - 'Generated filename for PDF' |
|
28 | - ); |
|
29 | - } |
|
30 | - |
|
31 | - public function testPdfLink() |
|
32 | - { |
|
33 | - $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
34 | - $this->assertContains('test-page-one/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
35 | - } |
|
36 | - |
|
37 | - public function testHomePagePdfLink() |
|
38 | - { |
|
39 | - $page = $this->objFromFixture(BasePage::class, 'home-page'); |
|
40 | - $this->assertContains('home/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
41 | - } |
|
42 | - |
|
43 | - public function testPdfLinkDisabled() |
|
44 | - { |
|
45 | - Config::modify()->set(BasePage::class, 'pdf_export', false); |
|
46 | - $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
47 | - $this->assertFalse($page->PdfLink(), 'No PDF link as the functionality is disabled'); |
|
48 | - } |
|
11 | + protected static $fixture_file = 'BasePageTest.yml'; |
|
12 | + |
|
13 | + protected function setUp() |
|
14 | + { |
|
15 | + parent::setUp(); |
|
16 | + |
|
17 | + Config::modify()->set(BasePage::class, 'pdf_export', true); |
|
18 | + Config::modify()->set(BasePage::class, 'generated_pdf_path', 'assets/_generated_pdfs'); |
|
19 | + } |
|
20 | + |
|
21 | + public function testPdfFilename() |
|
22 | + { |
|
23 | + $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
24 | + $this->assertContains( |
|
25 | + 'assets/_generated_pdfs/test-page-one-1.pdf', |
|
26 | + $page->getPdfFilename(), |
|
27 | + 'Generated filename for PDF' |
|
28 | + ); |
|
29 | + } |
|
30 | + |
|
31 | + public function testPdfLink() |
|
32 | + { |
|
33 | + $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
34 | + $this->assertContains('test-page-one/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
35 | + } |
|
36 | + |
|
37 | + public function testHomePagePdfLink() |
|
38 | + { |
|
39 | + $page = $this->objFromFixture(BasePage::class, 'home-page'); |
|
40 | + $this->assertContains('home/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
41 | + } |
|
42 | + |
|
43 | + public function testPdfLinkDisabled() |
|
44 | + { |
|
45 | + Config::modify()->set(BasePage::class, 'pdf_export', false); |
|
46 | + $page = $this->objFromFixture(BasePage::class, 'test-page-one'); |
|
47 | + $this->assertFalse($page->PdfLink(), 'No PDF link as the functionality is disabled'); |
|
48 | + } |
|
49 | 49 | } |
@@ -8,94 +8,94 @@ |
||
8 | 8 | |
9 | 9 | class EventHolderTest extends SapphireTest |
10 | 10 | { |
11 | - protected static $fixture_file = 'EventHolderTest.yml'; |
|
11 | + protected static $fixture_file = 'EventHolderTest.yml'; |
|
12 | 12 | |
13 | - public function testEventTags() |
|
14 | - { |
|
15 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
13 | + public function testEventTags() |
|
14 | + { |
|
15 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
16 | 16 | |
17 | - $tags = $holder->UpdateTags(); |
|
18 | - $this->assertNotNull($tags->find('Name', 'Future'), 'Finds present terms.'); |
|
19 | - $this->assertNull($tags->find('Name', 'Event types', 'Does not find top level taxonomy.')); |
|
20 | - $this->assertNull($tags->find('Name', 'Carrot'), 'Does not find terms that are not applied.'); |
|
21 | - } |
|
17 | + $tags = $holder->UpdateTags(); |
|
18 | + $this->assertNotNull($tags->find('Name', 'Future'), 'Finds present terms.'); |
|
19 | + $this->assertNull($tags->find('Name', 'Event types', 'Does not find top level taxonomy.')); |
|
20 | + $this->assertNull($tags->find('Name', 'Carrot'), 'Does not find terms that are not applied.'); |
|
21 | + } |
|
22 | 22 | |
23 | - public function testEventWithParentFilter() |
|
24 | - { |
|
25 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder2'); |
|
23 | + public function testEventWithParentFilter() |
|
24 | + { |
|
25 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder2'); |
|
26 | 26 | |
27 | - $items = $holder->Updates(); |
|
27 | + $items = $holder->Updates(); |
|
28 | 28 | |
29 | - $this->assertNotNull($items->find('URLSegment', 'other-holder'), 'Event from the holder is shown.'); |
|
30 | - $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Events from other holders are not shown.'); |
|
31 | - } |
|
29 | + $this->assertNotNull($items->find('URLSegment', 'other-holder'), 'Event from the holder is shown.'); |
|
30 | + $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Events from other holders are not shown.'); |
|
31 | + } |
|
32 | 32 | |
33 | - public function testEventsWithTagFilter() |
|
34 | - { |
|
35 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
33 | + public function testEventsWithTagFilter() |
|
34 | + { |
|
35 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
36 | 36 | |
37 | - //Get the "Future" tag. |
|
38 | - $tag = $this->objFromFixture(TaxonomyTerm::class, 'TaxonomyTerm1'); |
|
37 | + //Get the "Future" tag. |
|
38 | + $tag = $this->objFromFixture(TaxonomyTerm::class, 'TaxonomyTerm1'); |
|
39 | 39 | |
40 | - $items = $holder->Updates($tag->ID); |
|
40 | + $items = $holder->Updates($tag->ID); |
|
41 | 41 | |
42 | - $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the tagged page.'); |
|
43 | - $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find pages that are not tagged.'); |
|
44 | - } |
|
42 | + $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the tagged page.'); |
|
43 | + $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find pages that are not tagged.'); |
|
44 | + } |
|
45 | 45 | |
46 | - public function testEventsWithMonthFilter() |
|
47 | - { |
|
48 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
46 | + public function testEventsWithMonthFilter() |
|
47 | + { |
|
48 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
49 | 49 | |
50 | - $items = $holder->Updates(null, null, null, 2013, 7); |
|
50 | + $items = $holder->Updates(null, null, null, 2013, 7); |
|
51 | 51 | |
52 | - $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the event in 2013-07.'); |
|
53 | - $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find events at other dates.'); |
|
54 | - } |
|
52 | + $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the event in 2013-07.'); |
|
53 | + $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find events at other dates.'); |
|
54 | + } |
|
55 | 55 | |
56 | - public function testEventsWithDateRangeFilter() |
|
57 | - { |
|
58 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
56 | + public function testEventsWithDateRangeFilter() |
|
57 | + { |
|
58 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
59 | 59 | |
60 | - $items = $holder->Updates(null, '2013-01-19', null); |
|
61 | - $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds the event at the date'); |
|
62 | - $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find the event at another date'); |
|
60 | + $items = $holder->Updates(null, '2013-01-19', null); |
|
61 | + $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds the event at the date'); |
|
62 | + $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find the event at another date'); |
|
63 | 63 | |
64 | - $items = $holder->Updates(null, '2013-01-01', '2013-01-19'); |
|
65 | - $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds events in the date range'); |
|
66 | - $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find event out of range'); |
|
67 | - } |
|
64 | + $items = $holder->Updates(null, '2013-01-01', '2013-01-19'); |
|
65 | + $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds events in the date range'); |
|
66 | + $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find event out of range'); |
|
67 | + } |
|
68 | 68 | |
69 | - public function testExtractMonths() |
|
70 | - { |
|
71 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
69 | + public function testExtractMonths() |
|
70 | + { |
|
71 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
72 | 72 | |
73 | - $months = EventHolder::ExtractMonths( |
|
74 | - $holder->Updates(), |
|
75 | - 'http://mybase.org/?tag=12&start=10&from=2010-10-10&to=2010-10-11', // Used for link generation |
|
76 | - 2013, // Currently selected |
|
77 | - 1 // Currently selected |
|
78 | - ); |
|
73 | + $months = EventHolder::ExtractMonths( |
|
74 | + $holder->Updates(), |
|
75 | + 'http://mybase.org/?tag=12&start=10&from=2010-10-10&to=2010-10-11', // Used for link generation |
|
76 | + 2013, // Currently selected |
|
77 | + 1 // Currently selected |
|
78 | + ); |
|
79 | 79 | |
80 | - // Check which years are generated. |
|
81 | - $this->assertNotNull($months->find('YearName', 2013), 'Generates existing year'); |
|
82 | - $this->assertNull($months->find('YearName', 1990), 'Does not generate non-present year'); |
|
80 | + // Check which years are generated. |
|
81 | + $this->assertNotNull($months->find('YearName', 2013), 'Generates existing year'); |
|
82 | + $this->assertNull($months->find('YearName', 1990), 'Does not generate non-present year'); |
|
83 | 83 | |
84 | - $year = $months->find('YearName', 2013); |
|
84 | + $year = $months->find('YearName', 2013); |
|
85 | 85 | |
86 | - // Check which months come up in 2013 |
|
87 | - $this->assertNotNull($year['Months']->find('MonthNumber', 7), 'Generates existing month'); |
|
88 | - $this->assertNull($year['Months']->find('MonthNumber', 12), 'Does not generate non-present month'); |
|
86 | + // Check which months come up in 2013 |
|
87 | + $this->assertNotNull($year['Months']->find('MonthNumber', 7), 'Generates existing month'); |
|
88 | + $this->assertNull($year['Months']->find('MonthNumber', 12), 'Does not generate non-present month'); |
|
89 | 89 | |
90 | - $month = $year['Months']->find('MonthNumber', 7); |
|
91 | - $this->assertEquals( |
|
92 | - $month['MonthLink'], |
|
93 | - 'http://mybase.org/?tag=12&from=2010-10-10&to=2010-10-11&month=7&year=2013', |
|
94 | - 'Selection link is built properly - start is removed, and tag, from and to retained.' |
|
95 | - ); |
|
90 | + $month = $year['Months']->find('MonthNumber', 7); |
|
91 | + $this->assertEquals( |
|
92 | + $month['MonthLink'], |
|
93 | + 'http://mybase.org/?tag=12&from=2010-10-10&to=2010-10-11&month=7&year=2013', |
|
94 | + 'Selection link is built properly - start is removed, and tag, from and to retained.' |
|
95 | + ); |
|
96 | 96 | |
97 | - // Check if these months are marked properly. |
|
98 | - $month = $year['Months']->find('MonthNumber', 1); |
|
99 | - $this->assertEquals($month['Active'], true, 'Correctly marks active link'); |
|
100 | - } |
|
97 | + // Check if these months are marked properly. |
|
98 | + $month = $year['Months']->find('MonthNumber', 1); |
|
99 | + $this->assertEquals($month['Active'], true, 'Correctly marks active link'); |
|
100 | + } |
|
101 | 101 | } |
@@ -9,26 +9,26 @@ |
||
9 | 9 | |
10 | 10 | class SitemapPageTest extends FunctionalTest |
11 | 11 | { |
12 | - protected static $fixture_file = 'SitemapPageTest.yml'; |
|
12 | + protected static $fixture_file = 'SitemapPageTest.yml'; |
|
13 | 13 | |
14 | - protected static $use_draft_site = true; |
|
14 | + protected static $use_draft_site = true; |
|
15 | 15 | |
16 | - protected function setUp() |
|
17 | - { |
|
18 | - parent::setUp(); |
|
16 | + protected function setUp() |
|
17 | + { |
|
18 | + parent::setUp(); |
|
19 | 19 | |
20 | - Config::inst()->update(SSViewer::class, 'theme', 'starter'); |
|
21 | - } |
|
20 | + Config::inst()->update(SSViewer::class, 'theme', 'starter'); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Note: this test depends on the "starter" theme being installed and configured as default |
|
25 | - */ |
|
26 | - public function testSitemapShowsNavigationTitleNotNormalTitle() |
|
27 | - { |
|
28 | - $response = $this->get('sitemap'); |
|
29 | - $parser = new CSSContentParser($response->getBody()); |
|
30 | - $elements = $parser->getBySelector('.sitemap li.first .sitemap-link'); |
|
31 | - $this->assertNotEmpty($elements); |
|
32 | - $this->assertEquals('Top page nav 1', (string) $elements[0]); |
|
33 | - } |
|
23 | + /** |
|
24 | + * Note: this test depends on the "starter" theme being installed and configured as default |
|
25 | + */ |
|
26 | + public function testSitemapShowsNavigationTitleNotNormalTitle() |
|
27 | + { |
|
28 | + $response = $this->get('sitemap'); |
|
29 | + $parser = new CSSContentParser($response->getBody()); |
|
30 | + $elements = $parser->getBySelector('.sitemap li.first .sitemap-link'); |
|
31 | + $this->assertNotEmpty($elements); |
|
32 | + $this->assertEquals('Top page nav 1', (string) $elements[0]); |
|
33 | + } |
|
34 | 34 | } |
@@ -15,34 +15,34 @@ |
||
15 | 15 | class WorkflowDefinitionExtensionTest extends FunctionalTest |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var Boolean If set to TRUE, this will force a test database to be generated |
|
20 | - * in {@link setUp()}. Note that this flag is overruled by the presence of a |
|
21 | - * {@link $fixture_file}, which always forces a database build. |
|
22 | - */ |
|
23 | - protected $usesDatabase = true; |
|
18 | + /** |
|
19 | + * @var Boolean If set to TRUE, this will force a test database to be generated |
|
20 | + * in {@link setUp()}. Note that this flag is overruled by the presence of a |
|
21 | + * {@link $fixture_file}, which always forces a database build. |
|
22 | + */ |
|
23 | + protected $usesDatabase = true; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Tests the config option that controls the creation of a default workflow definition |
|
27 | - * |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function testCreateDefaultWorkflowTest() |
|
31 | - { |
|
32 | - DB::quiet(); |
|
25 | + /** |
|
26 | + * Tests the config option that controls the creation of a default workflow definition |
|
27 | + * |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function testCreateDefaultWorkflowTest() |
|
31 | + { |
|
32 | + DB::quiet(); |
|
33 | 33 | |
34 | - // test disabling the default workflow definition |
|
35 | - Config::modify()->set(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', false); |
|
36 | - $workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class); |
|
37 | - $workflowExtn->requireDefaultRecords(); |
|
38 | - $definition = WorkflowDefinition::get()->first(); |
|
39 | - $this->assertNull($definition); |
|
34 | + // test disabling the default workflow definition |
|
35 | + Config::modify()->set(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', false); |
|
36 | + $workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class); |
|
37 | + $workflowExtn->requireDefaultRecords(); |
|
38 | + $definition = WorkflowDefinition::get()->first(); |
|
39 | + $this->assertNull($definition); |
|
40 | 40 | |
41 | - // test enabling the default workflow definition |
|
42 | - Config::modify()->set(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', true); |
|
43 | - $workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class); |
|
44 | - $workflowExtn->requireDefaultRecords(); |
|
45 | - $definition = WorkflowDefinition::get()->first(); |
|
46 | - $this->assertNotNull($definition); |
|
47 | - } |
|
41 | + // test enabling the default workflow definition |
|
42 | + Config::modify()->set(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', true); |
|
43 | + $workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class); |
|
44 | + $workflowExtn->requireDefaultRecords(); |
|
45 | + $definition = WorkflowDefinition::get()->first(); |
|
46 | + $this->assertNotNull($definition); |
|
47 | + } |
|
48 | 48 | } |
@@ -7,51 +7,51 @@ discard block |
||
7 | 7 | |
8 | 8 | class SynonymValidatorTest extends SapphireTest |
9 | 9 | { |
10 | - /** |
|
11 | - * @var SynonymValidator |
|
12 | - */ |
|
13 | - protected $validator; |
|
10 | + /** |
|
11 | + * @var SynonymValidator |
|
12 | + */ |
|
13 | + protected $validator; |
|
14 | 14 | |
15 | - protected function setUp() |
|
16 | - { |
|
17 | - parent::setUp(); |
|
15 | + protected function setUp() |
|
16 | + { |
|
17 | + parent::setUp(); |
|
18 | 18 | |
19 | - $this->validator = new SynonymValidator([ |
|
20 | - 'Synonyms', |
|
21 | - ]); |
|
22 | - } |
|
19 | + $this->validator = new SynonymValidator([ |
|
20 | + 'Synonyms', |
|
21 | + ]); |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * @dataProvider validValuesProvider |
|
26 | - */ |
|
27 | - public function testItAllowsValidValues($value) |
|
28 | - { |
|
29 | - $this->validator->php([ |
|
30 | - 'Synonyms' => $value, |
|
31 | - ]); |
|
24 | + /** |
|
25 | + * @dataProvider validValuesProvider |
|
26 | + */ |
|
27 | + public function testItAllowsValidValues($value) |
|
28 | + { |
|
29 | + $this->validator->php([ |
|
30 | + 'Synonyms' => $value, |
|
31 | + ]); |
|
32 | 32 | |
33 | - $this->assertEmpty($this->validator->getErrors()); |
|
34 | - } |
|
33 | + $this->assertEmpty($this->validator->getErrors()); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function validValuesProvider() |
|
40 | - { |
|
41 | - return [ |
|
42 | - ['foo'], |
|
43 | - ['foo,bar,baz'], |
|
44 | - ['foo, bar, baz'], |
|
45 | - [ |
|
46 | - ' |
|
36 | + /** |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function validValuesProvider() |
|
40 | + { |
|
41 | + return [ |
|
42 | + ['foo'], |
|
43 | + ['foo,bar,baz'], |
|
44 | + ['foo, bar, baz'], |
|
45 | + [ |
|
46 | + ' |
|
47 | 47 | foo |
48 | 48 | bar |
49 | 49 | baz |
50 | 50 | ' |
51 | - ], |
|
52 | - ['foo => bar, baz'], |
|
53 | - [ |
|
54 | - ' |
|
51 | + ], |
|
52 | + ['foo => bar, baz'], |
|
53 | + [ |
|
54 | + ' |
|
55 | 55 | # this is a comment, it should be ignored! |
56 | 56 | |
57 | 57 | foo, bar, baz |
@@ -59,32 +59,32 @@ discard block |
||
59 | 59 | |
60 | 60 | # ...as should this. |
61 | 61 | ' |
62 | - ], |
|
63 | - ]; |
|
64 | - } |
|
62 | + ], |
|
63 | + ]; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @dataProvider invalidValuesProvider |
|
68 | - * |
|
69 | - * @param string $value |
|
70 | - */ |
|
71 | - public function testItDisallowsInvalidValues($value) |
|
72 | - { |
|
73 | - $this->validator->php([ |
|
74 | - 'Synonyms' => $value, |
|
75 | - ]); |
|
66 | + /** |
|
67 | + * @dataProvider invalidValuesProvider |
|
68 | + * |
|
69 | + * @param string $value |
|
70 | + */ |
|
71 | + public function testItDisallowsInvalidValues($value) |
|
72 | + { |
|
73 | + $this->validator->php([ |
|
74 | + 'Synonyms' => $value, |
|
75 | + ]); |
|
76 | 76 | |
77 | - $this->assertNotEmpty($this->validator->getErrors()); |
|
78 | - } |
|
77 | + $this->assertNotEmpty($this->validator->getErrors()); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return array |
|
82 | - */ |
|
83 | - public function invalidValuesProvider() |
|
84 | - { |
|
85 | - return [ |
|
86 | - ['foo, bar baz, qux'], |
|
87 | - ['foo => bar baz, qux'], |
|
88 | - ]; |
|
89 | - } |
|
80 | + /** |
|
81 | + * @return array |
|
82 | + */ |
|
83 | + public function invalidValuesProvider() |
|
84 | + { |
|
85 | + return [ |
|
86 | + ['foo, bar baz, qux'], |
|
87 | + ['foo => bar baz, qux'], |
|
88 | + ]; |
|
89 | + } |
|
90 | 90 | } |