<commit_before><?php
use Vision\Html\Element;

class ElementTest extends \PHPUnit_Framework_TestCase
{
    public function testConstructWithValidArgument()
    {
        $element = new Element('h1');
        $this->assertInstanceOf('\Vision\Html\Element', $element);
    }

    public function testContructWhenArgumentIsNoString()
    {
        $this->setExpectedException('InvalidArgumentException');
        $element = new Element(1);
    }

    public function testContructWhenArgumentHasForbiddenCharacters()
    {
        $this->setExpectedException('InvalidArgumentException');
        $element = new Element('h1?');
    }

    public function testGetTag()
    {
        $element = new Element('div');
        $this->assertSame('div', $element->getTag());
    }

    public function testVoidElement()
    {
        $element = new Element('area');
        $this->assertTrue($element->isVoid());
    }

    public function testNonVoidElement()
    {
        $element = new Element('div');
        $this->assertFalse($element->isVoid());
    }

    public function testSetAndGetAttributeWithOneArgument()
    {
        $element = new Element('div');

        $this->assertSame(null, $element->getAttribute('required'));
        $this->assertSame($element, $element->setAttribute('required'));
        $this->assertSame(true, $element->getAttribute('required'));
    }

    public function testSetAndGetAttributeWithTwoArguments()
    {
        $element = new Element('div');

        $this->assertSame(null, $element->getAttribute('id'));
        $this->assertSame($element, $element->setAttribute('id', 'foo'));
        $this->assertSame('foo', $element->getAttribute('id'));
    }

    public function testSetAndGetAttributes()
    {
        $attr = array(
            'required',
            'id' => 'foo'
        );

        $element = new Element('div');

        $this->assertSame(array(), $element->getAttributes());
        $this->assertSame($element, $element->setAttributes($attr));
        $this->assertSame($attr, $element->getAttributes());
    }

    public function testRemoveAttribute()
    {
        $element = new Element('div');

        $this->assertFalse($element->removeAttribute('id'));

        $element->setAttribute('id', 'foo');

        $this->assertSame('foo', $element->getAttribute('id'));
        $this->assertTrue($element->removeAttribute('id'));
        $this->assertSame(null, $element->getAttribute('id'));
    }

    public function testAddAndGetContents()
    {
        $element = new Element('div');

        $this->assertSame(array(), $element->getContents());
        $this->assertSame($element, $element->addContent('Hello World'));
        $this->assertSame(array('Hello World'), $element->getContents());<commit_msg>Fix: neccessary value for empty attributes<commit_after><?php
use Vision\Html\Element;

class ElementTest extends \PHPUnit_Framework_TestCase
{
    public function testConstructWithValidArgument()
    {
        $element = new Element('h1');
        $this->assertInstanceOf('\Vision\Html\Element', $element);
    }

    public function testContructWhenArgumentIsNoString()
    {
        $this->setExpectedException('InvalidArgumentException');
        $element = new Element(1);
    }

    public function testContructWhenArgumentHasForbiddenCharacters()
    {
        $this->setExpectedException('InvalidArgumentException');
        $element = new Element('h1?');
    }

    public function testGetTag()
    {
        $element = new Element('div');
        $this->assertSame('div', $element->getTag());
    }

    public function testVoidElement()
    {
        $element = new Element('area');
        $this->assertTrue($element->isVoid());
    }

    public function testNonVoidElement()
    {
        $element = new Element('div');
        $this->assertFalse($element->isVoid());
    }

    public function testSetAndGetAttributeWithOneArgument()
    {
        $element = new Element('div');

        $this->assertSame(null, $element->getAttribute('required'));
        $this->assertSame($element, $element->setAttribute('required'));
        $this->assertSame(true, $element->getAttribute('required'));
    }

    public function testSetAndGetAttributeWithTwoArguments()
    {
        $element = new Element('div');

        $this->assertSame(null, $element->getAttribute('id'));
        $this->assertSame($element, $element->setAttribute('id', 'foo'));
        $this->assertSame('foo', $element->getAttribute('id'));
    }

    public function testSetAndGetAttributes()
    {
        $attr = array(
            'required' => true,
            'id' => 'foo'
        );

        $element = new Element('div');

        $this->assertSame(array(), $element->getAttributes());
        $this->assertSame($element, $element->setAttributes($attr));
        $this->assertSame($attr, $element->getAttributes());
    }

    public function testRemoveAttribute()
    {
        $element = new Element('div');

        $this->assertFalse($element->removeAttribute('id'));

        $element->setAttribute('id', 'foo');

        $this->assertSame('foo', $element->getAttribute('id'));
        $this->assertTrue($element->removeAttribute('id'));
        $this->assertSame(null, $element->getAttribute('id'));
    }

    public function testAddAndGetContents()
    {
        $element = new Element('div');

        $this->assertSame(array(), $element->getContents());
        $this->assertSame($element, $element->addContent('Hello World'));
        $this->assertSame(array('Hello World'), $element->getContents());
{'fraction_non_alphanumeric': 0.16298292902066486, 'fraction_numerical': 0.001078167115902965, 'mean_word_length': 3.1724137931034484, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 90, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5600125', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1481, 'n_words': 247}