* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Tests\Extension\Core\Type; class UrlTypeTest extends TextTypeTest { const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\UrlType'; public function testSubmitAddsDefaultProtocolIfNoneIsIncluded() { $form = $this->factory->create(static::TESTED_TYPE, 'name'); $form->submit('www.domain.com'); $this->assertSame('http://www.domain.com', $form->getData()); $this->assertSame('http://www.domain.com', $form->getViewData()); } public function testSubmitAddsNoDefaultProtocolIfAlreadyIncluded() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'default_protocol' => 'http', )); $form->submit('ftp://www.domain.com'); $this->assertSame('ftp://www.domain.com', $form->getData()); $this->assertSame('ftp://www.domain.com', $form->getViewData()); } public function testSubmitAddsNoDefaultProtocolIfEmpty() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'default_protocol' => 'http', )); $form->submit(''); $this->assertNull($form->getData()); $this->assertSame('', $form->getViewData()); } public function testSubmitAddsNoDefaultProtocolIfNull() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'default_protocol' => 'http', )); $form->submit(null); $this->assertNull($form->getData()); $this->assertSame('', $form->getViewData()); } public function testSubmitAddsNoDefaultProtocolIfSetToNull() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'default_protocol' => null, )); $form->submit('www.domain.com'); $this->assertSame('www.domain.com', $form->getData()); $this->assertSame('www.domain.com', $form->getViewData()); } /** * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function testThrowExceptionIfDefaultProtocolIsInvalid() { $this->factory->create(static::TESTED_TYPE, null, array( 'default_protocol' => array(), )); } public function testSubmitWithNonStringDataDoesNotBreakTheFixUrlProtocolListener() { $form = $this->factory->create(static::TESTED_TYPE); $form->submit(array('domain.com', 'www.domain.com')); $this->assertSame(array('domain.com', 'www.domain.com'), $form->getData()); } } __halt_compiler();----SIGNATURE:----WMzYzb/f/wzioayuICw1RNNCzGjKrxR83zhuKWP/XT6+DvbVZwQmTslNSjtRLHWSXrcB3xr0bRAr0C+UNCGj9+TV5gFaaKZzMjM1F1/51cdrBcnSma0UcnHgcXDwD9cUda7MCSA5uombQWKNMl7Cal6HLt8PlLDMRTeMhcsxyVtNmGU2HBc1wxY1rYl41me0VkQ7rzbw/47gwXD8Z5XMyKZ8Cop1Ik+V9XLiwCJ2AtvBPlyKjEu5Olvoqyp+NavuO77QDBXsFUTXml5wun2eJBmLa5IEpCwyMEsqLlJ8/vT2XOlQweKFS9ywOlEiE2C2CFtMby4kKTLj8KM8pU0w9PXuFglsHyfIW5WCIsKfPJYmZT9udFQ3wU3S6Uhcn/QL7NvhDVg3vdrWaFq2VIk63ih+B/YKpZPDp8CCyegXueOyJ88nqSQcCNDSm5o4yb1YzFoBAcG0FRtRgWuQPqwRaQOE4V06acuSI4yjn09zZyLV5OZdZ7O6c8LpXadi01Uib5ElY/CkC6Hi6SfzZS3T5FV6+qZ7WxjH5dEatzWvuHYjw7HJGd/gh6JLGVWvctrY2H96sllMdrpIthEYYsIb+nubtAW1cKSzN9aqFkUgPPJAvG5FkHP3Ddr7DZAOtqhn21ljSMXod1Vzvf8XAY3jEf4g/WN976++G5s/tA75a0E=----ATTACHMENT:----ODI2ODI2NzQ0MDU5NDU1NCAyNTI0ODI5NTc2NjEyNjMxIDE1NjE1MDU0MDUxMDE0OTA=