<commit_before><commit_msg>Adding in unit tests for PPI_Form_Tag_Password and PPI_Form->password()<commit_after><?php
class PPI_Test_PasswordTagTest extends PHPUnit_Framework_TestCase {

	function setUp() {
		$this->_form = new PPI_Form();
	}

	function tearDown() {
		unset($this->_form);
	}

	function testCreate() {
		$output = $this->_form->password('<PASSWORD>');
		$this->assertEquals($output, '<input type="password" name="mypass">');
	}

	function testCreateWithAttrs() {
		$output = $this->_form->password('<PASSWORD>', array('id' => 'bar'));
		$this->assertEquals($output, '<input type="password" name="mypass" id="bar">');
	}

	function testDirectClass() {
		$pass = new PPI_Form_Tag_Password(array(
			'value' => 'foo_pass',
			'name'  => 'mypass',
			'id'    => 'bar'
		));
		$output = $pass->render();
		$this->assertEquals($output, '<input type="password" value="foo_pass" name="mypass" id="bar">');
	}

	function testHasAttr() {
		$pass = new PPI_Form_Tag_Password(array(
			'value' => 'foo_pass',
			'name'  => 'mypass',
			'id'    => 'bar'
		));
		$this->assertTrue($pass->hasAttr('name'));
		$this->assertFalse($pass->hasAttr('nonexistantattr'));
	}

	function testGetAttr() {
		$pass = new PPI_Form_Tag_Password(array(
			'value' => 'foo_pass',
			'name'  => 'mypass',
			'id'    => 'bar'
		));
		$this->assertEquals('foo_pass', $pass->attr('value'));
	}

	function testSetAttr() {
		$pass = new PPI_Form_Tag_Password(array(
			'value' => 'foo_pass'
		));
		$pass->attr('foo', 'bar');
		$this->assertEquals('bar', $pass->attr('foo'));
	}

}
{'fraction_non_alphanumeric': 0.21153846153846154, 'fraction_numerical': 0.0, 'mean_word_length': 4.890566037735849, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 39, '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': '4305859', 'n_tokens_mistral': 614, 'n_tokens_neox': 552, 'n_words': 95}