File tree Expand file tree Collapse file tree 2 files changed +27
-6
lines changed
tests/TestCase/View/Widget Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Original file line number Diff line number Diff line change 33
44namespace ADmad \I18n \View \Widget ;
55
6+ use Cake \View \Form \ContextInterface ;
67use Cake \View \Widget \SelectBoxWidget ;
78use DateTimeZone ;
89
1213class TimezoneWidget extends SelectBoxWidget
1314{
1415 /**
15- * Render the contents of the select element.
16+ * {@inheritDoc}
17+ *
18+ * ### Options format
1619 *
1720 * `$data['options']` is expected to be associative array of regions for which
1821 * you want identifiers list. The key will be used as optgroup.
1922 * Eg. `['Asia' => DateTimeZone::ASIA, 'Europe' => DateTimeZone::EUROPE]`
2023 *
21- * @param array $data The context for rendering a select.
22- * @return array
24+ * @param array $data Data to render with.
25+ * @param \Cake\View\Form\ContextInterface $context The current form context.
26+ * @return string A generated select box.
27+ * @throws \RuntimeException when the name attribute is empty.
2328 */
24- protected function _renderContent (array $ data ): array
29+ public function render (array $ data, ContextInterface $ context ): string
2530 {
26- $ data ['options ' ] = $ this ->_identifierList ($ data ['options ' ]);
31+ $ data ['options ' ] = $ this ->_identifierList ($ data ['options ' ] ?? [] );
2732
28- return parent ::_renderContent ($ data );
33+ return parent ::render ($ data, $ context );
2934 }
3035
3136 /**
Original file line number Diff line number Diff line change @@ -74,4 +74,20 @@ public function testRender()
7474 ];
7575 $ this ->assertHtml ($ expected , $ result );
7676 }
77+
78+ /**
79+ * @see https://github.com/ADmad/cakephp-i18n/pull/52
80+ * @doesNotPerformAssertions
81+ * @return void
82+ */
83+ public function testRenderOptionsNull ()
84+ {
85+ $ data = [
86+ 'name ' => 'timezone ' ,
87+ 'options ' => null ,
88+ ];
89+
90+ $ select = new TimezoneWidget ($ this ->templates );
91+ $ select ->render ($ data , $ this ->context );
92+ }
7793}
You can’t perform that action at this time.
0 commit comments