Permalink
Browse files

Wire up the existing widgets to the registry.

Preconfigure the registry so other classes have less work to do.
Update tests to clear pre-baked configuration.
  • Loading branch information...
markstory committed Jan 18, 2014
1 parent 64a932d commit e7ff0e4f051104833cd5a588117483916496cf64
Showing with 20 additions and 1 deletion.
  1. +17 −1 src/View/Input/InputRegistry.php
  2. +3 −0 tests/TestCase/View/Input/InputRegistryTest.php
@@ -39,7 +39,14 @@ class InputRegistry {
*
* @var array
*/
- protected $_widgets = [];
+ protected $_widgets = [
+ 'checkbox' => ['Cake\View\Input\Checkbox'],
+ 'label' => ['Cake\View\Input\Label'],
+ 'multicheckbox' => ['Cake\View\Input\MultiCheckbox', 'label'],
+ 'radio' => ['Cake\View\Input\Radio', 'label'],
+ 'select' => ['Cake\View\Input\SelectBox'],
+ '_default' => ['Cake\View\Input\Text'],
+ ];
/**
* Templates to use.
@@ -107,6 +114,15 @@ public function get($name) {
return $this->_widgets[$name];
}
+/**
+ * Clear the registry and reset the widgets.
+ *
+ * @return void
+ */
+ public function clear() {
+ $this->_widgets = [];
+ }
+
/**
* Resolves a widget spec into an instance.
*
@@ -101,6 +101,7 @@ public function testGetFallback() {
*/
public function testGetNoFallbackError() {
$inputs = new InputRegistry($this->templates);
+ $inputs->clear();
$inputs->get('foo');
}
@@ -111,6 +112,7 @@ public function testGetNoFallbackError() {
*/
public function testGetResolveDependency() {
$inputs = new InputRegistry($this->templates);
+ $inputs->clear();
$inputs->add([
'label' => ['Cake\View\Input\Label'],
'multicheckbox' => ['Cake\View\Input\MultiCheckbox', 'label']
@@ -141,6 +143,7 @@ public function testGetResolveDependencyMissingClass() {
*/
public function testGetResolveDependencyMissingDependency() {
$inputs = new InputRegistry($this->templates);
+ $inputs->clear();
$inputs->add(['multicheckbox' => ['Cake\View\Input\MultiCheckbox', 'label']]);
$inputs->get('multicheckbox');
}

0 comments on commit e7ff0e4

Please sign in to comment.