4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Form\Tests\Extension\Core\Type
;
14 class UrlTypeTest
extends TypeTestCase
16 public function testSubmitAddsDefaultProtocolIfNoneIsIncluded()
18 $form = $this->factory
->create('url', 'name');
20 $form->submit('www.domain.com');
22 $this->assertSame('http://www.domain.com', $form->getData());
23 $this->assertSame('http://www.domain.com', $form->getViewData());
26 public function testSubmitAddsNoDefaultProtocolIfAlreadyIncluded()
28 $form = $this->factory
->create('url', null, array(
29 'default_protocol' => 'http',
32 $form->submit('ftp://www.domain.com');
34 $this->assertSame('ftp://www.domain.com', $form->getData());
35 $this->assertSame('ftp://www.domain.com', $form->getViewData());
38 public function testSubmitAddsNoDefaultProtocolIfEmpty()
40 $form = $this->factory
->create('url', null, array(
41 'default_protocol' => 'http',
46 $this->assertNull($form->getData());
47 $this->assertSame('', $form->getViewData());
50 public function testSubmitAddsNoDefaultProtocolIfSetToNull()
52 $form = $this->factory
->create('url', null, array(
53 'default_protocol' => null,
56 $form->submit('www.domain.com');
58 $this->assertSame('www.domain.com', $form->getData());
59 $this->assertSame('www.domain.com', $form->getViewData());