The following patch adds the test coverage provided by peterpoe in #735528: FAPI #states: Fix conditionals to allow OR and XOR constructions. This is just a straight diff from that tarball; I haven't done any cleanup or anything.

Comments

xjm’s picture

StatusFileSize
new23.17 KB

Ahem. Let's use git diff --staged. ;)

xjm’s picture

Status: Needs review » Needs work
+++ b/states_exercise.jsundefined
@@ -0,0 +1,30 @@
+/**
+ * Additional state change handlers to ease selection of conditions.
+ */

+++ b/states_exercise.moduleundefined
@@ -20,129 +112,350 @@ function states_exercise_menu() {
+/**
+ * Allows testing of multiple conditions from different dependees, ANDed, ORed
+ * or XORed together.
+ * TODO: test also AND, OR and XOR of "value" condition values.
+ */
...
+/**
+ * Allows testing of mixed AND, OR and XOR conditions on the same dependent.
+ * TODO: test what works and what doesn't when mixing states in several ways.
+ */
...
+/**
+ * List of element states from drupal_process_states().
+ */
...
+/**
+ * List of conditions from drupal_process_states().
+ */
...
+/**
+ * Basic form element definitions to be used as dependees and dependents.
+ * The properties #relevant_states and #relevant_conditions are used
+ * to exclude the elements in specific cases (for example, it doesn't make
+ * sense to test if a textfield is checked when a fieldset is disabled).
+ */

Summaries.

+++ b/states_exercise.moduleundefined
@@ -6,13 +6,105 @@
+      );        ¶
...
+        );        ¶

@@ -20,129 +112,350 @@ function states_exercise_menu() {
+        $form['condition_' . $condition]['#description'] = t('These fields should change state when !dependee is !condition', array('!dependee' => $dependee['#title'], '!condition' => $condition_name));        ¶

Trailing whitespace.

+++ b/states_exercise.moduleundefined
@@ -20,129 +112,350 @@ function states_exercise_menu() {
 /**
  * Attempt to demonstrate most permutations of #states.
- *
  * This hopes to become a complete and exhaustive click-and-test suite.
  */

Should keep that line.

peterpoe’s picture

Status: Needs work » Needs review
StatusFileSize
new23.61 KB

Reworked summaries and inline comments, removed trailing whitespaces and removed the $id$ tag.

dawehner’s picture

StatusFileSize
new3.95 KB
new23.51 KB

I don't have a real idea why but the patch in #3 didn't applied for me, so i took #2 and added the changes from #3.

This patch is against the 8.x branch.