<commit_before><?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2013 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;

use PHPUnit_Framework_TestCase as TestCase;
use Zend\Form\Element;
use Zend\Form\Form;
use Zend\Form\Fieldset;
use Zend\InputFilter\InputFilter;

/**
 * @category   Zend
 * @package    Zend_Form
 * @subpackage UnitTest
 */
class FieldsetTest extends TestCase
{
    public function setUp()
    {
        $this->fieldset = new Fieldset();
    }

    public function populateFieldset()
    {
        $this->fieldset->add(new Element('foo'));
        $this->fieldset->add(new Element('bar'));
        $this->fieldset->add(new Element('baz'));

        $subFieldset = new Fieldset('foobar');
        $subFieldset->add(new Element('foo'));
        $subFieldset->add(new Element('bar'));
        $subFieldset->add(new Element('baz'));
        $this->fieldset->add($subFieldset);

        $subFieldset = new Fieldset('barbaz');
        $subFieldset->add(new Element('foo'));
        $subFieldset->add(new Element('bar'));
        $subFieldset->add(new Element('baz'));
        $this->fieldset->add($subFieldset);
    }

    public function getMessages()
    {
        return array(
            'foo' => array(
                'Foo message 1',
            ),
            'bar' => array(
                'Bar message 1',
                'Bar message 2',
            ),
            'baz' => array(
                'Baz message 1',
            ),
            'foobar' => array(
                'foo' => array(
                    'Foo message 1',
                ),
                'bar' => array(
                    'Bar message 1',
                    'Bar message 2',
                ),
                'baz' => array(
                    'Baz message 1',
                ),
            ),
            'barbaz' => array(
                'foo' => array(
                    'Foo message 1',
                ),
                'bar' => array(
                    'Bar message 1',
                    'Bar message 2',
                ),
                'baz' => array(
                    'Baz message 1',
                ),
            ),
        );
    }

    public function testExtractOnAnEmptyRelationship()
    {
        $form = new TestAsset\FormCollection();
        $form->populateValues(array('fieldsets' => array()));
    }

    public function testPopulateValuesWithInvalidElementRaisesException()
    {
        $this->setExpectedException('Zend\Form\Exception\InvalidArgumentException');
        $this->fieldset->populateValues(null);
    }

    public function testFieldsetIsEmptyByDefault()
    {
        $this->assertEquals(0, count($this->fieldset));
    }
<commit_msg>add test populateValues with traversable<commit_after><?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2013 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;

use PHPUnit_Framework_TestCase as TestCase;
use Zend\Form\Element;
use Zend\Form\Form;
use Zend\Form\Fieldset;
use Zend\InputFilter\InputFilter;

/**
 * @category   Zend
 * @package    Zend_Form
 * @subpackage UnitTest
 */
class FieldsetTest extends TestCase
{
    public function setUp()
    {
        $this->fieldset = new Fieldset();
    }

    public function populateFieldset()
    {
        $this->fieldset->add(new Element('foo'));
        $this->fieldset->add(new Element('bar'));
        $this->fieldset->add(new Element('baz'));

        $subFieldset = new Fieldset('foobar');
        $subFieldset->add(new Element('foo'));
        $subFieldset->add(new Element('bar'));
        $subFieldset->add(new Element('baz'));
        $this->fieldset->add($subFieldset);

        $subFieldset = new Fieldset('barbaz');
        $subFieldset->add(new Element('foo'));
        $subFieldset->add(new Element('bar'));
        $subFieldset->add(new Element('baz'));
        $this->fieldset->add($subFieldset);
    }

    public function getMessages()
    {
        return array(
            'foo' => array(
                'Foo message 1',
            ),
            'bar' => array(
                'Bar message 1',
                'Bar message 2',
            ),
            'baz' => array(
                'Baz message 1',
            ),
            'foobar' => array(
                'foo' => array(
                    'Foo message 1',
                ),
                'bar' => array(
                    'Bar message 1',
                    'Bar message 2',
                ),
                'baz' => array(
                    'Baz message 1',
                ),
            ),
            'barbaz' => array(
                'foo' => array(
                    'Foo message 1',
                ),
                'bar' => array(
                    'Bar message 1',
                    'Bar message 2',
                ),
                'baz' => array(
                    'Baz message 1',
                ),
            ),
        );
    }

    public function testExtractOnAnEmptyRelationship()
    {
        $form = new TestAsset\FormCollection();
        $form->populateValues(array('fieldsets' => array()));
    }

    public function testExtractOnAnEmptyTraversable()
    {
        $form = new TestAsset\FormCollection();
        $form->populateValues(new \ArrayObject(array('fieldsets' => new \ArrayObject())));
    }

    public function testPopulateValuesWithInvalidElementRaisesException()
    {
        $this->setExpectedException('Zend\Form\Exception\InvalidArgumentException');
        $this->fieldset->populateValues(null);
    }

    public function testFieldsetIsEmptyByDefault()
    {
        $this->assertEquals(0, count($this->fieldset));
    }

{'fraction_non_alphanumeric': 0.13696396543290396, 'fraction_numerical': 0.0071743029512473504, 'mean_word_length': 1.735950044603033, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 75, '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': '5486055', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1656, 'n_words': 348}