aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2013-03-21 03:07:50 +0100
committerAndreas Fischer <bantu@phpbb.com>2013-03-21 03:07:50 +0100
commit15aec0bbb24be10da850f78d85a3d10880c6f28a (patch)
treebc659f47db2a2308f62d2b3f507689675930041c
parent1ac94699e456e8358ab88a0eec959f21333cb687 (diff)
downloadforums-15aec0bbb24be10da850f78d85a3d10880c6f28a.tar
forums-15aec0bbb24be10da850f78d85a3d10880c6f28a.tar.gz
forums-15aec0bbb24be10da850f78d85a3d10880c6f28a.tar.bz2
forums-15aec0bbb24be10da850f78d85a3d10880c6f28a.tar.xz
forums-15aec0bbb24be10da850f78d85a3d10880c6f28a.zip
[ticket/11460] Add methods for checkbox handling to phpbb_functional_test_case.
PHPBB3-11460
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 887dfea3b5..a62f5341ca 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -463,4 +463,68 @@ class phpbb_functional_test_case extends phpbb_test_case
$this->assertGreaterThan(0, count($nodes), $msg);
return $nodes;
}
+
+ /**
+ * Asserts that exactly one checkbox with name $name exists within the scope
+ * of $crawler and that the checkbox is checked.
+ *
+ * @param Symfony\Component\DomCrawler\Crawler $crawler
+ * @param string $name
+ * @param string $message
+ *
+ * @return null
+ */
+ public function assert_checkbox_is_checked($crawler, $name, $message = '')
+ {
+ $this->assertSame(
+ 'checked',
+ $this->assert_find_one_checkbox($crawler, $name)->attr('checked'),
+ $message ?: "Failed asserting that checkbox $name is checked."
+ );
+ }
+
+ /**
+ * Asserts that exactly one checkbox with name $name exists within the scope
+ * of $crawler and that the checkbox is unchecked.
+ *
+ * @param Symfony\Component\DomCrawler\Crawler $crawler
+ * @param string $name
+ * @param string $message
+ *
+ * @return null
+ */
+ public function assert_checkbox_is_unchecked($crawler, $name, $message = '')
+ {
+ $this->assertSame(
+ '',
+ $this->assert_find_one_checkbox($crawler, $name)->attr('checked'),
+ $message ?: "Failed asserting that checkbox $name is unchecked."
+ );
+ }
+
+ /**
+ * Searches for an input element of type checkbox with the name $name using
+ * $crawler. Contains an assertion that only one such checkbox exists within
+ * the scope of $crawler.
+ *
+ * @param Symfony\Component\DomCrawler\Crawler $crawler
+ * @param string $name
+ * @param string $message
+ *
+ * @return Symfony\Component\DomCrawler\Crawler
+ */
+ public function assert_find_one_checkbox($crawler, $name, $message = '')
+ {
+ $query = sprintf('//input[@type="checkbox" and @name="%s"]', $name);
+ $result = $crawler->filterXPath($query);
+
+ $this->assertEquals(
+ 1,
+ sizeof($result),
+ $message ?: 'Failed asserting that exactly one checkbox with name' .
+ " $name exists in crawler scope."
+ );
+
+ return $result;
+ }
}