<commit_before><?php

require_once 'Turing/TuringSeleniumTest.php';


/**
 * Test contact us form
 *
 * @package   Site
 * @copyright 2012 silverorange
 * @license   http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
 */
abstract class SiteContactUsTest extends TuringSeleniumTest
{
	// {{{ abstract protected function getPageUri()

	abstract protected function getPageUri();

	// }}}
	// {{{ abstract protected function getSubjectCount()

	abstract protected function getSubjectCount();

	// }}}
	// {{{ public function testPageLoad()

	public function testPageLoad()
	{
		$this->open($this->getPageUri());

		$this->assertNoErrors();

		$this->assertTrue(
			$this->isTextPresent('Send us a Message'),
			'Contact form title is missing.'
		);
	}

	// }}}
	// {{{ public function testSubjectList()

	public function testSubjectList()
	{
		$this->open($this->getPageUri());

		$options = $this->getSelectOptions('id=subject');

		$this->assertEquals(
			$this->getSubjectCount(),
			count($options),
			'Number of contact subjects is incorrect.'
		);
	}

	// }}}
	// {{{ public function testEmptyForm()

	public function testEmptyForm()
	{
		$this->open($this->getPageUri());

		$this->click("xpath=//input[@type='submit' and @value='Send Message']");
		$this->waitForPageToLoad(30000);

		$this->assertNoErrors();

		$this->assertTrue(
			$this->isTextPresent('The Your Email field is required.'),
			'Email address required message not present.'
		);

		$this->assertTrue(
			$this->isTextPresent('The Message field is required.'),
			'Message required message not present.'
		);
	}

	// }}}
	// {{{ public function testBadEmail()

	public function testBadEmail()
	{
		$this->open($this->getPageUri());

		$this->type('email', 'invalid email address');
		$this->click("xpath=//input[@type='submit' and @value='Send Message']");
		$this->waitForPageToLoad(30000);

		$this->assertNoErrors();

		$this->assertTrue(
			$this->isTextPresent(
				'The email address you have entered is not properly formatted.'
			),
			'Email validation error message not present.'
		);
	}

	// }}}
	// {{{ public function testFormProcessing()

	public function testFormProcessing()
	{
		$this->open($this->getPageUri());

		$this->type('email', '<EMAIL>');
		$this->type('message', 'Test contact from Selenium.');
		$this->click("xpath=//input[@type='submit' and @value='Send Message']");
		$this->waitForPageToLoad(30000);

		$this->assertNoErrors();

		$this->assertTrue(
			$this->isTextPresent('Thank You For Your Message'),
			'Thank you message not present after submitting contact message.'
		);
	}

	// }}}
}

?>
<commit_msg>ws<commit_after><?php

require_once 'Turing/TuringSeleniumTest.php';

/**
 * Test contact us form
 *
 * @package   Site
 * @copyright 2012 silverorange
 * @license   http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
 */
abstract class SiteContactUsTest extends TuringSeleniumTest
{
	// {{{ abstract protected function getPageUri()

	abstract protected function getPageUri();

	// }}}
	// {{{ abstract protected function getSubjectCount()

	abstract protected function getSubjectCount();

	// }}}
	// {{{ public function testPageLoad()

	public function testPageLoad()
	{
		$this->open($this->getPageUri());

		$this->assertNoErrors();

		$this->assertTrue(
			$this->isTextPresent('Send us a Message'),
			'Contact form title is missing.'
		);
	}

	// }}}
	// {{{ public function testSubjectList()

	public function testSubjectList()
	{
		$this->open($this->getPageUri());

		$options = $this->getSelectOptions('id=subject');

		$this->assertEquals(
			$this->getSubjectCount(),
			count($options),
			'Number of contact subjects is incorrect.'
		);
	}

	// }}}
	// {{{ public function testEmptyForm()

	public function testEmptyForm()
	{
		$this->open($this->getPageUri());

		$this->click("xpath=//input[@type='submit' and @value='Send Message']");
		$this->waitForPageToLoad(30000);

		$this->assertNoErrors();

		$this->assertTrue(
			$this->isTextPresent('The Your Email field is required.'),
			'Email address required message not present.'
		);

		$this->assertTrue(
			$this->isTextPresent('The Message field is required.'),
			'Message required message not present.'
		);
	}

	// }}}
	// {{{ public function testBadEmail()

	public function testBadEmail()
	{
		$this->open($this->getPageUri());

		$this->type('email', 'invalid email address');
		$this->click("xpath=//input[@type='submit' and @value='Send Message']");
		$this->waitForPageToLoad(30000);

		$this->assertNoErrors();

		$this->assertTrue(
			$this->isTextPresent(
				'The email address you have entered is not properly formatted.'
			),
			'Email validation error message not present.'
		);
	}

	// }}}
	// {{{ public function testFormProcessing()

	public function testFormProcessing()
	{
		$this->open($this->getPageUri());

		$this->type('email', '<EMAIL>');
		$this->type('message', 'Test contact from Selenium.');
		$this->click("xpath=//input[@type='submit' and @value='Send Message']");
		$this->waitForPageToLoad(30000);

		$this->assertNoErrors();

		$this->assertTrue(
			$this->isTextPresent('Thank You For Your Message'),
			'Thank you message not present after submitting contact message.'
		);
	}

	// }}}
}

?>

{'fraction_non_alphanumeric': 0.17590822179732313, 'fraction_numerical': 0.00803059273422562, 'mean_word_length': 4.12843137254902, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 79, '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': '4100169', 'n_tokens_mistral': 1830, 'n_tokens_neox': 1624, 'n_words': 362}