]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php
twig implementation
[github/wallabag/wallabag.git] / vendor / symfony / form / Symfony / Component / Form / Tests / Extension / Core / Type / UrlTypeTest.php
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14 class UrlTypeTest extends TypeTestCase
15 {
16 public function testSubmitAddsDefaultProtocolIfNoneIsIncluded()
17 {
18 $form = $this->factory->create('url', 'name');
19
20 $form->submit('www.domain.com');
21
22 $this->assertSame('http://www.domain.com', $form->getData());
23 $this->assertSame('http://www.domain.com', $form->getViewData());
24 }
25
26 public function testSubmitAddsNoDefaultProtocolIfAlreadyIncluded()
27 {
28 $form = $this->factory->create('url', null, array(
29 'default_protocol' => 'http',
30 ));
31
32 $form->submit('ftp://www.domain.com');
33
34 $this->assertSame('ftp://www.domain.com', $form->getData());
35 $this->assertSame('ftp://www.domain.com', $form->getViewData());
36 }
37
38 public function testSubmitAddsNoDefaultProtocolIfEmpty()
39 {
40 $form = $this->factory->create('url', null, array(
41 'default_protocol' => 'http',
42 ));
43
44 $form->submit('');
45
46 $this->assertNull($form->getData());
47 $this->assertSame('', $form->getViewData());
48 }
49
50 public function testSubmitAddsNoDefaultProtocolIfSetToNull()
51 {
52 $form = $this->factory->create('url', null, array(
53 'default_protocol' => null,
54 ));
55
56 $form->submit('www.domain.com');
57
58 $this->assertSame('www.domain.com', $form->getData());
59 $this->assertSame('www.domain.com', $form->getViewData());
60 }
61 }