This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Component/Form/UrlFieldTest.php

65 lines
1.8 KiB
PHP
Raw Normal View History

2010-10-19 14:20:55 +01:00
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
2010-10-19 14:20:55 +01:00
namespace Symfony\Tests\Component\Form;
require_once __DIR__ . '/LocalizedTestCase.php';
use Symfony\Component\Form\UrlField;
class UrlFieldTest extends LocalizedTestCase
{
public function testSubmitAddsDefaultProtocolIfNoneIsIncluded()
2010-10-19 14:20:55 +01:00
{
$field = new UrlField('name');
$field->submit('www.domain.com');
2010-10-19 14:20:55 +01:00
$this->assertSame('http://www.domain.com', $field->getData());
$this->assertSame('http://www.domain.com', $field->getDisplayedData());
}
public function testSubmitAddsNoDefaultProtocolIfAlreadyIncluded()
2010-10-19 14:20:55 +01:00
{
$field = new UrlField('name', array(
'default_protocol' => 'http',
));
$field->submit('ftp://www.domain.com');
2010-10-19 14:20:55 +01:00
$this->assertSame('ftp://www.domain.com', $field->getData());
$this->assertSame('ftp://www.domain.com', $field->getDisplayedData());
}
public function testSubmitAddsNoDefaultProtocolIfEmpty()
2010-10-19 14:20:55 +01:00
{
$field = new UrlField('name', array(
'default_protocol' => 'http',
));
$field->submit('');
2010-10-19 14:20:55 +01:00
$this->assertSame(null, $field->getData());
$this->assertSame('', $field->getDisplayedData());
}
public function testSubmitAddsNoDefaultProtocolIfSetToNull()
2010-10-19 14:20:55 +01:00
{
$field = new UrlField('name', array(
'default_protocol' => null,
));
$field->submit('www.domain.com');
2010-10-19 14:20:55 +01:00
$this->assertSame('www.domain.com', $field->getData());
$this->assertSame('www.domain.com', $field->getDisplayedData());
}
}