Skip to content

Instantly share code, notes, and snippets.

@jbclements
Created April 13, 2012 23:02
Show Gist options
  • Save jbclements/2380694 to your computer and use it in GitHub Desktop.
Save jbclements/2380694 to your computer and use it in GitHub Desktop.
Excerpt from symfony /tmp/symfony/src/Symfony/Component/Form/Tests/Extension/Core/Type/...
<?php
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
use Symfony\Component\Form\FormError;
class DateTimeTypeTest extends LocalizedTestCase
{
public function testSubmit_dateTime()
{
$form = $this->factory->create('datetime', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'date_widget' => 'choice',
'time_widget' => 'choice',
'input' => 'datetime',
));
$form->bind(array(
'date' => array(
'day' => '2',
'month' => '6',
'year' => '2010',
),
'time' => array(
'hour' => '3',
'minute' => '4',
),
));
$dateTime = new \DateTime('2010-06-02 03:04:00 UTC');
$this->assertDateTimeEquals($dateTime, $form->getData());
}
public function testSubmit_string()
{
$form = $this->factory->create('datetime', null, array(
'data_timezone' => 'UTC',
'user_timezone' => 'UTC',
'input' => 'string',
'date_widget' => 'choice',
'time_widget' => 'choice',
));
$form->bind(array(
'date' => array(
'day' => '2',
'month' => '6',
'year' => '2010',
),
'time' => array(
'hour' => '3',
'minute' => '4',
),
));
$this->assertEquals('2010-06-02 03:04:00', $form->getData());
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment