<commit_before><?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 * @package   Zend_Form
 */

namespace ZendTest\Form\View\Helper;

use PHPUnit_Framework_TestCase as TestCase;
use Zend\Captcha;
use Zend\Form\Element;
use Zend\Form\View\HelperConfiguration;
use Zend\Form\View\Helper\FormElement as FormElementHelper;
use Zend\View\Helper\Doctype;
use Zend\View\Renderer\PhpRenderer;

/**
 * @category   Zend
 * @package    Zend_Form
 * @subpackage UnitTest
 */
class FormElementTest extends TestCase
{
    public $helper;
    public $renderer;

    public function setUp()
    {
        $this->helper = new FormElementHelper();

        Doctype::unsetDoctypeRegistry();

        $this->renderer = new PhpRenderer;
        $helpers = $this->renderer->getHelperPluginManager();
        $config  = new HelperConfiguration();
        $config->configureServiceManager($helpers);

        $this->helper->setView($this->renderer);
    }

    public function getInputElements()
    {
        return array(
            array('text'),
            array('password'),
            array('checkbox'),
            array('radio'),
            array('submit'),
            array('reset'),
            array('file'),
            array('hidden'),
            array('image'),
            array('button'),
            array('number'),
            array('range'),
            array('date'),
            array('color'),
            array('search'),
            array('tel'),
            array('email'),
            array('url'),
            array('datetime'),
            array('datetime-local'),
            array('month'),
            array('week'),
            array('time'),
        );
    }

    /**
     * @dataProvider getInputElements
     */
    public function testRendersExpectedInputElement($type)
    {
        if ($type === 'radio') {
            $element = new Element\Radio('foo');
        } else {
            $element = new Element('foo');
        }

        $element->setAttribute('type', $type);
        $element->setAttribute('options', array('option' => 'value'));
        $markup  = $this->helper->render($element);

        $this->assertContains('<input', $markup);
        $this->assertContains('type="' . $type . '"', $markup);
    }

    public function getMultiElements()
    {
        return array(
            array('radio', 'input', 'type="radio"'),
            array('multi_checkbox', 'input', 'type="checkbox"'),
            array('select', 'option', '<select'),
        );
    }
<commit_msg>Fix FormElementTest for FormImage<commit_after><?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 * @package   Zend_Form
 */

namespace ZendTest\Form\View\Helper;

use PHPUnit_Framework_TestCase as TestCase;
use Zend\Captcha;
use Zend\Form\Element;
use Zend\Form\View\HelperConfiguration;
use Zend\Form\View\Helper\FormElement as FormElementHelper;
use Zend\View\Helper\Doctype;
use Zend\View\Renderer\PhpRenderer;

/**
 * @category   Zend
 * @package    Zend_Form
 * @subpackage UnitTest
 */
class FormElementTest extends TestCase
{
    public $helper;
    public $renderer;

    public function setUp()
    {
        $this->helper = new FormElementHelper();

        Doctype::unsetDoctypeRegistry();

        $this->renderer = new PhpRenderer;
        $helpers = $this->renderer->getHelperPluginManager();
        $config  = new HelperConfiguration();
        $config->configureServiceManager($helpers);

        $this->helper->setView($this->renderer);
    }

    public function getInputElements()
    {
        return array(
            array('text'),
            array('password'),
            array('checkbox'),
            array('radio'),
            array('submit'),
            array('reset'),
            array('file'),
            array('hidden'),
            array('image'),
            array('button'),
            array('number'),
            array('range'),
            array('date'),
            array('color'),
            array('search'),
            array('tel'),
            array('email'),
            array('url'),
            array('datetime'),
            array('datetime-local'),
            array('month'),
            array('week'),
            array('time'),
        );
    }

    /**
     * @dataProvider getInputElements
     */
    public function testRendersExpectedInputElement($type)
    {
        if ($type === 'radio') {
            $element = new Element\Radio('foo');
        } else {
            $element = new Element('foo');
        }

        $element->setAttribute('type', $type);
        $element->setAttribute('options', array('option' => 'value'));
        $element->setAttribute('src', 'http://zend.com/img.png');
        $markup  = $this->helper->render($element);

        $this->assertContains('<input', $markup);
        $this->assertContains('type="' . $type . '"', $markup);
    }

    public function getMultiElements()
    {
        return array(
            array('radio', 'input', 'type="radio"'),
            array('multi_checkbox', 'input', 'type="checkbox"'),
            array('select', 'option', '<select'),
        );
    }

{'fraction_non_alphanumeric': 0.15517857142857142, 'fraction_numerical': 0.0032142857142857142, 'mean_word_length': 2.245075318655852, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2972465', 'n_tokens_mistral': 1556, 'n_tokens_neox': 1508, 'n_words': 299}