diff options
Diffstat (limited to 'modules/gallery/tests/DrawForm_Test.php')
-rw-r--r-- | modules/gallery/tests/DrawForm_Test.php | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/modules/gallery/tests/DrawForm_Test.php b/modules/gallery/tests/DrawForm_Test.php index 7ee80ca2..da8a6b04 100644 --- a/modules/gallery/tests/DrawForm_Test.php +++ b/modules/gallery/tests/DrawForm_Test.php @@ -23,28 +23,28 @@ class DrawForm_Test extends Unit_Test_Case { $form->input("title")->label(t("Title")); $form->textarea("description")->label(t("Text Area")); $form->submit("")->value(t("Submit")); - $rendered = $form->__toString(); + $csrf = access::csrf_token(); $expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " . "id=\"g-test-group-form\">\n" . - "<input type=\"hidden\" name=\"csrf\" value=\"" . access::csrf_token() . "\" />\n" . + "<input type=\"hidden\" name=\"csrf\" value=\"$csrf\" />" . " <ul>\n" . " <li>\n" . " <label for=\"title\" >Title</label>\n" . - " <input type=\"text\" id=\"title\" name=\"title\" value=\"\" " . + " <input type=\"text\" name=\"title\" value=\"\" " . "class=\"textbox\" />\n" . " </li>\n" . " <li>\n" . " <label for=\"description\" >Text Area</label>\n" . - " <textarea id=\"description\" name=\"description\" " . + " <textarea name=\"description\" rows=\"\" cols=\"\" " . "class=\"textarea\" ></textarea>\n" . " </li>\n" . " <li>\n" . " <input type=\"submit\" value=\"Submit\" class=\"submit\" />\n" . " </li>\n" . " </ul>\n" . - "</form>\n"; - $this->assert_same($expected, $rendered); + "</form>"; + $this->assert_same($expected, (string) $form); } function group_test() { @@ -53,22 +53,22 @@ class DrawForm_Test extends Unit_Test_Case { $group->input("title")->label(t("Title")); $group->textarea("description")->label(t("Text Area")); $group->submit("")->value(t("Submit")); - $rendered = $form->__toString(); + $csrf = access::csrf_token(); $expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " . "id=\"g-test-group-form\">\n" . - "<input type=\"hidden\" name=\"csrf\" value=\"" . access::csrf_token() . "\" />\n" . + "<input type=\"hidden\" name=\"csrf\" value=\"$csrf\" />" . " <fieldset>\n" . " <legend>Test Group</legend>\n" . " <ul>\n" . " <li>\n" . " <label for=\"title\" >Title</label>\n" . - " <input type=\"text\" id=\"title\" name=\"title\" value=\"\" " . + " <input type=\"text\" name=\"title\" value=\"\" " . "class=\"textbox\" />\n" . " </li>\n" . " <li>\n" . " <label for=\"description\" >Text Area</label>\n" . - " <textarea id=\"description\" name=\"description\" " . + " <textarea name=\"description\" rows=\"\" cols=\"\" " . "class=\"textarea\" ></textarea>\n" . " </li>\n" . " <li>\n" . @@ -76,8 +76,8 @@ class DrawForm_Test extends Unit_Test_Case { " </li>\n" . " </ul>\n" . " </fieldset>\n" . - "</form>\n"; - $this->assert_same($expected, $rendered); + "</form>"; + $this->assert_same($expected, (string) $form); } function form_script_test() { @@ -89,22 +89,22 @@ class DrawForm_Test extends Unit_Test_Case { ->url(url::file("test.js")) ->text("alert('Test Javascript');"); $group->submit("")->value(t("Submit")); - $rendered = $form->__toString(); + $csrf = access::csrf_token(); $expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " . "id=\"g-test-group-form\">\n" . - "<input type=\"hidden\" name=\"csrf\" value=\"" . access::csrf_token() . "\" />\n" . + "<input type=\"hidden\" name=\"csrf\" value=\"$csrf\" />" . " <fieldset>\n" . " <legend>Test Group</legend>\n" . " <ul>\n" . " <li>\n" . " <label for=\"title\" >Title</label>\n" . - " <input type=\"text\" id=\"title\" name=\"title\" value=\"\" " . + " <input type=\"text\" name=\"title\" value=\"\" " . "class=\"textbox\" />\n" . " </li>\n" . " <li>\n" . " <label for=\"description\" >Text Area</label>\n" . - " <textarea id=\"description\" name=\"description\" " . + " <textarea name=\"description\" rows=\"\" cols=\"\" " . "class=\"textarea\" ></textarea>\n" . " </li>\n" . " <li>\n" . @@ -116,8 +116,22 @@ class DrawForm_Test extends Unit_Test_Case { "<script type=\"text/javascript\">\n" . "alert('Test Javascript');\n" . "</script>\n" . - "</form>\n"; - $this->assert_same($expected, $rendered); + "</form>"; + $this->assert_same($expected, (string) $form); + } + + function two_hiddens_test() { + $form = new Forge("test/controller", "", "post"); + $form->hidden("HIDDEN_NAME")->value("HIDDEN_VALUE"); + + $csrf = access::csrf_token(); + $expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" class=\"form\">\n" . + "<input type=\"hidden\" name=\"csrf\" value=\"$csrf\" />" . + "<input type=\"hidden\" name=\"HIDDEN_NAME\" value=\"HIDDEN_VALUE\" />" . + " <ul>\n" . + " </ul>\n" . + "</form>"; + $this->assert_same($expected, (string) $form); } } |