Skip to content
Permalink
Browse files

Re-enable year() tests.

Remove duplicate tests and tests that are no longer valid. Values of '',
and `false` will now select the empty option.
  • Loading branch information...
markstory committed Feb 23, 2014
1 parent 96560ea commit 71e23083015fd83f8ee90db43c6e7fe69cc7de6c
Showing with 20 additions and 124 deletions.
  1. +20 −124 tests/TestCase/View/Helper/FormHelperTest.php
@@ -5792,10 +5792,9 @@ public function testHour() {
* @return void
*/
public function testYear() {
$this->markTestIncomplete('Need to revisit once models work again.');
$result = $this->Form->year('Model.field', 2006, 2007);
$result = $this->Form->year('Model.field', ['minYear' => 2006, 'maxYear' => 2007]);
$expected = array(
array('select' => array('name' => 'Model[field][year]', 'id' => 'ModelFieldYear')),
array('select' => array('name' => 'Model[field][year]')),
array('option' => array('value' => '')),
'/option',
array('option' => array('value' => '2007')),
@@ -5808,71 +5807,33 @@ public function testYear() {
);
$this->assertTags($result, $expected);
$result = $this->Form->year('Model.field', 2006, 2007, array('orderYear' => 'asc'));
$expected = array(
array('select' => array('name' => 'Model[field][year]', 'id' => 'ModelFieldYear')),
array('option' => array('value' => '')),
'/option',
array('option' => array('value' => '2006')),
'2006',
'/option',
array('option' => array('value' => '2007')),
'2007',
'/option',
'/select',
);
$this->assertTags($result, $expected);
$this->request->data['Contact']['published'] = '';
$result = $this->Form->year('Contact.published', 2006, 2007, array('class' => 'year'));
$result = $this->Form->year('Model.field', [
'minYear' => 2006,
'maxYear' => 2007,
'orderYear' => 'asc'
]);
$expected = array(
array('select' => array('name' => 'Contact[published][year]', 'id' => 'ContactPublishedYear', 'class' => 'year')),
array('select' => array('name' => 'Model[field][year]')),
array('option' => array('value' => '')),
'/option',
array('option' => array('value' => '2007')),
'2007',
'/option',
array('option' => array('value' => '2006')),
'2006',
'/option',
'/select',
);
$this->assertTags($result, $expected);
$this->Form->request->data['Contact']['published'] = '2006-10-10';
$result = $this->Form->year('Contact.published', 2006, 2007, array('empty' => false));
$expected = array(
array('select' => array('name' => 'Contact[published][year]', 'id' => 'ContactPublishedYear')),
array('option' => array('value' => '2007')),
'2007',
'/option',
array('option' => array('value' => '2006', 'selected' => 'selected')),
'2006',
'/option',
'/select',
);
$this->assertTags($result, $expected);
$this->Form->request->data['Contact']['published'] = '';
$result = $this->Form->year('Contact.published', 2006, 2007, array('value' => false));
$expected = array(
array('select' => array('name' => 'Contact[published][year]', 'id' => 'ContactPublishedYear')),
array('option' => array('value' => '')),
'/option',
array('option' => array('value' => '2007')),
'2007',
'/option',
array('option' => array('value' => '2006')),
'2006',
'/option',
'/select',
);
$this->assertTags($result, $expected);
$this->Form->request->data['Contact']['published'] = '2006-10-10';
$result = $this->Form->year('Contact.published', 2006, 2007, array('empty' => false, 'value' => false));
$result = $this->Form->year('Contact.published', [
'empty' => false,
'maxYear' => 2006,
'minYear' => 2007,
]);
$expected = array(
array('select' => array('name' => 'Contact[published][year]', 'id' => 'ContactPublishedYear')),
array('select' => array('name' => 'Contact[published][year]')),
array('option' => array('value' => '2007')),
'2007',
'/option',
@@ -5884,9 +5845,13 @@ public function testYear() {
$this->assertTags($result, $expected);
$this->Form->request->data['Contact']['published'] = '';
$result = $this->Form->year('Contact.published', 2006, 2007, array('value' => 2007));
$result = $this->Form->year('Contact.published', [
'minYear' => 2006,
'maxYear' => 2007,
'value' => 2007
]);
$expected = array(
array('select' => array('name' => 'Contact[published][year]', 'id' => 'ContactPublishedYear')),
array('select' => array('name' => 'Contact[published][year]')),
array('option' => array('value' => '')),
'/option',
array('option' => array('value' => '2007', 'selected' => 'selected')),
@@ -5898,75 +5863,6 @@ public function testYear() {
'/select',
);
$this->assertTags($result, $expected);
$this->Form->request->data['Contact']['published'] = '2006-10-10';
$result = $this->Form->year('Contact.published', 2006, 2007, array('empty' => false, 'value' => 2007));
$expected = array(
array('select' => array('name' => 'Contact[published][year]', 'id' => 'ContactPublishedYear')),
array('option' => array('value' => '2007', 'selected' => 'selected')),
'2007',
'/option',
array('option' => array('value' => '2006')),
'2006',
'/option',
'/select',
);
$this->assertTags($result, $expected);
$this->Form->request->data['Contact']['published'] = '';
$result = $this->Form->year('Contact.published', 2006, 2008, array('empty' => false, 'value' => 2007));
$expected = array(
array('select' => array('name' => 'Contact[published][year]', 'id' => 'ContactPublishedYear')),
array('option' => array('value' => '2008')),
'2008',
'/option',
array('option' => array('value' => '2007', 'selected' => 'selected')),
'2007',
'/option',
array('option' => array('value' => '2006')),
'2006',
'/option',
'/select',
);
$this->assertTags($result, $expected);
$this->Form->request->data['Contact']['published'] = '2006-10-10';
$result = $this->Form->year('Contact.published', 2006, 2008, array('empty' => false));
$expected = array(
array('select' => array('name' => 'Contact[published][year]', 'id' => 'ContactPublishedYear')),
array('option' => array('value' => '2008')),
'2008',
'/option',
array('option' => array('value' => '2007')),
'2007',
'/option',
array('option' => array('value' => '2006', 'selected' => 'selected')),
'2006',
'/option',
'/select',
);
$this->assertTags($result, $expected);
$this->Form->request->data = array();
$this->Form->create('Contact');
$result = $this->Form->year('published', 2006, 2008, array('empty' => false));
$expected = array(
array('select' => array('name' => 'Contact[published][year]', 'id' => 'ContactPublishedYear')),
array('option' => array('value' => '2008')),
'2008',
'/option',
array('option' => array('value' => '2007')),
'2007',
'/option',
array('option' => array('value' => '2006')),
'2006',
'/option',
'/select',
);
$this->assertTags($result, $expected);
$result = $this->Form->year('published', array(), array(), array('empty' => false));
$this->assertContains('Contact[published][year]', $result);
}
/**

0 comments on commit 71e2308

Please sign in to comment.
You can’t perform that action at this time.