Permalink
Browse files

Implement remaining tests for InputRegistry.

  • Loading branch information...
markstory committed Jan 18, 2014
1 parent 08920aa commit 64a932da51a25f394190e9ce6c69763e496e9c1b
Showing with 36 additions and 4 deletions.
  1. +36 −4 tests/TestCase/View/Input/InputRegistryTest.php
@@ -33,13 +33,31 @@ public function setUp() {
$this->templates = new StringTemplate();
}
+/**
+ * Test adding new widgets.
+ *
+ * @return void
+ */
+ public function testAddInConstructor() {
+ $widgets = [
+ 'text' => ['Cake\View\Input\Text'],
+ ];
+ $inputs = new InputRegistry($this->templates, $widgets);
+ $result = $inputs->get('text');
+ $this->assertInstanceOf('Cake\View\Input\Text', $result);
+ }
+
/**
* Test adding new widgets.
*
* @return void
*/
public function testAdd() {
- $this->markTestIncomplete();
+ $inputs = new InputRegistry($this->templates);
+ $result = $inputs->add([
+ 'text' => ['Cake\View\Input\Text'],
+ ]);
+ $this->assertNull($result);
}
/**
@@ -48,7 +66,13 @@ public function testAdd() {
* @return void
*/
public function testGet() {
- $this->markTestIncomplete();
+ $inputs = new InputRegistry($this->templates);
+ $inputs->add([
+ 'text' => ['Cake\View\Input\Text'],
+ ]);
+ $result = $inputs->get('text');
+ $this->assertInstanceOf('Cake\View\Input\Text', $result);
+ $this->assertSame($result, $inputs->get('text'));
}
/**
@@ -57,7 +81,15 @@ public function testGet() {
* @return void
*/
public function testGetFallback() {
- $this->markTestIncomplete();
+ $inputs = new InputRegistry($this->templates);
+ $inputs->add([
+ '_default' => ['Cake\View\Input\Text'],
+ ]);
+ $result = $inputs->get('text');
+ $this->assertInstanceOf('Cake\View\Input\Text', $result);
+
+ $result2 = $inputs->get('hidden');
+ $this->assertSame($result, $result2);
}
/**
@@ -84,7 +116,7 @@ public function testGetResolveDependency() {
'multicheckbox' => ['Cake\View\Input\MultiCheckbox', 'label']
]);
$result = $inputs->get('multicheckbox');
- $this->assertInstanceOf('CakeView\Input\MultiCheckbox', $result);
+ $this->assertInstanceOf('Cake\View\Input\MultiCheckbox', $result);
}
/**

0 comments on commit 64a932d

Please sign in to comment.