Skip to content

Commit

Permalink
Implement remaining tests for InputRegistry.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 18, 2014
1 parent 08920aa commit 64a932d
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions tests/TestCase/View/Input/InputRegistryTest.php
Expand Up @@ -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);
}

/**
Expand All @@ -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'));
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit 64a932d

Please sign in to comment.