[Form] removed some incomplete unit tests, added some new ones

This commit is contained in:
Fabien Potencier 2011-11-02 07:19:01 +01:00
parent a554541cb4
commit af6f0d5548
2 changed files with 15 additions and 287 deletions

View File

@ -317,210 +317,37 @@ class DateTypeTest extends LocalizedTestCase
$this->assertEquals('01.06.2010', $form->getClientData());
}
public function testIsYearWithinRangeReturnsTrueIfWithin()
public function testYearsOption()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('date', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'widget' => 'single_text',
'years' => array(2010, 2011),
));
$form->bind('2.6.2010');
$view = $form->createView();
$this->assertTrue($form->isYearWithinRange());
$this->assertSame(array(2010 => '2010', 2011 => '2011'), $view->getChild('year')->get('choices'));
}
public function testIsYearWithinRangeReturnsTrueIfEmpty()
public function testMonthsOption()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('date', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'widget' => 'single_text',
'years' => array(2010, 2011),
));
$form->bind('');
$this->assertTrue($form->isYearWithinRange());
}
public function testIsYearWithinRangeReturnsTrueIfEmptyChoice()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('date', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'widget' => 'choice',
'years' => array(2010, 2011),
));
$form->bind(array(
'day' => '1',
'month' => '2',
'year' => '',
));
$this->assertTrue($form->isYearWithinRange());
}
public function testIsYearWithinRangeReturnsFalseIfNotContained()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('date', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'widget' => 'single_text',
'years' => array(2010, 2012),
));
$form->bind('2.6.2011');
$this->assertFalse($form->isYearWithinRange());
}
public function testIsMonthWithinRangeReturnsTrueIfWithin()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('date', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'widget' => 'single_text',
'months' => array(6, 7),
));
$form->bind('2.6.2010');
$view = $form->createView();
$this->assertTrue($form->isMonthWithinRange());
}
public function testIsMonthWithinRangeReturnsTrueIfEmpty()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('date', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'widget' => 'single_text',
'months' => array(6, 7),
));
$form->bind('');
$this->assertTrue($form->isMonthWithinRange());
}
public function testIsMonthWithinRangeReturnsTrueIfEmptyChoice()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('date', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'widget' => 'choice',
'months' => array(6, 7),
));
$form->bind(array(
'day' => '1',
'month' => '',
'year' => '2011',
));
$this->assertTrue($form->isMonthWithinRange());
}
public function testIsMonthWithinRangeReturnsFalseIfNotContained()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('date', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'widget' => 'single_text',
'months' => array(6, 8),
));
$form->bind('2.7.2010');
$this->assertFalse($form->isMonthWithinRange());
$this->assertSame(array(6 => '06', 7 => '07'), $view->getChild('month')->get('choices'));
}
public function testIsDayWithinRangeReturnsTrueIfWithin()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('date', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'widget' => 'single_text',
'days' => array(6, 7),
));
$form->bind('6.6.2010');
$view = $form->createView();
$this->assertTrue($form->isDayWithinRange());
}
public function testIsDayWithinRangeReturnsTrueIfEmpty()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('date', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'widget' => 'single_text',
'days' => array(6, 7),
));
$form->bind('');
$this->assertTrue($form->isDayWithinRange());
}
public function testIsDayWithinRangeReturnsTrueIfEmptyChoice()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('date', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'widget' => 'choice',
'days' => array(6, 7),
));
$form->bind(array(
'day' => '',
'month' => '1',
'year' => '2011',
));
$this->assertTrue($form->isDayWithinRange());
}
public function testIsDayWithinRangeReturnsFalseIfNotContained()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('date', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'widget' => 'single_text',
'days' => array(6, 8),
));
$form->bind('7.6.2010');
$this->assertFalse($form->isDayWithinRange());
$this->assertSame(array(6 => '06', 7 => '07'), $view->getChild('day')->get('choices'));
}
public function testIsPartiallyFilledReturnsFalseIfSingleText()

View File

@ -235,137 +235,38 @@ class TimeTypeTest extends LocalizedTestCase
$this->assertEquals($displayedData, $form->getClientData());
}
public function testIsHourWithinRange_returnsTrueIfWithin()
public function testHoursOption()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('time', null, array(
'hours' => array(6, 7),
));
$form->bind(array('hour' => '06', 'minute' => '12'));
$view = $form->createView();
$this->assertTrue($form->isHourWithinRange());
}
public function testIsHourWithinRange_returnsTrueIfEmpty()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('time', null, array(
'hours' => array(6, 7),
));
$form->bind(array('hour' => '', 'minute' => '06'));
$this->assertTrue($form->isHourWithinRange());
}
public function testIsHourWithinRange_returnsFalseIfNotContained()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('time', null, array(
'hours' => array(6, 7),
));
$form->bind(array('hour' => '08', 'minute' => '12'));
$this->assertFalse($form->isHourWithinRange());
$this->assertSame(array(6 => '06', 7 => '07'), $view->getChild('hour')->get('choices'));
}
public function testIsMinuteWithinRange_returnsTrueIfWithin()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('time', null, array(
'minutes' => array(6, 7),
));
$form->bind(array('hour' => '06', 'minute' => '06'));
$view = $form->createView();
$this->assertTrue($form->isMinuteWithinRange());
}
public function testIsMinuteWithinRange_returnsTrueIfEmpty()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('time', null, array(
'minutes' => array(6, 7),
));
$form->bind(array('hour' => '06', 'minute' => ''));
$this->assertTrue($form->isMinuteWithinRange());
}
public function testIsMinuteWithinRange_returnsFalseIfNotContained()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('time', null, array(
'minutes' => array(6, 7),
));
$form->bind(array('hour' => '06', 'minute' => '08'));
$this->assertFalse($form->isMinuteWithinRange());
$this->assertSame(array(6 => '06', 7 => '07'), $view->getChild('minute')->get('choices'));
}
public function testIsSecondWithinRange_returnsTrueIfWithin()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('time', null, array(
'seconds' => array(6, 7),
'with_seconds' => true,
));
$form->bind(array('hour' => '04', 'minute' => '05', 'second' => '06'));
$view = $form->createView();
$this->assertTrue($form->isSecondWithinRange());
}
public function testIsSecondWithinRange_returnsTrueIfEmpty()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('time', null, array(
'seconds' => array(6, 7),
'with_seconds' => true,
));
$form->bind(array('hour' => '06', 'minute' => '06', 'second' => ''));
$this->assertTrue($form->isSecondWithinRange());
}
public function testIsSecondWithinRange_returnsTrueIfNotWithSeconds()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('time', null, array(
'seconds' => array(6, 7),
));
$form->bind(array('hour' => '06', 'minute' => '06'));
$this->assertTrue($form->isSecondWithinRange());
}
public function testIsSecondWithinRange_returnsFalseIfNotContained()
{
$this->markTestIncomplete('Needs to be reimplemented using validators');
$form = $this->factory->create('time', null, array(
'seconds' => array(6, 7),
'with_seconds' => true,
));
$form->bind(array('hour' => '04', 'minute' => '05', 'second' => '08'));
$this->assertFalse($form->isSecondWithinRange());
$this->assertSame(array(6 => '06', 7 => '07'), $view->getChild('second')->get('choices'));
}
public function testIsPartiallyFilled_returnsFalseIfCompletelyEmpty()