HTML-FormFu-2.07/ 0000775 0001751 0001752 00000000000 13404751171 012036 5 ustar carl carl HTML-FormFu-2.07/dist.ini 0000644 0001751 0001752 00000006365 13404751171 013512 0 ustar carl carl name = HTML-FormFu
author = Carl Franks
license = Perl_5
copyright_holder = Carl Franks
copyright_year = 2018
main_module = lib/HTML/FormFu.pm
[Prereqs]
;;; Although we believe this will work on perl 5.8 versions, other dependancies
;;; such as Number::Format have been forcing a minimum version of 5.10 since
;;; 2011. Testing new versions against 5.8.x is getting impractical
;;perl = 5.008001
perl = 5.010
; this is the lowest version of Exporter I can identify that exports import()
; it's bundled with perl 5.83
; version 5.567 that ships with perl 5.82 is no good
Exporter = 5.57
Carp = 0
Class::MOP::Method = 0
Clone = 0.31
Config::Any = 0.18 ; 0.10 - supports multi-doc config files
; 0.18 - prefers YAML::XS for YAML
Cwd = 0
Data::Visitor = 0.26 ; when it dumped Any::Moose for Moose
Data::Visitor::Callback = 0
DateTime = 0.54 ; required for string overloading
DateTime::Format::Strptime = 1.2000
DateTime::Format::Builder = 0.7901 ; fixes memory leaks
DateTime::Format::Natural = 0
DateTime::Locale = 0.45
Email::Valid = 0
Encode = 0
Fatal = 0
File::Copy = 0
File::Find = 0
File::ShareDir = 0
File::Spec = 0
File::Temp = 0
Hash::Flatten = 0
HTML::Scrubber = 0
HTML::TokeParser::Simple = 3.14
HTTP::Headers = 1.64
IO::File = 0
JSON::MaybeXS = 0
List::MoreUtils = 0
List::Util = 1.45
Locale::Maketext = 0
Module::Pluggable = 0
Moose = 1.00 ; Reasonable default until we get test results
Moose::Role = 0
Moose::Util = 0
MooseX::Aliases = 0
MooseX::Attribute::Chained = 1.0.2
Number::Format = 0
Readonly = 0
Regexp::Common = 0
Path::Class::File = 0
Scalar::Util = 0
Storable = 0
Task::Weaken = 0 ; to ensure Scalar::Util was built with weaken()
YAML::XS = 0.32
[Prereqs / TestRequires]
CGI = 3.37 ; for file POST tests
POSIX = 0
Regexp::Assemble = 0
Test::More = 0.92
Test::Exception = 0
Test::Memory::Cycle = 0 ; for the xt/circular_reference.t
Test::RequiresInternet = 0
;; --
;; -- Sets of additional tests we want to do as part of release
[Test::Perl::Critic]
[MetaTests]
;; [PodCoverageTests] ; Currently we comprehensively fail these
[PkgVersion]
; [PodVersion] ; PodWeaver does this and more
[PodWeaver]
[Test::Kwalitee]
[Test::EOL]
finder = :InstallModules ; prevents test inputs being flagged
[Test::PAUSE::Permissions] ; if doing a release make sure we have PAUSE perms
;; -- Additional information
[GithubMeta] ; Grab the repo metadata
[NextRelease] ; Mark up the next release in changes
;; -- Additional git
[Git::GatherDir]
[Git::NextVersion] ; Get the next version tag from git
[Git::CheckFor::CorrectBranch] ; ensure on master branch for release
[Git::Remote::Check] ; ensure our branch is ahead of remote
;; -- We base the release stuff on the starter module, and tweak a bit
[@Starter]
-remove = GatherDir ; this is replaced by [Git::GatherDir]
ReadmeAnyFromPod.source_filename = lib/HTML/FormFu.pm
[ReadmeAnyFromPod / Pod_Readme]
type = pod
location = root ; do not include pod readmes in the build!
[@Git]
changelog = Changes
allow_dirty = dist.ini
allow_dirty = README.pod
allow_dirty = Changes
commit_msg = v%v%t - %d%n%n%c
tag_format = v%v%t ; see Git::Tag
tag_message = v%v%t - %d ; see Git::Tag
HTML-FormFu-2.07/MANIFEST 0000644 0001751 0001752 00000066723 13404751171 013203 0 ustar carl carl # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.011.
Changes
LICENSE
MANIFEST
MANIFEST.SKIP
META.json
META.yml
Makefile.PL
README
bin/html_formfu_deploy.pl
bin/html_formfu_dumpconf.pl
dist.ini
examples/unicode/Changes
examples/unicode/Makefile.PL
examples/unicode/README
examples/unicode/database.sql
examples/unicode/lib/unicode.pm
examples/unicode/lib/unicode/Controller/Root.pm
examples/unicode/lib/unicode/Model/DB.pm
examples/unicode/lib/unicode/Schema.pm
examples/unicode/lib/unicode/Schema/Unicode.pm
examples/unicode/lib/unicode/View/TT.pm
examples/unicode/lib/unicode/View/TT/Alloy.pm
examples/unicode/root/favicon.ico
examples/unicode/root/formfu/block
examples/unicode/root/formfu/checkboxgroup
examples/unicode/root/formfu/checkboxgroup_tag
examples/unicode/root/formfu/content_button
examples/unicode/root/formfu/end_block
examples/unicode/root/formfu/end_form
examples/unicode/root/formfu/field
examples/unicode/root/formfu/form
examples/unicode/root/formfu/input
examples/unicode/root/formfu/input_tag
examples/unicode/root/formfu/label
examples/unicode/root/formfu/multi
examples/unicode/root/formfu/non_block
examples/unicode/root/formfu/recaptcha
examples/unicode/root/formfu/repeatable
examples/unicode/root/formfu/select_tag
examples/unicode/root/formfu/start_block
examples/unicode/root/formfu/start_form
examples/unicode/root/formfu/textarea_tag
examples/unicode/root/forms/index.yml
examples/unicode/root/forms/view.conf
examples/unicode/root/forms/view.yml
examples/unicode/root/index.tt
examples/unicode/root/static/images/btn_120x50_built.png
examples/unicode/root/static/images/btn_120x50_built_shadow.png
examples/unicode/root/static/images/btn_120x50_powered.png
examples/unicode/root/static/images/btn_120x50_powered_shadow.png
examples/unicode/root/static/images/btn_88x31_built.png
examples/unicode/root/static/images/btn_88x31_built_shadow.png
examples/unicode/root/static/images/btn_88x31_powered.png
examples/unicode/root/static/images/btn_88x31_powered_shadow.png
examples/unicode/root/static/images/catalyst_logo.png
examples/unicode/root/vertically-aligned.css
examples/unicode/root/view.tt
examples/unicode/script/unicode_cgi.pl
examples/unicode/script/unicode_create.pl
examples/unicode/script/unicode_fastcgi.pl
examples/unicode/script/unicode_server.pl
examples/unicode/script/unicode_test.pl
examples/unicode/t/01app.t
examples/unicode/t/02pod.t
examples/unicode/t/03podcoverage.t
examples/unicode/t/model_DB.t
examples/unicode/t/view_TT-Alloy.t
examples/unicode/t/view_TT.t
examples/unicode/unicode.db
examples/unicode/unicode.yml
examples/vertically-aligned-css/test.jpg
examples/vertically-aligned-css/vertically-aligned-ie.css
examples/vertically-aligned-css/vertically-aligned.css
examples/vertically-aligned-css/vertically-aligned.html
examples/vertically-aligned-css/vertically-aligned.pl
examples/vertically-aligned-css/vertically-aligned.tt
examples/vertically-aligned-css/vertically-aligned.yml
lib/HTML/FormFu.pm
lib/HTML/FormFu/Attribute.pm
lib/HTML/FormFu/Constants.pm
lib/HTML/FormFu/Constraint.pm
lib/HTML/FormFu/Constraint/ASCII.pm
lib/HTML/FormFu/Constraint/AllOrNone.pm
lib/HTML/FormFu/Constraint/AutoSet.pm
lib/HTML/FormFu/Constraint/Bool.pm
lib/HTML/FormFu/Constraint/Callback.pm
lib/HTML/FormFu/Constraint/CallbackOnce.pm
lib/HTML/FormFu/Constraint/DateTime.pm
lib/HTML/FormFu/Constraint/DependOn.pm
lib/HTML/FormFu/Constraint/Email.pm
lib/HTML/FormFu/Constraint/Equal.pm
lib/HTML/FormFu/Constraint/File.pm
lib/HTML/FormFu/Constraint/File/MIME.pm
lib/HTML/FormFu/Constraint/File/MaxSize.pm
lib/HTML/FormFu/Constraint/File/MinSize.pm
lib/HTML/FormFu/Constraint/File/Size.pm
lib/HTML/FormFu/Constraint/Integer.pm
lib/HTML/FormFu/Constraint/JSON.pm
lib/HTML/FormFu/Constraint/Length.pm
lib/HTML/FormFu/Constraint/MaxLength.pm
lib/HTML/FormFu/Constraint/MaxRange.pm
lib/HTML/FormFu/Constraint/MinLength.pm
lib/HTML/FormFu/Constraint/MinMaxFields.pm
lib/HTML/FormFu/Constraint/MinRange.pm
lib/HTML/FormFu/Constraint/Number.pm
lib/HTML/FormFu/Constraint/Printable.pm
lib/HTML/FormFu/Constraint/Range.pm
lib/HTML/FormFu/Constraint/Regex.pm
lib/HTML/FormFu/Constraint/Repeatable/Any.pm
lib/HTML/FormFu/Constraint/Required.pm
lib/HTML/FormFu/Constraint/Set.pm
lib/HTML/FormFu/Constraint/SingleValue.pm
lib/HTML/FormFu/Constraint/Word.pm
lib/HTML/FormFu/Deflator.pm
lib/HTML/FormFu/Deflator/Callback.pm
lib/HTML/FormFu/Deflator/CompoundDateTime.pm
lib/HTML/FormFu/Deflator/CompoundSplit.pm
lib/HTML/FormFu/Deflator/FormatNumber.pm
lib/HTML/FormFu/Deflator/PathClassFile.pm
lib/HTML/FormFu/Deflator/Strftime.pm
lib/HTML/FormFu/Deploy.pm
lib/HTML/FormFu/Element.pm
lib/HTML/FormFu/Element/Blank.pm
lib/HTML/FormFu/Element/Block.pm
lib/HTML/FormFu/Element/Button.pm
lib/HTML/FormFu/Element/Checkbox.pm
lib/HTML/FormFu/Element/Checkboxgroup.pm
lib/HTML/FormFu/Element/ComboBox.pm
lib/HTML/FormFu/Element/ContentButton.pm
lib/HTML/FormFu/Element/Date.pm
lib/HTML/FormFu/Element/DateTime.pm
lib/HTML/FormFu/Element/Email.pm
lib/HTML/FormFu/Element/Fieldset.pm
lib/HTML/FormFu/Element/File.pm
lib/HTML/FormFu/Element/Hidden.pm
lib/HTML/FormFu/Element/Hr.pm
lib/HTML/FormFu/Element/Image.pm
lib/HTML/FormFu/Element/Label.pm
lib/HTML/FormFu/Element/Multi.pm
lib/HTML/FormFu/Element/Number.pm
lib/HTML/FormFu/Element/Password.pm
lib/HTML/FormFu/Element/Radio.pm
lib/HTML/FormFu/Element/Radiogroup.pm
lib/HTML/FormFu/Element/Repeatable.pm
lib/HTML/FormFu/Element/Reset.pm
lib/HTML/FormFu/Element/Select.pm
lib/HTML/FormFu/Element/SimpleTable.pm
lib/HTML/FormFu/Element/Src.pm
lib/HTML/FormFu/Element/Submit.pm
lib/HTML/FormFu/Element/Text.pm
lib/HTML/FormFu/Element/Textarea.pm
lib/HTML/FormFu/Element/URL.pm
lib/HTML/FormFu/Exception.pm
lib/HTML/FormFu/Exception/Constraint.pm
lib/HTML/FormFu/Exception/Inflator.pm
lib/HTML/FormFu/Exception/Input.pm
lib/HTML/FormFu/Exception/Transformer.pm
lib/HTML/FormFu/Exception/Validator.pm
lib/HTML/FormFu/FakeQuery.pm
lib/HTML/FormFu/Filter.pm
lib/HTML/FormFu/Filter/Callback.pm
lib/HTML/FormFu/Filter/CompoundJoin.pm
lib/HTML/FormFu/Filter/CompoundSprintf.pm
lib/HTML/FormFu/Filter/CopyValue.pm
lib/HTML/FormFu/Filter/Encode.pm
lib/HTML/FormFu/Filter/ForceListValue.pm
lib/HTML/FormFu/Filter/FormatNumber.pm
lib/HTML/FormFu/Filter/HTMLEscape.pm
lib/HTML/FormFu/Filter/HTMLScrubber.pm
lib/HTML/FormFu/Filter/LowerCase.pm
lib/HTML/FormFu/Filter/NonNumeric.pm
lib/HTML/FormFu/Filter/Regex.pm
lib/HTML/FormFu/Filter/Split.pm
lib/HTML/FormFu/Filter/TrimEdges.pm
lib/HTML/FormFu/Filter/UpperCase.pm
lib/HTML/FormFu/Filter/Whitespace.pm
lib/HTML/FormFu/I18N.pm
lib/HTML/FormFu/I18N/bg.pm
lib/HTML/FormFu/I18N/cs.pm
lib/HTML/FormFu/I18N/da.pm
lib/HTML/FormFu/I18N/de.pm
lib/HTML/FormFu/I18N/en.pm
lib/HTML/FormFu/I18N/es.pm
lib/HTML/FormFu/I18N/fr.pm
lib/HTML/FormFu/I18N/hu.pm
lib/HTML/FormFu/I18N/it.pm
lib/HTML/FormFu/I18N/ja.pm
lib/HTML/FormFu/I18N/no.pm
lib/HTML/FormFu/I18N/pt_br.pm
lib/HTML/FormFu/I18N/pt_pt.pm
lib/HTML/FormFu/I18N/ro.pm
lib/HTML/FormFu/I18N/ru.pm
lib/HTML/FormFu/I18N/tr.pm
lib/HTML/FormFu/I18N/ua.pm
lib/HTML/FormFu/I18N/zh_cn.pm
lib/HTML/FormFu/Inflator.pm
lib/HTML/FormFu/Inflator/Callback.pm
lib/HTML/FormFu/Inflator/CompoundDateTime.pm
lib/HTML/FormFu/Inflator/DateTime.pm
lib/HTML/FormFu/Literal.pm
lib/HTML/FormFu/Localize.pm
lib/HTML/FormFu/Manual/Cookbook.pod
lib/HTML/FormFu/Manual/Unicode.pod
lib/HTML/FormFu/Model.pm
lib/HTML/FormFu/Model/HashRef.pm
lib/HTML/FormFu/ObjectUtil.pm
lib/HTML/FormFu/OutputProcessor.pm
lib/HTML/FormFu/OutputProcessor/Indent.pm
lib/HTML/FormFu/OutputProcessor/StripWhitespace.pm
lib/HTML/FormFu/Plugin.pm
lib/HTML/FormFu/Plugin/StashValid.pm
lib/HTML/FormFu/Preload.pm
lib/HTML/FormFu/Processor.pm
lib/HTML/FormFu/QueryType/CGI.pm
lib/HTML/FormFu/QueryType/CGI/Simple.pm
lib/HTML/FormFu/QueryType/Catalyst.pm
lib/HTML/FormFu/Role/Constraint/Others.pm
lib/HTML/FormFu/Role/ContainsElements.pm
lib/HTML/FormFu/Role/ContainsElementsSharedWithField.pm
lib/HTML/FormFu/Role/CreateChildren.pm
lib/HTML/FormFu/Role/CustomRoles.pm
lib/HTML/FormFu/Role/Element/Coercible.pm
lib/HTML/FormFu/Role/Element/Field.pm
lib/HTML/FormFu/Role/Element/FieldMethods.pm
lib/HTML/FormFu/Role/Element/Group.pm
lib/HTML/FormFu/Role/Element/Input.pm
lib/HTML/FormFu/Role/Element/Layout.pm
lib/HTML/FormFu/Role/Element/MultiElement.pm
lib/HTML/FormFu/Role/Element/NonBlock.pm
lib/HTML/FormFu/Role/Element/ProcessOptionsFromModel.pm
lib/HTML/FormFu/Role/Element/SingleValueField.pm
lib/HTML/FormFu/Role/Filter/Compound.pm
lib/HTML/FormFu/Role/FormAndBlockMethods.pm
lib/HTML/FormFu/Role/FormAndElementMethods.pm
lib/HTML/FormFu/Role/FormBlockAndFieldMethods.pm
lib/HTML/FormFu/Role/GetProcessors.pm
lib/HTML/FormFu/Role/HasParent.pm
lib/HTML/FormFu/Role/NestedHashUtils.pm
lib/HTML/FormFu/Role/Populate.pm
lib/HTML/FormFu/Role/Render.pm
lib/HTML/FormFu/Transformer.pm
lib/HTML/FormFu/Transformer/Callback.pm
lib/HTML/FormFu/Upload.pm
lib/HTML/FormFu/UploadParam.pm
lib/HTML/FormFu/Util.pm
lib/HTML/FormFu/Validator.pm
lib/HTML/FormFu/Validator/Callback.pm
share/templates/tt/xhtml/block
share/templates/tt/xhtml/end_block
share/templates/tt/xhtml/end_form
share/templates/tt/xhtml/field
share/templates/tt/xhtml/field_layout
share/templates/tt/xhtml/field_layout_block
share/templates/tt/xhtml/field_layout_checkboxgroup_field
share/templates/tt/xhtml/field_layout_comment
share/templates/tt/xhtml/field_layout_contentbutton_field
share/templates/tt/xhtml/field_layout_errors
share/templates/tt/xhtml/field_layout_field
share/templates/tt/xhtml/field_layout_javascript
share/templates/tt/xhtml/field_layout_label
share/templates/tt/xhtml/field_layout_label_field
share/templates/tt/xhtml/field_layout_label_text
share/templates/tt/xhtml/field_layout_multi_field
share/templates/tt/xhtml/field_layout_parser
share/templates/tt/xhtml/field_layout_select_field
share/templates/tt/xhtml/field_layout_textarea_field
share/templates/tt/xhtml/form
share/templates/tt/xhtml/non_block
share/templates/tt/xhtml/recaptcha
share/templates/tt/xhtml/repeatable
share/templates/tt/xhtml/start_block
share/templates/tt/xhtml/start_form
t/00-report-prereqs.dd
t/00-report-prereqs.t
t/01use.t
t/04basic.t
t/04basic.yml
t/05_repeated_render.t
t/block_insert_after.t
t/block_insert_before.t
t/bugs/constructor_arg_overwrites_default.t
t/bugs/date_element_deflator.t
t/bugs/date_element_empty_input.t
t/bugs/datetime_hour_lt_10.t
t/bugs/disabled_select_default_value.yml
t/bugs/element_class.t
t/bugs/element_parent.t
t/bugs/empty_block_with_nested_name.t
t/bugs/empty_block_with_nested_name.yml
t/bugs/error_msg.t
t/bugs/error_multiple_fields_same_name.t
t/bugs/error_multiple_fields_same_name.yml
t/bugs/field_no_name.t
t/bugs/filter_run_once.t
t/bugs/multiple_checkbox_same_name.t
t/bugs/multiple_checkbox_same_name.yml
t/bugs/name_regex_chars.t
t/bugs/not_nested.t
t/bugs/populate_element_coderef.t
t/bugs/pre_1_00_compat.t
t/bugs/pre_1_00_compat.yml
t/bugs/render_processed_value_retain_default.t
t/bugs/render_processed_value_retain_default.yml
t/bugs/repeatable_increase_rep.t
t/bugs/repeatable_increase_rep.yml
t/bugs/result_params_multiple.t
t/bugs/select_empty_options.t
t/bugs/submit_no_value.t
t/bugs/submit_retain_default.t
t/bugs/value_empty_string.t
t/bugs/value_no_default.t
t/bugs/yaml_utf8.t
t/bugs/yaml_utf8.txt
t/bugs/yaml_utf8.yml
t/constraints/allornone.t
t/constraints/allornone_attach_errors_to_base.t
t/constraints/allornone_attach_errors_to_base.yml
t/constraints/allornone_attach_errors_to_others.t
t/constraints/allornone_attach_errors_to_others.yml
t/constraints/ascii.t
t/constraints/autoset.t
t/constraints/autoset_group.t
t/constraints/bool.t
t/constraints/callback.t
t/constraints/callbackonce.t
t/constraints/constraint.t
t/constraints/constraint_other_siblings.t
t/constraints/constraint_other_siblings.yml
t/constraints/constraint_other_siblings_not.t
t/constraints/constraint_other_siblings_not.yml
t/constraints/constraint_when.t
t/constraints/constraint_when.yml
t/constraints/constraint_when_any_field.t
t/constraints/constraint_when_any_field.yml
t/constraints/constraint_when_any_true_value.t
t/constraints/constraint_when_any_true_value.yml
t/constraints/constraint_when_default_empty_value.t
t/constraints/constraint_when_default_empty_value.yml
t/constraints/constraint_when_fields.t
t/constraints/constraint_when_fields.yml
t/constraints/datetime_parser.t
t/constraints/dependon.t
t/constraints/dependon_attach_errors_to_base.t
t/constraints/dependon_attach_errors_to_base.yml
t/constraints/dependon_attach_errors_to_others.t
t/constraints/dependon_attach_errors_to_others.yml
t/constraints/email-mx.t
t/constraints/email.t
t/constraints/equal.t
t/constraints/equal_internals.t
t/constraints/equal_not.t
t/constraints/file.t
t/constraints/file.yml
t/constraints/file_maxsize.t
t/constraints/file_maxsize.yml
t/constraints/file_mime.t
t/constraints/file_mime.yml
t/constraints/file_minsize.t
t/constraints/file_minsize.yml
t/constraints/file_size.t
t/constraints/file_size.yml
t/constraints/integer.t
t/constraints/json.t
t/constraints/length.t
t/constraints/localize.t
t/constraints/maxlength.t
t/constraints/maxrange.t
t/constraints/minlength.t
t/constraints/minmaxfields.t
t/constraints/minmaxfields_with_filter_split.t
t/constraints/minmaxfields_with_filter_split.yml
t/constraints/minrange.t
t/constraints/not_equal.t
t/constraints/not_word.t
t/constraints/number.t
t/constraints/printable.t
t/constraints/range.t
t/constraints/regex.t
t/constraints/regex_anchored.t
t/constraints/regex_common.t
t/constraints/repeatable_any.t
t/constraints/repeatable_any.yml
t/constraints/repeatable_any_not_increment_field_names.t
t/constraints/repeatable_any_not_increment_field_names.yml
t/constraints/required.t
t/constraints/required_file.t
t/constraints/required_file.yml
t/constraints/required_only_on_reps.t
t/constraints/required_only_on_reps.yml
t/constraints/set.t
t/constraints/singlevalue.t
t/constraints/word.t
t/constraints/xml.t
t/deflators/callback.t
t/deflators/compounddatetime.t
t/deflators/compounddatetime.yml
t/deflators/compounddatetime_field_order.t
t/deflators/compounddatetime_field_order.yml
t/deflators/compoundsplit.t
t/deflators/compoundsplit.yml
t/deflators/compoundsplit_after_submit.t
t/deflators/compoundsplit_after_submit.yml
t/deflators/compoundsplit_field_order.t
t/deflators/compoundsplit_field_order.yml
t/deflators/compoundsplit_split.t
t/deflators/compoundsplit_split.yml
t/deflators/formatnumber.t
t/deflators/formatnumber.yml
t/deflators/pathclassfile.t
t/elements-file_post.t
t/elements-file_post.txt
t/elements/blank.t
t/elements/block.t
t/elements/block_auto_block_id.t
t/elements/block_auto_block_id.yml
t/elements/block_repeatable.t
t/elements/block_repeatable.yml
t/elements/block_repeatable_attrs.t
t/elements/block_repeatable_attrs.yml
t/elements/block_repeatable_auto_block_id.t
t/elements/block_repeatable_auto_block_id.yml
t/elements/block_repeatable_auto_id.t
t/elements/block_repeatable_auto_id.yml
t/elements/block_repeatable_date.t
t/elements/block_repeatable_date.yml
t/elements/block_repeatable_inc.t
t/elements/block_repeatable_inc.yml
t/elements/block_repeatable_multi.t
t/elements/block_repeatable_tag.t
t/elements/block_repeatable_tag.yml
t/elements/button.t
t/elements/button_no_name.t
t/elements/checkbox.t
t/elements/checkbox_force_default.t
t/elements/checkbox_retain_default.t
t/elements/checkbox_reverse.t
t/elements/checkbox_reverse.yml
t/elements/checkboxgroup.t
t/elements/checkboxgroup_attributes_escaped.t
t/elements/checkboxgroup_attributes_escaped.yml
t/elements/combobox.t
t/elements/combobox.yml
t/elements/combobox_repeatable.t
t/elements/combobox_repeatable.yml
t/elements/combobox_required.t
t/elements/combobox_required.yml
t/elements/content_button.t
t/elements/date.t
t/elements/date_default.t
t/elements/date_default_datetime_args.t
t/elements/date_default_datetime_args.yml
t/elements/date_default_empty.t
t/elements/date_month_year.t
t/elements/date_natural.t
t/elements/date_order.t
t/elements/date_order_error.t
t/elements/date_rename.t
t/elements/date_undef.t
t/elements/date_year_reverse.t
t/elements/date_year_reverse.yml
t/elements/datetime.t
t/elements/datetime.yml
t/elements/datetime_interval.t
t/elements/datetime_interval.yml
t/elements/datetime_seconds.t
t/elements/datetime_seconds.yml
t/elements/element_setup.t
t/elements/email.t
t/elements/error_attributes_failing_test.select-with-attrs.yml
t/elements/error_attributes_failing_test.select.yml
t/elements/error_attributes_failing_test.t
t/elements/error_attributes_failing_test.text-with-attrs.yml
t/elements/error_attributes_failing_test.text.yml
t/elements/escaping.t
t/elements/field_default_empty_value.t
t/elements/field_default_empty_value.yml
t/elements/field_non_param.t
t/elements/fieldset.t
t/elements/fieldset_legend_attrs.t
t/elements/fieldset_legend_attrs.yml
t/elements/file.t
t/elements/file_post.txt
t/elements/file_post_cgi_simple.t
t/elements/hidden.t
t/elements/hr.t
t/elements/image.t
t/elements/label.t
t/elements/label.yml
t/elements/label_value_submission.t
t/elements/label_value_submission.yml
t/elements/multi.t
t/elements/multi_errors.t
t/elements/multiple_submit_buttons.t
t/elements/no_block_tag.t
t/elements/no_block_tag.yml
t/elements/no_container_tag.t
t/elements/no_container_tag.yml
t/elements/number.t
t/elements/number.yml
t/elements/object.t
t/elements/object/field_layout_field_custom
t/elements/password.t
t/elements/password_render_value.t
t/elements/password_retain_default.t
t/elements/radio.t
t/elements/radio_force_default.t
t/elements/radio_retain_default.t
t/elements/radiogroup.t
t/elements/radiogroup_attributes_escaped.t
t/elements/radiogroup_attributes_escaped.yml
t/elements/radiogroup_attrs_xml.t
t/elements/radiogroup_dup_opt.t
t/elements/radiogroup_errors.t
t/elements/radiogroup_force_default.t
t/elements/radiogroup_id.t
t/elements/radiogroup_id_value.t
t/elements/radiogroup_retain_default.t
t/elements/radiogroup_subgroup.t
t/elements/radiogroup_unknown_opt.t
t/elements/radiogroup_xml.t
t/elements/render_method.t
t/elements/repeatable_counter_name.t
t/elements/repeatable_counter_name.yml
t/elements/repeatable_repeatable.t
t/elements/repeatable_repeatable.yml
t/elements/reset.t
t/elements/reverse.t
t/elements/select.t
t/elements/select_attributes_escaped.t
t/elements/select_attributes_escaped.yml
t/elements/select_deflator_default.t
t/elements/select_empty_first.t
t/elements/select_empty_first.yml
t/elements/select_empty_first_label.t
t/elements/select_force_default.t
t/elements/select_label_loc.t
t/elements/select_multi_default_values.t
t/elements/select_multi_value.t
t/elements/select_optgroup.t
t/elements/select_options.t
t/elements/select_retain_default.t
t/elements/select_same_name.t
t/elements/select_same_name.yml
t/elements/select_value_range.t
t/elements/simple_table.t
t/elements/simple_table.yml
t/elements/simple_table_class.t
t/elements/simple_table_class.yml
t/elements/simple_table_multiple.t
t/elements/simple_table_multiple.yml
t/elements/src.t
t/elements/submit.t
t/elements/text.t
t/elements/text_attributes.t
t/elements/text_auto_comment_class.t
t/elements/text_auto_comment_class.yml
t/elements/text_auto_container_class.t
t/elements/text_auto_container_class.yml
t/elements/text_auto_container_comment_class.t
t/elements/text_auto_container_comment_class.yml
t/elements/text_auto_container_error_class.t
t/elements/text_auto_container_error_class.yml
t/elements/text_auto_container_label_class.t
t/elements/text_auto_container_label_class.yml
t/elements/text_auto_label_class.t
t/elements/text_auto_label_class.yml
t/elements/text_datalist_options.t
t/elements/text_datalist_options.yml
t/elements/text_datalist_values.t
t/elements/text_datalist_values.yml
t/elements/text_errors.t
t/elements/text_force_default.t
t/elements/text_layout.t
t/elements/text_layout.yml
t/elements/text_retain_default.t
t/elements/text_title.t
t/elements/textarea.t
t/elements/url.t
t/elements/url.yml
t/examples/custom_label.t
t/examples/custom_label2.t
t/examples/field_as.t
t/examples/fields_as_list_items.t
t/field_accessor_loc.t
t/field_accessor_loc_arrayref.t
t/field_accessor_loc_arrayref.yml
t/field_change_name.t
t/field_id.t
t/filters/all_by_default.t
t/filters/callback.t
t/filters/compoundjoin.t
t/filters/compoundjoin.yml
t/filters/compoundjoin_field_order.t
t/filters/compoundjoin_field_order.yml
t/filters/compoundjoin_join.t
t/filters/compoundjoin_join.yml
t/filters/compoundsprintf.t
t/filters/compoundsprintf.yml
t/filters/compoundsprintf_field_order.t
t/filters/compoundsprintf_field_order.yml
t/filters/copyvalue.t
t/filters/encode.t
t/filters/filter.t
t/filters/formatnumber.t
t/filters/formatnumber.yml
t/filters/htmlescape.t
t/filters/htmlscrubber.t
t/filters/lowercase.t
t/filters/nonnumeric.t
t/filters/regex.t
t/filters/regex.yml
t/filters/regex_eval.t
t/filters/regex_eval.yml
t/filters/split.t
t/filters/split.yml
t/filters/trimedges.t
t/filters/uppercase.t
t/filters/whitespace.t
t/force_errors/allornone.t
t/force_errors/callbackonce.t
t/force_errors/dependon.t
t/force_errors/equal.t
t/force_errors/force_errors.t
t/force_errors/integer.t
t/force_errors/minmaxfields.t
t/form/add_render_class_args.t
t/form/add_valid.t
t/form/add_valid_unknown.t
t/form/attributes.t
t/form/auto_constraint_class.t
t/form/auto_error_class.t
t/form/auto_error_field_class.t
t/form/auto_error_message.t
t/form/auto_fieldset.t
t/form/auto_label.t
t/form/clone.t
t/form/config_callback.t
t/form/config_callback.yml
t/form/constraints_from_dbic.t
t/form/constraints_from_dbic.yml
t/form/constraints_from_dbic_rs.t
t/form/default_args.t
t/form/default_args_alt.t
t/form/default_args_alt.yml
t/form/default_args_isa.t
t/form/default_args_isa.yml
t/form/default_args_not_inheriting.t
t/form/default_values.t
t/form/end.t
t/form/error_message.t
t/form/force_error_message.t
t/form/form_error_message_class.t
t/form/get_all_elements.t
t/form/get_constraint.t
t/form/get_constraints.t
t/form/get_deflator.t
t/form/get_deflators.t
t/form/get_element.t
t/form/get_elements.t
t/form/get_errors.t
t/form/get_field.t
t/form/get_fields.t
t/form/get_filter.t
t/form/get_filters.t
t/form/get_inflator.t
t/form/get_inflators.t
t/form/get_parent.t
t/form/get_parent.yml
t/form/has_errors.t
t/form/hidden_fields.t
t/form/init_arg.t
t/form/insert_after.t
t/form/insert_before.t
t/form/javascript.t
t/form/javascript_src.t
t/form/languages.t
t/form/languages.yml
t/form/model.t
t/form/multiple_same_named_fields.t
t/form/object.t
t/form/object/form
t/form/param.t
t/form/param_array.t
t/form/param_list.t
t/form/param_value.t
t/form/params.t
t/form/params_ignore_underscore.t
t/form/query.t
t/form/render_processed_value.t
t/form/render_processed_value.yml
t/form/start.t
t/form/stash.t
t/form/submitted.t
t/form/submitted_and_valid.t
t/form/title_xml.t
t/form/valid.t
t/i18n/add_localize_object.t
t/i18n/add_localize_object_from_class.t
t/i18n/add_localize_object_from_class.yml
t/inflators/array.t
t/inflators/callback.t
t/inflators/compounddatetime.t
t/inflators/compounddatetime.yml
t/inflators/compounddatetime_field_order.t
t/inflators/compounddatetime_field_order.yml
t/inflators/datetime_optional.t
t/inflators/datetime_parser.t
t/inflators/datetime_regex.t
t/inflators/datetime_regex_string.t
t/inflators/datetime_strptime.t
t/inflators/datetime_timezone.t
t/inflators/datetime_with_constraint.t
t/inflators/datetime_with_constraint.yml
t/internals/default_args-types.t
t/internals/default_args-types.yml
t/lib/HTMLFormFu/DBICUniqueFake.pm
t/lib/HTMLFormFu/ElementSetup.pm
t/lib/HTMLFormFu/I18N.pm
t/lib/HTMLFormFu/I18N/en.pm
t/lib/HTMLFormFu/MyBlockRole.pm
t/lib/HTMLFormFu/MyDeflator.pm
t/lib/HTMLFormFu/MyFieldRole.pm
t/lib/HTMLFormFu/MyFormRole.pm
t/lib/HTMLFormFu/MyModel.pm
t/lib/HTMLFormFu/MyObject.pm
t/lib/HTMLFormFu/MyValidator.pm
t/lib/HTMLFormFu/RegressLocalization.pm
t/lib/HTMLFormFu/RegressLocalization/en.pm
t/lib/HTMLFormFu/TestLib.pm
t/lib/MyApp/Schema.pm
t/lib/MyApp/Schema/Dongle.pm
t/lib/MyApp/Schema/Person.pm
t/load_config/config_file_path.t
t/load_config/config_file_path/form.yml
t/load_config/config_file_path2/form.yml
t/load_config/load_config_file.t
t/load_config/load_config_file_constraint_regex.t
t/load_config/load_config_file_constraint_regex.yml
t/load_config/load_config_file_fieldset.yml
t/load_config/load_config_file_form.yml
t/load_config/load_config_file_multi_stream.t
t/load_config/load_config_file_multi_stream.yml
t/load_config/load_config_file_multiple.t
t/load_config/load_config_file_multiple.yml
t/load_config/load_config_file_multiple1.yml
t/load_config/load_config_file_multiple2.yml
t/load_config/load_config_filestem.t
t/model/hashref_create.t
t/model/hashref_create_repeatable_without_nestedname.t
t/model/hashref_create_repeatable_without_nestedname.yml
t/model/hashref_default_values.t
t/model/hashref_escaping.t
t/model/hashref_multi_within_rep.t
t/model/hashref_multi_within_rep.yml
t/model/hashref_process.t
t/multiple_select_fields.t
t/multiple_text_fields.t
t/nested-elements-file_post.t
t/nested/constraints/allornone.t
t/nested/constraints/callbackonce.t
t/nested/constraints/constraint_when.t
t/nested/constraints/constraint_when.yml
t/nested/constraints/dependon.t
t/nested/constraints/equal.t
t/nested/constraints/minmaxfields.t
t/nested/constraints/required.t
t/nested/element_name.t
t/nested/element_name.yml
t/nested/elements/block_repeatable_multi_named.t
t/nested/elements/block_repeatable_multi_named.yml
t/nested/elements/block_repeatable_multi_named_filter.t
t/nested/elements/block_repeatable_multi_named_filter.yml
t/nested/elements/block_without_name.t
t/nested/elements/block_without_name.yml
t/nested/elements/checkbox_force_default.t
t/nested/elements/checkbox_retain_default.t
t/nested/elements/combobox.t
t/nested/elements/date.t
t/nested/elements/multi.t
t/nested/elements/multi_named.t
t/nested/elements/radio.t
t/nested/elements/radio_force_default.t
t/nested/elements/radio_retain_default.t
t/nested/elements/radiogroup.t
t/nested/elements/radiogroup_force_default.t
t/nested/elements/radiogroup_retain_default.t
t/nested/elements/repeatable_repeatable.t
t/nested/elements/repeatable_repeatable.yml
t/nested/elements/select.t
t/nested/elements/select_force_default.t
t/nested/elements/select_retain_default.t
t/nested/elements/select_same_name.t
t/nested/elements/select_same_name.yml
t/nested/elements/text.t
t/nested/filters/regex.t
t/nested/form/render_processed_value.t
t/nested/form/render_processed_value.yml
t/nested/form_input.t
t/nested/illegal_name.t
t/nested/inflators/datetime_strptime.t
t/nested/internals/form_processed_params.t
t/nested/internals/hash_keys.t
t/nested/param.t
t/nested/params.t
t/nested/pre_expanded.t
t/nested/transformers/callback.t
t/nested/valid.t
t/nested/validators/callback.t
t/output_processors/indent.t
t/output_processors/indent_internals.t
t/output_processors/strip_whitespace.t
t/output_processors/strip_whitespace.yml
t/plugins/stashvalid.t
t/plugins/stashvalid.yml
t/plugins/stashvalid_on_field.t
t/plugins/stashvalid_on_field.yml
t/repeatable/clone.t
t/repeatable/clone.yml
t/repeatable/constraints/attach_errors_to.t
t/repeatable/constraints/attach_errors_to.yml
t/repeatable/constraints/equal.t
t/repeatable/constraints/equal.yml
t/repeatable/constraints/required.t
t/repeatable/constraints/required.yml
t/repeatable/constraints/required_not_increment_field_names.t
t/repeatable/constraints/required_not_increment_field_names.yml
t/repeatable/constraints/required_not_nested.t
t/repeatable/constraints/required_not_nested.yml
t/repeatable/constraints/when.t
t/repeatable/constraints/when.yml
t/repeatable/repeatable/constraints/repeatable_any.t
t/repeatable/repeatable/constraints/repeatable_any.yml
t/roles/block.t
t/roles/block.yml
t/roles/field.t
t/roles/field.yml
t/roles/form.t
t/roles/form.yml
t/templates/field_layout
t/transformers/callback.t
t/utils/append_xml_attribute.t
t/utils/has_xml_attribute.t
t/utils/remove_xml_attribute.t
t/validators/callback.t
t/validators/validator.t
xt/author/00-compile.t
xt/author/critic.t
xt/author/eol.t
xt/author/pod-syntax.t
xt/circular_reference.t
xt/circular_reference.yml
xt/release/distmeta.t
xt/release/kwalitee.t
xt/release/pause-permissions.t
HTML-FormFu-2.07/t/ 0000775 0001751 0001752 00000000000 13404751171 012301 5 ustar carl carl HTML-FormFu-2.07/t/multiple_select_fields.t 0000644 0001751 0001752 00000001665 13404751171 017214 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 2;
use HTML::FormFu;
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->element('Select')->name('foo')->values( [qw/ one two three /] )
->default('two')->multiple(1);
$form->process( { foo => [qw/ one three /], } );
my $xhtml = <
EOF
is( "$form", $xhtml );
$form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->element('Select')->name('foo')->values( [qw/ one two three /] )
->default('two')->multiple(1);
my $select_field = $form->get_element( { name => 'foo' } );
$select_field->default( [qw/ one three /] );
is( "$form", $xhtml );
HTML-FormFu-2.07/t/repeatable/ 0000775 0001751 0001752 00000000000 13404751171 014405 5 ustar carl carl HTML-FormFu-2.07/t/repeatable/repeatable/ 0000775 0001751 0001752 00000000000 13404751171 016511 5 ustar carl carl HTML-FormFu-2.07/t/repeatable/repeatable/constraints/ 0000775 0001751 0001752 00000000000 13404751171 021060 5 ustar carl carl HTML-FormFu-2.07/t/repeatable/repeatable/constraints/repeatable_any.yml 0000644 0001751 0001752 00000000615 13404751171 024556 0 ustar carl carl ---
elements:
- type: Hidden
name: outer_count
- type: Repeatable
counter_name: outer_count
elements:
- name: foo
constraints:
- 'Repeatable::Any'
- type: Hidden
name: inner_count
- type: Repeatable
counter_name: inner_count
elements:
- name: foo
constraints:
- 'Repeatable::Any'
HTML-FormFu-2.07/t/repeatable/repeatable/constraints/repeatable_any.t 0000644 0001751 0001752 00000002547 13404751171 024226 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 3;
use HTML::FormFu;
use lib 't/lib';
use HTMLFormFu::TestLib;
my $form = HTML::FormFu->new;
$form->load_config_file(
't/repeatable/repeatable/constraints/repeatable_any.yml');
# Valid
{
$form->process(
{ outer_count => 3,
foo_1 => 'a',
foo_2 => '',
foo_3 => '',
inner_count_1 => 2,
foo_1_1 => '',
foo_1_2 => 'b',
inner_count_2 => 3,
foo_2_1 => '',
foo_2_2 => '',
foo_2_3 => 'c',
inner_count_3 => 1,
foo_3_1 => 'd',
} );
ok( $form->submitted_and_valid );
}
# Missing - Invalid
{
$form->process(
{ outer_count => 3,
foo_1 => '',
foo_2 => '',
foo_3 => '',
inner_count_1 => 2,
foo_1_1 => '',
foo_1_2 => 'b',
inner_count_2 => 3,
foo_2_1 => '',
foo_2_2 => '',
foo_2_3 => 'c',
inner_count_3 => 1,
foo_3_1 => '',
} );
ok( !$form->submitted_and_valid );
# error is only attached to first rep
is_deeply( [ $form->has_errors ], [ 'foo_1', 'foo_3_1' ] );
}
HTML-FormFu-2.07/t/repeatable/constraints/ 0000775 0001751 0001752 00000000000 13404751171 016754 5 ustar carl carl HTML-FormFu-2.07/t/repeatable/constraints/required_not_increment_field_names.yml 0000644 0001751 0001752 00000000316 13404751171 026567 0 ustar carl carl ---
elements:
- type: Hidden
name: count
- type: Repeatable
increment_field_names: 0
counter_name: count
elements:
- name: foo
- name: bar
constraints:
- Required
HTML-FormFu-2.07/t/repeatable/constraints/required.t 0000644 0001751 0001752 00000003123 13404751171 020756 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 11;
use HTML::FormFu;
use lib 't/lib';
use HTMLFormFu::TestLib;
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->load_config_file('t/repeatable/constraints/required.yml');
$form->get_element( { type => 'Repeatable' } )->repeat(2);
# Valid
{
$form->process(
{ 'rep_1.foo' => 'a',
'rep_1.bar' => 'b',
'rep_2.foo' => 'c',
'rep_2.bar' => 'd',
count => 2,
} );
ok( $form->submitted_and_valid );
is_deeply(
$form->params,
{ rep_1 => {
foo => 'a',
bar => 'b',
},
rep_2 => {
foo => 'c',
bar => 'd',
},
count => 2,
} );
}
# Missing - Invalid
{
$form->process(
{ 'rep_1.bar' => 'b',
'rep_2.foo' => 'c',
count => 2,
} );
ok( !$form->submitted_and_valid );
ok( $form->has_errors('rep_1.foo') );
ok( !$form->has_errors('rep_1.bar') );
ok( !$form->has_errors('rep_2.foo') );
ok( $form->has_errors('rep_2.bar') );
like( $form->get_field( { nested_name => 'rep_1.foo' } ),
qr/This field is required/ );
unlike( $form->get_field( { nested_name => 'rep_1.bar' } ),
qr/This field is required/ );
unlike( $form->get_field( { nested_name => 'rep_2.foo' } ),
qr/This field is required/ );
like( $form->get_field( { nested_name => 'rep_2.bar' } ),
qr/This field is required/ );
}
HTML-FormFu-2.07/t/repeatable/constraints/required_not_nested.yml 0000644 0001751 0001752 00000000316 13404751171 023537 0 ustar carl carl ---
elements:
- type: Hidden
name: count
- type: Repeatable
increment_field_names: 1
counter_name: count
elements:
- name: foo
- name: bar
constraints:
- Required
HTML-FormFu-2.07/t/repeatable/constraints/attach_errors_to.t 0000644 0001751 0001752 00000001414 13404751171 022501 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 5;
use HTML::FormFu;
use lib 't/lib';
use HTMLFormFu::TestLib;
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->load_config_file('t/repeatable/constraints/attach_errors_to.yml');
$form->get_element( { type => 'Repeatable' } )->repeat(2);
# Missing - Invalid
{
$form->process(
{ 'rep_1.foo' => 'AAA',
'rep_1.bar' => '',
count => 1,
} );
ok( !$form->submitted_and_valid );
ok( $form->has_errors('rep_1.foo') );
ok( $form->has_errors('rep_1.bar') );
like( $form->get_field( { nested_name => 'rep_1.foo' } ), qr/Error/ );
like( $form->get_field( { nested_name => 'rep_1.bar' } ), qr/Error/ );
}
HTML-FormFu-2.07/t/repeatable/constraints/when.yml 0000644 0001751 0001752 00000000452 13404751171 020437 0 ustar carl carl ---
elements:
- type: Hidden
name: count
- type: Repeatable
nested_name: rep
increment_field_names: 1
counter_name: count
elements:
- name: foo
- name: bar
constraints:
- type: Required
when:
field: 'rep.foo'
HTML-FormFu-2.07/t/repeatable/constraints/equal.t 0000644 0001751 0001752 00000003674 13404751171 020260 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 16;
use HTML::FormFu;
use lib 't/lib';
use HTMLFormFu::TestLib;
my $form = HTML::FormFu->new;
$form->load_config_file('t/repeatable/constraints/equal.yml');
$form->get_element( { type => 'Repeatable' } )->repeat(2);
# Valid
{
$form->process(
{ 'rep_1.foo' => 'a',
'rep_1.bar' => 'a',
'rep_1.baz' => 'a',
'rep_2.foo' => 'c',
'rep_2.bar' => 'c',
'rep_2.baz' => 'c',
count => 2,
} );
ok( $form->submitted_and_valid );
is_deeply(
$form->params,
{ rep_1 => {
foo => 'a',
bar => 'a',
baz => 'a',
},
rep_2 => {
foo => 'c',
bar => 'c',
baz => 'c',
},
count => 2,
} );
}
# Invalid
{
$form->process(
{ 'rep_1.foo' => 'a',
'rep_1.bar' => 'a',
'rep_1.baz' => 'a',
'rep_2.foo' => 'c',
'rep_2.bar' => 'd',
'rep_2.baz' => 'c',
count => 2,
} );
ok( !$form->submitted_and_valid );
ok( !$form->has_errors('rep_1.foo') );
ok( !$form->has_errors('rep_1.bar') );
ok( !$form->has_errors('rep_1.baz') );
ok( !$form->has_errors('rep_2.foo') );
ok( $form->has_errors('rep_2.bar') );
ok( !$form->has_errors('rep_2.baz') );
}
# Missing - Invalid
{
$form->process(
{ 'rep_1.foo' => 'a',
'rep_1.bar' => 'a',
'rep_1.baz' => 'a',
'rep_2.foo' => 'c',
count => 2,
} );
ok( !$form->submitted_and_valid );
ok( !$form->has_errors('rep_1.foo') );
ok( !$form->has_errors('rep_1.bar') );
ok( !$form->has_errors('rep_1.baz') );
ok( !$form->has_errors('rep_2.foo') );
ok( $form->has_errors('rep_2.bar') );
ok( $form->has_errors('rep_2.baz') );
}
HTML-FormFu-2.07/t/repeatable/constraints/required_not_increment_field_names.t 0000644 0001751 0001752 00000003175 13404751171 026237 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 13;
use HTML::FormFu;
use lib 't/lib';
use HTMLFormFu::TestLib;
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->load_config_file(
't/repeatable/constraints/required_not_increment_field_names.yml');
$form->get_element( { type => 'Repeatable' } )->repeat(2);
# Valid
{
$form->process(
{ foo => [ 'a', 'b' ],
bar => [ 'c', 'd' ],
count => 2,
} );
ok( $form->submitted_and_valid );
is_deeply(
$form->params,
{ foo => [ 'a', 'b' ],
bar => [ 'c', 'd' ],
count => 2,
} );
}
# Missing - Invalid
{
$form->process(
{ foo => [ '', 'b' ],
bar => [ 'c', '' ],
count => 2,
} );
ok( !$form->submitted_and_valid );
# $form->has_errors() doesn't really make sense for multiple fields with the same name
# - an error on any of those fields will return true
ok( $form->has_errors('foo') );
ok( $form->has_errors('bar') );
my $foo1 = $form->get_fields('foo')->[0];
my $foo2 = $form->get_fields('foo')->[1];
my $bar1 = $form->get_fields('bar')->[0];
my $bar2 = $form->get_fields('bar')->[1];
is( scalar @{ $foo1->get_errors }, 1 );
is( scalar @{ $foo2->get_errors }, 0 );
is( scalar @{ $bar1->get_errors }, 0 );
is( scalar @{ $bar2->get_errors }, 1 );
like( $foo1, qr/This field is required/ );
unlike( $foo2, qr/This field is required/ );
unlike( $bar1, qr/This field is required/ );
like( $bar2, qr/This field is required/ );
}
HTML-FormFu-2.07/t/repeatable/constraints/required.yml 0000644 0001751 0001752 00000000343 13404751171 021315 0 ustar carl carl ---
elements:
- type: Hidden
name: count
- type: Repeatable
nested_name: rep
increment_field_names: 1
counter_name: count
elements:
- name: foo
- name: bar
constraints:
- Required
HTML-FormFu-2.07/t/repeatable/constraints/attach_errors_to.yml 0000644 0001751 0001752 00000000515 13404751171 023040 0 ustar carl carl ---
elements:
- type: Hidden
name: count
- type: Repeatable
nested_name: rep
counter_name: count
elements:
- name: foo
constraints:
- type: AllOrNone
others:
rep.bar
attach_errors_to:
- rep.foo
- rep.bar
- name: bar
HTML-FormFu-2.07/t/repeatable/constraints/when.t 0000644 0001751 0001752 00000001302 13404751171 020074 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
use lib 't/lib';
use HTMLFormFu::TestLib;
my $form = HTML::FormFu->new;
$form->load_config_file('t/repeatable/constraints/when.yml');
$form->get_element( { type => 'Repeatable' } )->repeat(1);
# Valid
{
$form->process(
{ 'rep_1.foo' => 'a',
'rep_1.bar' => 'b',
count => 1,
} );
ok( $form->submitted_and_valid );
}
# Missing - Invalid
{
$form->process(
{ 'rep_1.foo' => 'a',
'rep_1.bar' => '',
count => 1,
} );
ok( $form->has_errors );
ok( $form->valid('rep_1.foo') );
ok( !$form->valid('rep_1.bar') );
}
HTML-FormFu-2.07/t/repeatable/constraints/equal.yml 0000644 0001751 0001752 00000000507 13404751171 020606 0 ustar carl carl ---
elements:
- type: Hidden
name: count
- type: Repeatable
nested_name: rep
increment_field_names: 1
counter_name: count
elements:
- name: foo
constraints:
- type: Equal
others:
- bar
- 'rep.baz'
- name: bar
- name: baz
HTML-FormFu-2.07/t/repeatable/constraints/required_not_nested.t 0000644 0001751 0001752 00000002506 13404751171 023204 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 11;
use HTML::FormFu;
use lib 't/lib';
use HTMLFormFu::TestLib;
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->load_config_file('t/repeatable/constraints/required_not_nested.yml');
$form->get_element( { type => 'Repeatable' } )->repeat(2);
# Valid
{
$form->process(
{ foo_1 => 'a',
bar_1 => 'b',
foo_2 => 'c',
bar_2 => 'd',
count => 2,
} );
ok( $form->submitted_and_valid );
is_deeply(
$form->params,
{ foo_1 => 'a',
bar_1 => 'b',
foo_2 => 'c',
bar_2 => 'd',
count => 2,
} );
}
# Missing - Invalid
{
$form->process(
{ bar_1 => 'b',
foo_2 => 'c',
count => 2,
} );
ok( !$form->submitted_and_valid );
ok( $form->has_errors('foo_1') );
ok( !$form->has_errors('bar_1') );
ok( !$form->has_errors('foo_2') );
ok( $form->has_errors('bar_2') );
like( $form->get_field('foo_1'), qr/This field is required/ );
unlike( $form->get_field('bar_1'), qr/This field is required/ );
unlike( $form->get_field('foo_2'), qr/This field is required/ );
like( $form->get_field('bar_2'), qr/This field is required/ );
}
HTML-FormFu-2.07/t/repeatable/clone.yml 0000644 0001751 0001752 00000000365 13404751171 016232 0 ustar carl carl ---
auto_fieldset: 1
elements:
- type: Hidden
name: count
- type: Repeatable
nested_name: rep
increment_field_names: 1
counter_name: count
elements:
- name: foo
- name: bar
constraints:
- Required
HTML-FormFu-2.07/t/repeatable/clone.t 0000644 0001751 0001752 00000003515 13404751171 015674 0 ustar carl carl use strict;
use warnings;
use Scalar::Util qw/ refaddr /;
use Test::More tests => 19;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->load_config_file('t/repeatable/clone.yml');
$form->get_all_element( { type => 'Repeatable' } )->repeat(2);
$form->process(
{ 'rep_1.foo' => 'a',
'rep_1.bar' => '',
'rep_2.foo' => '',
'rep_2.bar' => 'd',
count => 2,
} );
isa_ok( $form, 'HTML::FormFu' );
# fieldset
my $fs = $form->get_element;
isa_ok( $fs, 'HTML::FormFu::Element::Fieldset' );
is( refaddr( $fs->parent ), refaddr($form), );
# hidden field
my $hidden = $form->get_field('count');
isa_ok( $hidden, 'HTML::FormFu::Element::Hidden' );
is( refaddr( $hidden->parent ), refaddr($fs), );
# repeatable
my $rep = $fs->get_element( { type => 'Repeatable' } );
isa_ok( $rep, 'HTML::FormFu::Element::Repeatable' );
is( refaddr( $rep->parent ), refaddr($fs), );
# block 1
{
my $block = $rep->get_elements->[0];
my $foo = $block->get_fields->[0];
is( refaddr( $foo->parent ), refaddr($block), );
is( refaddr( $foo->get_constraint->parent ), refaddr($foo), );
ok( !$foo->get_error );
my $bar = $block->get_fields->[1];
is( refaddr( $bar->parent ), refaddr($block), );
is( refaddr( $bar->get_constraint->parent ), refaddr($bar), );
is( refaddr( $bar->get_error->parent ), refaddr($bar), );
}
# block 2
{
my $block = $rep->get_elements->[1];
my $foo = $block->get_fields->[0];
is( refaddr( $foo->parent ), refaddr($block), );
is( refaddr( $foo->get_constraint->parent ), refaddr($foo), );
is( refaddr( $foo->get_error->parent ), refaddr($foo), );
my $bar = $block->get_fields->[1];
is( refaddr( $bar->parent ), refaddr($block), );
is( refaddr( $bar->get_constraint->parent ), refaddr($bar), );
ok( !$bar->get_error );
}
HTML-FormFu-2.07/t/elements-file_post.t 0000644 0001751 0001752 00000006315 13404751171 016267 0 ustar carl carl use strict;
use warnings;
use Test::More;
use HTML::FormFu;
use IO::File;
eval "use CGI";
if ($@) {
plan skip_all => 'CGI required';
die $!;
}
plan tests => 25;
# Copied from CGI.pm - http://search.cpan.org/perldoc?CGI
%ENV = (
%ENV,
'SCRIPT_NAME' => '/test.cgi',
'SERVER_NAME' => 'perl.org',
'HTTP_CONNECTION' => 'TE, close',
'REQUEST_METHOD' => 'POST',
'SCRIPT_URI' => 'http://www.perl.org/test.cgi',
'SCRIPT_FILENAME' => '/home/usr/test.cgi',
'SERVER_SOFTWARE' => 'Apache/1.3.27 (Unix) ',
'HTTP_TE' => 'deflate,gzip;q=0.3',
'QUERY_STRING' => '',
'REMOTE_PORT' => '1855',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)',
'SERVER_PORT' => '80',
'REMOTE_ADDR' => '127.0.0.1',
'CONTENT_TYPE' => 'multipart/form-data; boundary=xYzZY',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'PATH' => '/usr/local/bin:/usr/bin:/bin',
'REQUEST_URI' => '/test.cgi',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SCRIPT_URL' => '/test.cgi',
'SERVER_ADDR' => '127.0.0.1',
'DOCUMENT_ROOT' => '/home/develop',
'HTTP_HOST' => 'www.perl.org'
);
my $io = new IO::File 't/elements-file_post.txt';
$io->binmode;
local *STDIN = $io;
my $q = CGI->new();
my $form = HTML::FormFu->new(
{ action => 'http://www.perl.org/test.cgi',
elements => [
{ type => 'Text', name => 'multiple' },
{ type => 'File', name => 'multiple' },
{ type => 'File', name => 'multiple' },
{ type => 'File', name => 'hello_world' },
{ type => 'File', name => 'does_not_exist_gif' },
{ type => 'File', name => '100x100_gif' },
{ type => 'File', name => '300x300_gif' },
],
} );
$form->process($q);
{
my $multiple = $form->params->{multiple};
is( @$multiple, 3 );
my ( $m1, $m2, $m3 ) = @$multiple;
ok( !ref $m1 );
is( $m1, 'foo' );
isa_ok( $m2, 'HTML::FormFu::Upload' );
is( $m2->filename, 'one.txt' );
is( $m2->headers->content_length, 4 );
is( $m2->headers->content_type, 'text/plain' );
is( $m2->slurp, "One\n" );
# new Cat-compatable methods
is( $m2->size, 4 );
is( $m2->type, 'text/plain' );
isa_ok( $m3, 'HTML::FormFu::Upload' );
is( $m3->filename, 'two.txt' );
is( $m3->headers->content_length, 5 );
is( $m3->headers->content_type, 'text/plain' );
is( $m3->slurp, "Two!\n" );
}
{
my $value = $form->params->{hello_world};
isa_ok( $value, 'HTML::FormFu::Upload' );
is( $value->filename, 'hello_world.txt' );
is( $value->headers->content_length, 13 );
is( $value->headers->content_type, 'text/plain' );
is( $value->slurp, "Hello World!\n" );
}
{
my $value = $form->params->{does_not_exist_gif};
isa_ok( $value, 'HTML::FormFu::Upload' );
is( $value->filename, 'does_not_exist.gif' );
is( $value->headers->content_length, undef );
is( $value->headers->content_type, 'application/octet-stream' );
is( $value->slurp, '' );
}
HTML-FormFu-2.07/t/force_errors/ 0000775 0001751 0001752 00000000000 13404751171 014773 5 ustar carl carl HTML-FormFu-2.07/t/force_errors/integer.t 0000644 0001751 0001752 00000001321 13404751171 016610 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 6;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('Integer')->force_errors(1);
$form->element('Text')->name('bar')->constraint('Integer')->force_errors(1);
{
$form->process(
{ foo => '12',
bar => "12\n",
} );
ok( !$form->has_errors('foo') );
ok( $form->has_errors('bar') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
}
{
$form->process(
{ foo => 0,
bar => "0\n",
} );
ok( !$form->has_errors('foo') );
ok( $form->has_errors('bar') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
}
HTML-FormFu-2.07/t/force_errors/equal.t 0000644 0001751 0001752 00000004621 13404751171 016270 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 31;
use HTML::FormFu;
my $form = HTML::FormFu->new->force_errors(1);
$form->element('Text')->name('foo')->constraint('Equal')
->others( [ 'bar', 'baz' ] );
$form->element('Text')->name('bar');
$form->element('Text')->name('baz');
# valid
{
$form->process(
{ foo => 'yada',
bar => 'yada',
baz => 'yada',
} );
ok( $form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( !$form->has_errors('bar') );
ok( !$form->has_errors('baz') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'bar', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } );
}
# valid
{
$form->process(
{ foo => '',
bar => '',
baz => '',
} );
ok( $form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( !$form->has_errors('bar') );
ok( !$form->has_errors('baz') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'bar', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } );
}
# valid
{
$form->process(
{ foo => [ 'a', 'b' ],
bar => [ 'a', 'b' ],
baz => [ 'b', 'a' ],
} );
ok( $form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( !$form->has_errors('bar') );
ok( !$form->has_errors('baz') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'bar', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } );
}
# invalid
{
$form->process(
{ foo => 'yada',
bar => 'yada',
baz => 'x',
} );
ok( !$form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( !$form->has_errors('bar') );
ok( $form->has_errors('baz') );
ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } );
}
# invalid
{
$form->process(
{ foo => [ 'a', 'b' ],
bar => [ 'a', 'b' ],
baz => ['a'],
} );
ok( !$form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( !$form->has_errors('bar') );
ok( $form->has_errors('baz') );
ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } );
}
HTML-FormFu-2.07/t/force_errors/callbackonce.t 0000644 0001751 0001752 00000001774 13404751171 017570 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 9;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('CallbackOnce')
->force_errors(1)->callback(
sub {
return $_[0] eq 'a';
} );
$form->element('Text')->name('bar')->constraint('CallbackOnce')
->force_errors(1)->callback(
sub {
return $_[0] eq 'b';
} );
# valid
{
$form->process(
{ foo => 'a',
bar => 'b',
} );
ok( $form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( !$form->has_errors('bar') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'bar', forced => 1 } ) } );
}
# invalid
{
$form->process(
{ foo => 'a',
bar => 'c',
} );
ok( !$form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( $form->has_errors('bar') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
}
HTML-FormFu-2.07/t/force_errors/dependon.t 0000644 0001751 0001752 00000002215 13404751171 016752 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 13;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('DependOn')
->others( [qw/ bar baz /] )->force_errors(1);
$form->element('Text')->name('bar');
$form->element('Text')->name('baz');
# valid
{
$form->process(
{ foo => 1,
bar => 'a',
baz => [2],
} );
ok( $form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( !$form->has_errors('bar') );
ok( !$form->has_errors('baz') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'bar', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } );
}
# invalid
{
$form->process(
{ foo => 1,
bar => '',
baz => 2,
} );
ok( !$form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( $form->has_errors('bar') );
ok( !$form->has_errors('baz') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } );
}
HTML-FormFu-2.07/t/force_errors/allornone.t 0000644 0001751 0001752 00000003510 13404751171 017146 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 24;
use HTML::FormFu;
my $form = HTML::FormFu->new->indicator( sub {1} );
$form->element('Text')->name('foo')->constraint('AllOrNone')
->others( [qw/ bar baz bif /] )->force_errors(1);
$form->element('Text')->name('bar');
$form->element('Text')->name('baz');
$form->element('Text')->name('bif');
# Valid
{
$form->process(
{ foo => 1,
bar => 'a',
baz => [2],
bif => [ 3, 4 ],
} );
ok( $form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( !$form->has_errors('bar') );
ok( !$form->has_errors('baz') );
ok( !$form->has_errors('bif') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'bar', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'bif', forced => 1 } ) } );
}
# Valid
{
$form->process( {} );
ok( $form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( !$form->has_errors('bar') );
ok( !$form->has_errors('baz') );
ok( !$form->has_errors('bif') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'bar', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'baz', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'bif', forced => 1 } ) } );
}
# Invalid
{
$form->process(
{ foo => 1,
bar => '',
baz => [2],
bif => [ 3, 4 ],
} );
ok( !$form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( $form->has_errors('bar') );
ok( !$form->has_errors('baz') );
ok( !$form->has_errors('bif') );
ok( @{ $form->get_errors( { name => 'bar', forced => 1 } ) } );
}
HTML-FormFu-2.07/t/force_errors/minmaxfields.t 0000644 0001751 0001752 00000004063 13404751171 017641 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 26;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('MinMaxFields')
->others( [qw/ bar baz boz/] )->min(1)->max(2)->force_errors(1);
$form->element('Text')->name('bar');
$form->element('Text')->name('baz');
$form->element('Text')->name('boz');
# valid
{
$form->process(
{ foo => 1,
bar => '',
baz => [2],
boz => '',
} );
ok( !$form->has_errors, 'no real errors' );
ok( !$form->has_errors('foo') );
ok( !$form->has_errors('bar') );
ok( !$form->has_errors('baz') );
ok( !$form->has_errors('boz') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
ok( !@{ $form->get_errors( { name => 'bar', forced => 1 } ) } );
ok( !@{ $form->get_errors( { name => 'baz', forced => 1 } ) } );
ok( !@{ $form->get_errors( { name => 'boz', forced => 1 } ) } );
}
# valid
{
$form->process(
{ foo => 1,
bar => '',
baz => '',
boz => '',
} );
ok( !$form->has_errors, 'no real errors' );
ok( !$form->has_errors('foo') );
ok( !$form->has_errors('bar') );
ok( !$form->has_errors('baz') );
ok( !$form->has_errors('boz') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
ok( !@{ $form->get_errors( { name => 'bar', forced => 1 } ) } );
ok( !@{ $form->get_errors( { name => 'baz', forced => 1 } ) } );
ok( !@{ $form->get_errors( { name => 'boz', forced => 1 } ) } );
}
# invalid
{
$form->process(
{ foo => 1,
bar => '',
baz => 2,
boz => '22',
} );
ok( $form->has_errors );
ok( $form->has_errors('foo') );
ok( !$form->has_errors('bar') );
ok( !$form->has_errors('baz') );
ok( !$form->has_errors('boz') );
ok( !@{ $form->get_errors( { name => 'bar', forced => 1 } ) } );
ok( !@{ $form->get_errors( { name => 'baz', forced => 1 } ) } );
ok( !@{ $form->get_errors( { name => 'boz', forced => 1 } ) } );
}
HTML-FormFu-2.07/t/force_errors/force_errors.t 0000644 0001751 0001752 00000002043 13404751171 017647 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 15;
use HTML::FormFu;
my $form = HTML::FormFu->new->force_errors(1);
$form->element('Text')->name('foo')->constraint('Integer');
$form->element('Text')->name('bar')->constraint('Integer');
{
$form->process(
{ foo => '1',
bar => '0',
} );
ok( !$form->has_errors, 'has no real errors' );
ok( !$form->has_errors('foo') );
ok( !$form->has_errors('bar') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
ok( @{ $form->get_errors( { name => 'bar', forced => 1 } ) } );
ok( $form->valid('foo') );
ok( $form->valid('bar') );
ok( $form->submitted_and_valid );
}
{
$form->process(
{ foo => 0,
bar => "0\n",
} );
ok( $form->has_errors );
ok( !$form->has_errors('foo') );
ok( $form->has_errors('bar') );
ok( @{ $form->get_errors( { name => 'foo', forced => 1 } ) } );
ok( $form->valid('foo') );
ok( !$form->valid('bar') );
ok( !$form->submitted_and_valid );
}
HTML-FormFu-2.07/t/05_repeated_render.t 0000644 0001751 0001752 00000000715 13404751171 016123 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 2;
use HTML::FormFu;
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->load_config_file('t/04basic.yml');
# check output is still exactly the same after rendering again
{
my $html = "$form";
is( $html, "$form" );
}
# and after submitted form
{
$form->process( { age => 'abc', } );
my $html = "$form";
is( $html, "$form" );
}
HTML-FormFu-2.07/t/constraints/ 0000775 0001751 0001752 00000000000 13404751171 014650 5 ustar carl carl HTML-FormFu-2.07/t/constraints/regex.t 0000644 0001751 0001752 00000001377 13404751171 016155 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 8;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo');
$form->element('Text')->name('bar');
$form->constraint('Regex');
# Valid
{
$form->process(
{ foo => 'aaa',
bar => 'bbbbbbb',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
}
# "0" is valid
{
$form->process(
{ foo => 0,
bar => 2,
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'foo valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
}
HTML-FormFu-2.07/t/constraints/constraint_when_default_empty_value.t 0000644 0001751 0001752 00000001631 13404751171 024357 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 8;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->load_config_file(
't/constraints/constraint_when_default_empty_value.yml');
# valid - foo Checkbox missing - bar is required
{
$form->process( { bar => '42', } );
ok( $form->submitted_and_valid );
is( $form->param_value('bar'), 42 );
}
# valid - foo Checkbox present - bar optional
{
$form->process( { foo => '1', } );
ok( $form->submitted_and_valid );
is( $form->param_value('foo'), 1 );
}
# valid - foo Checkbox present - bar optional
{
$form->process(
{ foo => '1',
bar => '42',
} );
ok( $form->submitted_and_valid );
is( $form->param_value('foo'), 1 );
is( $form->param_value('bar'), 42 );
}
# invalid - foo Checkbox missing - bar required
{
$form->process( { bar => '', } );
ok( !$form->submitted_and_valid );
}
HTML-FormFu-2.07/t/constraints/file_size.yml 0000644 0001751 0001752 00000000432 13404751171 017341 0 ustar carl carl ---
action: 'http://www.perl.org/test.cgi'
elements:
- type: File
name: hello_world
constraints:
- type: File::Size
min: 1
max: 15
- type: File
name: does_not_exist_gif
constraints:
- type: File::Size
min: 1
max: 15
HTML-FormFu-2.07/t/constraints/constraint_other_siblings_not.t 0000644 0001751 0001752 00000004424 13404751171 023176 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 24;
use HTML::FormFu;
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->load_config_file('t/constraints/constraint_other_siblings_not.yml');
# Valid
{
$form->process(
{ foo => 'yada',
bar => 'boba',
baz => 'sith',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('bar'), 'baz valid' );
}
# Valid
{
$form->process(
{ foo => '',
bar => '',
baz => '',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('baz'), 'baz valid' );
}
# Valid
{
$form->process(
{ foo => '',
bar => 'yada',
baz => 'boba',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('baz'), 'baz valid' );
}
# Valid
{
$form->process(
{ foo => 'yada',
bar => '',
baz => '',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('baz'), 'baz valid' );
}
# Valid
{
$form->process(
{ foo => '',
bar => 'yada',
baz => '',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('baz'), 'baz valid' );
}
# Invalid
{
$form->process(
{ foo => 'yada',
bar => 'yada',
baz => 'x',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'bar not valid' );
ok( $form->valid('baz'), 'baz valid' );
}
# Invalid
{
$form->process(
{ foo => 'yada',
bar => 'x',
baz => 'yada',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( !$form->valid('baz'), 'baz not valid' );
}
# Invalid
{
$form->process(
{ foo => 'yada',
bar => 'yada',
baz => 'yada',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'bar not valid' );
ok( !$form->valid('baz'), 'baz not valid' );
}
HTML-FormFu-2.07/t/constraints/file_maxsize.yml 0000644 0001751 0001752 00000000230 13404751171 020043 0 ustar carl carl ---
action: 'http://www.perl.org/test.cgi'
elements:
- type: File
name: hello_world
constraints:
- type: File::MaxSize
max: 15
HTML-FormFu-2.07/t/constraints/minmaxfields_with_filter_split.t 0000644 0001751 0001752 00000001510 13404751171 023323 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 7;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/minmaxfields_with_filter_split.yml');
# Valid
{
$form->process(
{ foo => '',
bar => '',
baz => '',
} );
ok( !$form->has_errors );
$form->process(
{ foo => '1',
bar => '',
baz => '',
} );
ok( !$form->has_errors );
$form->process(
{ foo => '1,2',
bar => '',
baz => '',
} );
ok( !$form->has_errors );
}
# Invalid
{
$form->process(
{ foo => 1,
bar => '',
baz => 2,
} );
ok( $form->has_errors );
ok( !$form->valid('foo') );
ok( $form->valid('bar') );
ok( $form->valid('baz') );
}
HTML-FormFu-2.07/t/constraints/equal_not.t 0000644 0001751 0001752 00000003032 13404751171 017020 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 15;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('Equal')
->others( [ 'bar', 'baz' ] )->not(1);
$form->element('Text')->name('bar');
$form->element('Text')->name('baz');
# Valid
{
$form->process(
{ foo => 'yada',
bar => 'boba',
baz => 'sith',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('bar'), 'baz valid' );
}
# Valid
{
$form->process(
{ foo => '',
bar => '',
baz => '',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('baz'), 'baz valid' );
}
# Valid
{
$form->process(
{ foo => '',
bar => 'yada',
baz => 'boba',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('baz'), 'baz valid' );
}
# Valid
{
$form->process(
{ foo => '',
bar => 'yada',
baz => '',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('baz'), 'baz valid' );
}
# Invalid
{
$form->process(
{ foo => 'yada',
bar => 'yada',
baz => 'x',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'bar not valid' );
ok( $form->valid('baz'), 'baz valid' );
}
HTML-FormFu-2.07/t/constraints/integer.t 0000644 0001751 0001752 00000001465 13404751171 016476 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 8;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo');
$form->element('Text')->name('bar');
$form->constraint('Integer');
# Valid
# linebreak not valid
{
$form->process(
{ foo => '12',
bar => "12\n",
} );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'bar valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( !grep { $_ eq 'bar' } $form->valid );
}
# "0" is valid
# linebreak not valid
{
$form->process(
{ foo => 0,
bar => "0\n",
} );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'foo valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( !grep { $_ eq 'bar' } $form->valid );
}
HTML-FormFu-2.07/t/constraints/required_only_on_reps.t 0000644 0001751 0001752 00000003220 13404751171 021436 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
use lib 't/lib';
use HTMLFormFu::TestLib;
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/required_only_on_reps.yml');
# Valid
{
$form->process(
{ foo_1 => 'a',
bar_1 => '',
buz_1 => 'g',
moo_1 => 'j',
foo_2 => '',
bar_2 => 'e',
buz_2 => '',
moo_2 => 'k',
foo_3 => '',
bar_3 => '',
buz_3 => 'i',
moo_3 => 'l',
count => 3,
} );
ok( $form->submitted_and_valid );
}
# Valid
{
$form->process(
{ foo_1 => 'a',
bar_1 => 'd',
buz_1 => 'g',
moo_1 => 'j',
foo_2 => 'b',
bar_2 => 'e',
buz_2 => 'h',
moo_2 => 'k',
foo_3 => 'c',
bar_3 => 'f',
buz_3 => 'i',
moo_3 => 'l',
count => 3,
} );
ok( $form->submitted_and_valid );
}
# Missing - Invalid
{
$form->process(
{ foo_1 => '',
bar_1 => '',
buz_1 => '',
moo_1 => '',
foo_2 => '',
bar_2 => '',
buz_2 => '',
moo_2 => 'k',
foo_3 => '',
bar_3 => '',
buz_3 => 'i',
moo_3 => '',
count => 3,
} );
ok( !$form->submitted_and_valid );
is_deeply(
[ $form->has_errors ],
[ qw/
foo_1
buz_1
moo_1
bar_2
moo_3
/
] );
}
HTML-FormFu-2.07/t/constraints/required_file.t 0000644 0001751 0001752 00000003151 13404751171 017652 0 ustar carl carl use strict;
use warnings;
use Test::More;
use HTML::FormFu;
eval "use CGI";
if ($@) {
plan skip_all => 'CGI required';
die $!;
}
plan tests => 4;
# Copied from CGI.pm - http://search.cpan.org/perldoc?CGI
%ENV = (
%ENV,
'SCRIPT_NAME' => '/test.cgi',
'SERVER_NAME' => 'perl.org',
'HTTP_CONNECTION' => 'TE, close',
'REQUEST_METHOD' => 'POST',
'SCRIPT_URI' => 'http://www.perl.org/test.cgi',
'SCRIPT_FILENAME' => '/home/usr/test.cgi',
'SERVER_SOFTWARE' => 'Apache/1.3.27 (Unix) ',
'HTTP_TE' => 'deflate,gzip;q=0.3',
'QUERY_STRING' => '',
'REMOTE_PORT' => '1855',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)',
'SERVER_PORT' => '80',
'REMOTE_ADDR' => '127.0.0.1',
'CONTENT_TYPE' => 'multipart/form-data; boundary=xYzZY',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'PATH' => '/usr/local/bin:/usr/bin:/bin',
'REQUEST_URI' => '/test.cgi',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SCRIPT_URL' => '/test.cgi',
'SERVER_ADDR' => '127.0.0.1',
'DOCUMENT_ROOT' => '/home/develop',
'HTTP_HOST' => 'www.perl.org'
);
my $q;
{
my $file = 't/elements/file_post.txt';
local *STDIN;
open STDIN, "<", $file
or die "missing test file $file";
binmode STDIN;
$q = CGI->new;
}
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/required_file.yml');
$form->process($q);
ok( $form->submitted );
ok( !$form->has_errors );
ok( $form->valid('multiple') );
ok( $form->valid('hello_world') );
HTML-FormFu-2.07/t/constraints/required.t 0000644 0001751 0001752 00000002522 13404751171 016654 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 16;
use HTML::FormFu;
use lib 't/lib';
use HTMLFormFu::TestLib;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo');
$form->element('Text')->name('bar');
$form->constraint('Required');
# Valid
{
$form->process(
{ foo => 'yada',
bar => 'nada',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
}
# Missing - Invalid
{
$form->process( { foo => 'yada', } );
ok( $form->valid('foo'), 'foo value' );
ok( !$form->valid('bar'), 'bar not valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( !grep { $_ eq 'bar' } $form->valid );
}
# Empty string - Invalid
{
$form->process(
{ foo => '',
bar => 2,
} );
ok( !$form->valid('foo'), 'foo not valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( !grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
}
# "0" is valid
{
$form->process(
{ foo => 0,
bar => 2,
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'foo valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
}
HTML-FormFu-2.07/t/constraints/singlevalue.t 0000644 0001751 0001752 00000000740 13404751171 017352 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 1;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo');
$form->element('Text')->name('bar');
$form->element('Text')->name('baz');
$form->element('Text')->name('bif');
$form->element('Text')->name('bom');
$form->constraint('SingleValue');
$form->process(
{ foo => 1,
bar => '',
baz => [2],
bif => [ 3, 4 ],
} );
is_deeply( [ $form->has_errors ], ['bif'] );
HTML-FormFu-2.07/t/constraints/minrange.t 0000644 0001751 0001752 00000001145 13404751171 016634 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('MinRange')->min(3);
$form->element('Text')->name('bar')->constraint('MinRange')->min(3);
# Valid
{
$form->process(
{ foo => 3,
bar => 4,
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => 1,
bar => 6,
} );
ok( !$form->valid('foo'), 'foo not valid' );
ok( $form->valid('bar'), 'bar not valid' );
}
HTML-FormFu-2.07/t/constraints/constraint_when_any_true_value.yml 0000644 0001751 0001752 00000000202 13404751171 023672 0 ustar carl carl ---
elements:
- name: foo
- name: bar
constraints:
- type: Required
when:
field: foo
HTML-FormFu-2.07/t/constraints/maxlength.t 0000644 0001751 0001752 00000001332 13404751171 017021 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 5;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('MaxLength')->max(5);
$form->element('Text')->name('bar')->constraint('MaxLength')->max(5);
# Valid
{
$form->process(
{ foo => 'abc',
bar => 'abcde',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => 'ab',
bar => 'abcdef',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'bar not valid' );
is( $form->get_error('bar')->message,
'Must not be longer than 5 characters long' );
}
HTML-FormFu-2.07/t/constraints/constraint_when_any_field.yml 0000644 0001751 0001752 00000000532 13404751171 022610 0 ustar carl carl ---
elements:
- name: a
constraints:
- type: MinMaxFields
min: 1
max: 2
others:
- 'b'
- 'c'
- 'd'
when:
any_field:
- 'a'
- 'b'
- 'c'
- 'd'
- name: b
- name: c
- name: d
HTML-FormFu-2.07/t/constraints/number.t 0000644 0001751 0001752 00000001364 13404751171 016327 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 8;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo');
$form->element('Text')->name('bar');
$form->constraint('Number');
# Valid
{
$form->process(
{ foo => 1,
bar => 2,
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
}
# "0" is valid
{
$form->process(
{ foo => 0,
bar => 2,
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'foo valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
}
HTML-FormFu-2.07/t/constraints/callback.t 0000644 0001751 0001752 00000001362 13404751171 016571 0 ustar carl carl use strict;
use warnings;
# base the package name on the test file path
# to stop 'redefined' warnings under Test::Aggregate::Nested
package My::Constraints::Callback;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('Callback')->callback( \&cb );
$form->element('Text')->name('bar')->constraint('Callback')
->callback("My::Constraints::Callback::cb");
sub cb {
my $value = shift;
::ok(1) if grep { $value eq $_ ? 1 : 0 } qw/ 1 0 a /;
return 1;
}
package main;
use Test::More tests => 5;
# Valid
{
$form->process(
{ foo => 1,
bar => [ 0, 'a', 'b' ],
} );
::ok( $form->valid('foo'), 'foo valid' );
::ok( $form->valid('bar'), 'bar valid' );
}
HTML-FormFu-2.07/t/constraints/equal.t 0000644 0001751 0001752 00000004131 13404751171 016141 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 21;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('Equal')
->others( [ 'bar', 'baz' ] );
$form->element('Text')->name('bar');
$form->element('Text')->name('baz');
# Valid
{
$form->process(
{ foo => 'yada',
bar => 'yada',
baz => 'yada',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('baz'), 'baz valid' );
}
# Valid
{
$form->process(
{ foo => '',
bar => '',
baz => '',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('baz'), 'baz valid' );
}
# Valid
{
$form->process(
{ foo => [ 'a', 'b' ],
bar => [ 'a', 'b' ],
baz => [ 'b', 'a' ],
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('baz'), 'baz valid' );
}
# Invalid
{
$form->process(
{ foo => 'yada',
bar => 'yada',
baz => 'x',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( !$form->valid('baz'), 'baz not valid' );
}
# Invalid
{
$form->process(
{ foo => 'yada',
bar => 'yada',
baz => '',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( !$form->valid('baz'), 'baz not valid' );
}
# Invalid
{
$form->process(
{ foo => '',
bar => 'yada',
baz => 'yada',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'bar not valid' );
ok( !$form->valid('baz'), 'baz not valid' );
}
# Invalid
{
$form->process(
{ foo => [ 'a', 'b' ],
bar => [ 'a', 'b' ],
baz => ['a'],
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( !$form->valid('baz'), 'baz not valid' );
}
HTML-FormFu-2.07/t/constraints/email.t 0000644 0001751 0001752 00000002212 13404751171 016117 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 5;
use HTML::FormFu;
{
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('Email');
# Valid
{
$form->process( { foo => 'cfranks@cpan.org', } );
ok( $form->valid('foo'), 'foo valid' );
}
# Invalid
{
$form->process( { foo => 'cfranks@cpan', } );
ok( $form->has_errors('foo'), 'foo has errors' );
}
# Email with IP valid by default
{
$form->process( { foo => 'rjbs@[1.2.3.4]' } );
ok( $form->valid('foo'), 'foo valid - ip ok by default' );
}
}
{
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('Email')
->options( { 'allow_ip' => 0 } );
# Email with IP invalid when turned off
{
$form->process( { foo => 'rjbs@[1.2.3.4]' } );
ok( $form->has_errors('foo'),
'foo valid - ip invalid when turned off' );
}
# Email with space - invalid
{
$form->process( { foo => 'Valid+except @space.org' } );
ok( $form->has_errors('foo'), 'email with space is invalid' );
}
}
HTML-FormFu-2.07/t/constraints/constraint_when.t 0000644 0001751 0001752 00000007544 13404751171 020252 0 ustar carl carl use strict;
use warnings;
package CB;
# Just to test we can provide strings as callbacks
# used by "coo2" field
sub when_string_callback { return 1 }
package main;
use Test::More tests => 49;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/constraint_when.yml');
# When triggered depending on callback
my $when_closure = sub {
my $params = shift;
return 1 if defined $params->{foo} && $params->{foo} eq '1';
};
$form->get_element('coo')
->get_constraint->when( { callback => $when_closure } );
# Valid
{
$form->process(
{ foo => 1,
bar => 'bar_value',
moo => undef,
zoo => 'zoo_value',
coo => 4,
coo2 => 5,
} );
# if 'moo' does not *exist* in process params
# it wouldn't be valid
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('moo'), 'moo valid' );
ok( $form->valid('zoo'), 'zoo valid' );
ok( $form->valid('coo'), 'coo valid' );
ok( $form->valid('coo2'), 'coo2 valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
ok( grep { $_ eq 'moo' } $form->valid );
ok( grep { $_ eq 'zoo' } $form->valid );
ok( grep { $_ eq 'coo' } $form->valid );
ok( grep { $_ eq 'coo2' } $form->valid );
$form->process(
{ foo => 2,
bar => undef,
moo => 'moo_value',
zoo => 'zoo_value',
coo => 'not_a_number',
} );
# if 'bar' does not *exist* in process params
# it wouldn't be valid
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('moo'), 'moo valid' );
ok( $form->valid('zoo'), 'zoo valid' );
ok( $form->valid('coo'), 'coo valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
ok( grep { $_ eq 'moo' } $form->valid );
ok( grep { $_ eq 'zoo' } $form->valid );
ok( grep { $_ eq 'coo' } $form->valid );
$form->process(
{ foo => 5,
bar => undef,
moo => undef,
zoo => undef,
coo => undef,
} );
# if 'bar' does not *exist* in process params
# it wouldn't be valid
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('moo'), 'moo valid' );
ok( $form->valid('zoo'), 'zoo valid' );
ok( $form->valid('coo'), 'coo valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
ok( grep { $_ eq 'moo' } $form->valid );
ok( grep { $_ eq 'zoo' } $form->valid );
ok( grep { $_ eq 'coo' } $form->valid );
}
# Invalid
{
$form->process(
{ foo => 1,
moo => undef,
coo => 'not_a_number',
} );
ok( $form->has_errors );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'bar not valid' );
ok( $form->valid('moo'), 'moo valid' );
ok( !$form->valid('zoo'), 'zoo not valid' );
ok( !$form->valid('coo'), 'coo not valid' );
$form->process(
{ foo => 'false value',
bar => undef,
moo => undef,
zoo => 'zoo_value',
coo => 'not_a_number',
} );
# if 'bar' and 'moo' does not *exist* in process params
# it wouldn't be valid
ok( $form->has_errors );
ok( !$form->valid('foo'), 'foo not valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('moo'), 'moo valid' );
ok( $form->valid('zoo'), 'zoo valid' );
ok( $form->valid('coo'), 'coo valid' );
ok( !grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
ok( grep { $_ eq 'moo' } $form->valid );
ok( grep { $_ eq 'zoo' } $form->valid );
ok( grep { $_ eq 'coo' } $form->valid );
}
HTML-FormFu-2.07/t/constraints/autoset_group.t 0000644 0001751 0001752 00000001337 13404751171 017737 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 2;
use HTML::FormFu;
my $form = HTML::FormFu->new;
# Autoset on Select with optgroups
my $field = $form->element('Select')->name('foo');
$field->options(
[ ['item 1'],
{ value => 'item 2', },
{ group => [ ['item 3'], { value => 'item 4', } ], },
['item 5'],
{ group => [ { value => 'item 6', }, ['item 7'], ], },
] );
$field->constraint('AutoSet');
# Valid
{
$form->process( { foo => 'item 6', } );
# Constraint set has 7 values
is_deeply(
$form->get_constraint->set,
[ 'item 1', 'item 2', 'item 3', 'item 4', 'item 5', 'item 6',
'item 7'
],
);
ok( $form->valid('foo') );
}
HTML-FormFu-2.07/t/constraints/printable.t 0000644 0001751 0001752 00000001146 13404751171 017015 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo');
$form->element('Text')->name('bar');
$form->constraint('Printable');
# Valid
{
$form->process(
{ foo => 'aaa',
bar => 'bbbbbbb',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => 'aaa',
bar => '日本語',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->has_errors('bar'), 'bar has errors' );
}
HTML-FormFu-2.07/t/constraints/file_minsize.yml 0000644 0001751 0001752 00000000227 13404751171 020047 0 ustar carl carl ---
action: 'http://www.perl.org/test.cgi'
elements:
- type: File
name: hello_world
constraints:
- type: File::MinSize
min: 1
HTML-FormFu-2.07/t/constraints/dependon_attach_errors_to_base.yml 0000644 0001751 0001752 00000000224 13404751171 023577 0 ustar carl carl ---
elements:
- name: foo
- name: bar
constraints:
- type: DependOn
others: foo
attach_errors_to_base: 1
HTML-FormFu-2.07/t/constraints/constraint_when_default_empty_value.yml 0000644 0001751 0001752 00000000354 13404751171 024716 0 ustar carl carl ---
elements:
- name: foo
type: Checkbox
default_empty_value: 1
- name: bar
constraints:
- type: Required
when:
field: foo
value: 1
not: 1
HTML-FormFu-2.07/t/constraints/allornone_attach_errors_to_others.yml 0000644 0001751 0001752 00000000247 13404751171 024373 0 ustar carl carl ---
elements:
- name: foo
- name: bar
constraints:
- type: AllOrNone
others: foo
attach_errors_to_others:
- foo
HTML-FormFu-2.07/t/constraints/regex_common.t 0000644 0001751 0001752 00000001176 13404751171 017522 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo');
$form->element('Text')->name('bar');
map { $_->common( [ 'URI', 'HTTP', { -scheme => 'https?' } ] ) }
$form->constraint('Regex');
{
$form->process(
{ foo => 'http://perl.org',
bar => 'ftp://perl.org',
} );
ok( $form->valid('foo') );
ok( $form->has_errors('bar') );
}
{
$form->process(
{ foo => 'https://perl.org',
bar => 'www.perl.org',
} );
ok( $form->valid('foo') );
ok( $form->has_errors('bar') );
}
HTML-FormFu-2.07/t/constraints/not_word.t 0000644 0001751 0001752 00000001124 13404751171 016664 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo');
$form->element('Text')->name('bar');
$form->constraint('Not_Word');
# Valid
{
$form->process(
{ foo => ' ',
bar => "\t",
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => 'a',
bar => "\n",
} );
ok( $form->has_errors('foo'), 'foo has_errors' );
ok( $form->valid('bar'), 'bar valid' );
}
HTML-FormFu-2.07/t/constraints/repeatable_any_not_increment_field_names.yml 0000644 0001751 0001752 00000000315 13404751171 025615 0 ustar carl carl ---
elements:
- type: Hidden
name: count
- type: Repeatable
counter_name: count
increment_field_names: 0
elements:
- name: foo
constraints:
- 'Repeatable::Any'
HTML-FormFu-2.07/t/constraints/localize.t 0000644 0001751 0001752 00000001051 13404751171 016632 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 2;
use HTML::FormFu;
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->element('Text')->name('foo');
$form->constraint('Required');
$form->constraint('MinLength')->min(3);
$form->constraint('Regex')->regex(qr/^\d+$/)
->message_loc('form_constraint_integer');
$form->process( { foo => 'a' } );
like( $form->get_field('foo'), qr/This field must be an integer/ );
like( $form->get_field('foo'), qr/Must be at least 3 characters long/ );
HTML-FormFu-2.07/t/constraints/callbackonce.t 0000644 0001751 0001752 00000001223 13404751171 017432 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('CallbackOnce')->callback(
sub {
is_deeply( \@_, [ 1, { foo => 1, bar => [ 0, 'a' ] } ] );
return 1;
} );
$form->element('Text')->name('bar')->constraint('CallbackOnce')->callback(
sub {
is_deeply( \@_, [ [ 0, 'a' ], { foo => 1, bar => [ 0, 'a' ] } ] );
return 1;
} );
# Valid
{
$form->process(
{ foo => 1,
bar => [ 0, 'a' ],
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
HTML-FormFu-2.07/t/constraints/datetime_parser.t 0000644 0001751 0001752 00000000772 13404751171 020211 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
my $foo = $form->element('Text')->name('foo');
$foo->constraint('DateTime')->parser( { strptime => '%d/%m/%Y' } );
# valid
{
$form->process( { foo => '31/12/2006' } );
ok( $form->submitted_and_valid );
is( $form->params->{foo}, '31/12/2006' );
}
# invalid
{
$form->process( { foo => '12/31/2006' } );
ok( !$form->submitted_and_valid );
ok( $form->has_errors('foo') );
}
HTML-FormFu-2.07/t/constraints/file_maxsize.t 0000644 0001751 0001752 00000003516 13404751171 017517 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 7;
use HTML::FormFu;
use CGI;
# Copied from CGI.pm - http://search.cpan.org/perldoc?CGI
%ENV = (
%ENV,
'SCRIPT_NAME' => '/test.cgi',
'SERVER_NAME' => 'perl.org',
'HTTP_CONNECTION' => 'TE, close',
'REQUEST_METHOD' => 'POST',
'SCRIPT_URI' => 'http://www.perl.org/test.cgi',
'SCRIPT_FILENAME' => '/home/usr/test.cgi',
'SERVER_SOFTWARE' => 'Apache/1.3.27 (Unix) ',
'HTTP_TE' => 'deflate,gzip;q=0.3',
'QUERY_STRING' => '',
'REMOTE_PORT' => '1855',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)',
'SERVER_PORT' => '80',
'REMOTE_ADDR' => '127.0.0.1',
'CONTENT_TYPE' => 'multipart/form-data; boundary=xYzZY',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'PATH' => '/usr/local/bin:/usr/bin:/bin',
'REQUEST_URI' => '/test.cgi',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SCRIPT_URL' => '/test.cgi',
'SERVER_ADDR' => '127.0.0.1',
'DOCUMENT_ROOT' => '/home/develop',
'HTTP_HOST' => 'www.perl.org'
);
my $q;
{
my $file = 't/elements/file_post.txt';
local *STDIN;
open STDIN, "<", $file
or die "missing test file $file";
binmode STDIN;
$q = CGI->new;
}
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->load_config_file('t/constraints/file_maxsize.yml');
$form->process($q);
{
ok( $form->submitted );
ok( !$form->has_errors('hello_world') );
ok( $form->valid('hello_world') );
}
$form->process( { hello_world => 'not a file', } );
{
ok( $form->submitted );
ok( $form->has_errors('hello_world') );
ok( !$form->valid('hello_world') );
like( "$form", qr/File-size must be no more than 15 bytes/ );
}
HTML-FormFu-2.07/t/constraints/minmaxfields_with_filter_split.yml 0000644 0001751 0001752 00000000520 13404751171 023661 0 ustar carl carl ---
elements:
- name: foo
constraints:
- type: MinMaxFields
others:
- bar
- baz
min: 0
max: 1
filters:
- type: Split
regex: ','
- name: bar
filters:
- type: Split
regex: ','
- name: baz
filters:
- type: Split
regex: ','
HTML-FormFu-2.07/t/constraints/regex_anchored.t 0000644 0001751 0001752 00000001402 13404751171 020005 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
my $foo = $form->element('Text')->name('foo');
my $bar = $form->element('Text')->name('bar');
$foo->constraint(
{ type => 'Regex',
regex => 'xxx',
} );
$bar->constraint(
{ type => 'Regex',
regex => 'xxx',
anchored => 1,
} );
# Valid
{
$form->process(
{ foo => ' xxx ',
bar => 'xxx',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => ' xxx ',
bar => ' xxx ',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'foo invalid' );
}
HTML-FormFu-2.07/t/constraints/required_file.yml 0000644 0001751 0001752 00000000240 13404751171 020204 0 ustar carl carl ---
action: 'http://www.perl.org/test.cgi'
elements:
- type: File
name: multiple
- type: File
name: hello_world
constraints:
- type: Required
HTML-FormFu-2.07/t/constraints/repeatable_any.yml 0000644 0001751 0001752 00000000250 13404751171 020341 0 ustar carl carl ---
elements:
- type: Hidden
name: count
- type: Repeatable
counter_name: count
elements:
- name: foo
constraints:
- 'Repeatable::Any'
HTML-FormFu-2.07/t/constraints/minlength.t 0000644 0001751 0001752 00000001322 13404751171 017016 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 5;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('MinLength')->min(3);
$form->element('Text')->name('bar')->constraint('MinLength')->min(3);
# Valid
{
$form->process(
{ foo => 'abc',
bar => 'abcd',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => 'ab',
bar => 'abcdef',
} );
ok( !$form->valid('foo'), 'foo not valid' );
ok( $form->valid('bar'), 'bar valid' );
is( $form->get_error('foo')->message,
'Must be at least 3 characters long' );
}
HTML-FormFu-2.07/t/constraints/json.t 0000644 0001751 0001752 00000001014 13404751171 016000 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo');
$form->constraint('JSON');
my @valid = ( '{"foo":"bar"}', '[1,2]', );
for my $string (@valid) {
$form->process( { foo => $string, } );
ok( $form->valid('foo'), "foo valid: $string" );
}
my @invalid = ( "{'foo':'bar'}", 'plain text', );
for my $string (@invalid) {
$form->process( { foo => $string, } );
ok( !$form->valid('foo'), "foo not valid: $string" );
}
HTML-FormFu-2.07/t/constraints/repeatable_any.t 0000644 0001751 0001752 00000003162 13404751171 020010 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 10;
use HTML::FormFu;
use lib 't/lib';
use HTMLFormFu::TestLib;
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->load_config_file('t/constraints/repeatable_any.yml');
$form->get_element( { type => 'Repeatable' } )->repeat(2);
# Valid
{
$form->process(
{ foo_1 => 'a',
foo_2 => 'b',
count => 2,
} );
ok( $form->submitted_and_valid );
is_deeply(
$form->params,
{ foo_1 => 'a',
foo_2 => 'b',
count => 2,
} );
}
# Valid - 1 missing
{
$form->process(
{ foo_1 => 'a',
foo_2 => '',
count => 2,
} );
ok( $form->submitted_and_valid );
is_deeply(
$form->params,
{ foo_1 => 'a',
foo_2 => '',
count => 2,
} );
}
# Valid - 1 missing
{
$form->process(
{ foo_1 => '',
foo_2 => 'b',
count => 2,
} );
ok( $form->submitted_and_valid );
is_deeply(
$form->params,
{ foo_1 => '',
foo_2 => 'b',
count => 2,
} );
}
# Missing - Invalid
{
$form->process(
{ foo_1 => '',
foo_2 => '',
count => 2,
} );
ok( !$form->submitted_and_valid );
# error is only attached to first rep
is_deeply( [ $form->has_errors ], ['foo_1'] );
like( $form->get_field( { nested_name => 'foo_1' } ), qr/is required/ );
unlike( $form->get_field( { nested_name => 'foo_2' } ), qr/is required/ );
}
HTML-FormFu-2.07/t/constraints/dependon.t 0000644 0001751 0001752 00000001171 13404751171 016627 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('DependOn')
->others( [qw/ bar baz /] );
$form->element('Text')->name('bar');
$form->element('Text')->name('baz');
# Valid
{
$form->process(
{ foo => 1,
bar => 'a',
baz => [2],
} );
ok( !$form->has_errors );
}
# Invalid
{
$form->process(
{ foo => 1,
bar => '',
baz => 2,
} );
ok( $form->valid('foo') );
ok( $form->has_errors('bar') );
ok( $form->valid('baz') );
}
HTML-FormFu-2.07/t/constraints/dependon_attach_errors_to_base.t 0000644 0001751 0001752 00000001014 13404751171 023237 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/dependon_attach_errors_to_base.yml');
# Valid
{
$form->process(
{ foo => 'a',
bar => 'b',
} );
ok( $form->submitted_and_valid );
}
# Invalid
{
$form->process(
{ foo => '',
bar => 'b',
} );
ok( !$form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( $form->has_errors('bar') );
}
HTML-FormFu-2.07/t/constraints/constraint_when.yml 0000644 0001751 0001752 00000001203 13404751171 020572 0 ustar carl carl ---
elements:
- name: foo
constraints:
- type: Integer
- name: bar
constraints:
- type: Required
when:
field: foo
value: 1
- name: moo
constraints:
type: Required
when:
field: foo
values: [2,3,4]
- name: zoo
constraints:
- type: Required
when:
field: foo
value: 5
not: 1
- name: coo
constraints:
- type: Number
- name: coo2
constraints:
- type: Integer
when:
callback: 'CB::when_string_callback'
HTML-FormFu-2.07/t/constraints/word.t 0000644 0001751 0001752 00000002512 13404751171 016006 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 16;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo');
$form->element('Text')->name('bar');
$form->constraint('Word');
# Valid
{
$form->process(
{ foo => 'aaa',
bar => 'bbbbbbb',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
}
# [space] - Invalid
{
$form->process(
{ foo => 'a',
bar => 'b c',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'foo valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( !grep { $_ eq 'bar' } $form->valid );
}
# [newline] - Invalid
{
$form->process(
{ foo => 'a',
bar => "b\nc",
} );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'foo valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( !grep { $_ eq 'bar' } $form->valid );
}
# "0" is valid
{
$form->process(
{ foo => 0,
bar => 2,
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'foo valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
}
HTML-FormFu-2.07/t/constraints/allornone.t 0000644 0001751 0001752 00000001571 13404751171 017030 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 7;
use HTML::FormFu;
my $form = HTML::FormFu->new->indicator( sub {1} );
$form->element('Text')->name('foo')->constraint('AllOrNone')
->others( [qw/ bar baz bif /] );
$form->element('Text')->name('bar');
$form->element('Text')->name('baz');
$form->element('Text')->name('bif');
# Valid
{
$form->process(
{ foo => 1,
bar => 'a',
baz => [2],
bif => [ 3, 4 ],
} );
ok( !$form->has_errors );
}
# Valid
{
$form->process( {} );
ok( !$form->has_errors );
}
# Invalid
{
$form->process(
{ foo => 1,
bar => '',
baz => [2],
bif => [ 3, 4 ],
} );
ok( $form->has_errors );
ok( $form->valid('foo') );
ok( $form->has_errors('bar') );
ok( $form->valid('baz') );
ok( $form->valid('bif') );
}
HTML-FormFu-2.07/t/constraints/constraint_when_fields.yml 0000644 0001751 0001752 00000000256 13404751171 022127 0 ustar carl carl ---
elements:
- name: a
constraints:
- type: Bool
when:
fields:
- 'b'
- 'c'
- name: b
- name: c
HTML-FormFu-2.07/t/constraints/constraint.t 0000644 0001751 0001752 00000005504 13404751171 017223 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 40;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo');
$form->element('Text')->name('bar');
my @c1 = $form->constraint(
{ type => 'Number',
names => [qw/ foo bar /],
} );
is( $c1[0]->name, 'foo' );
is( $c1[0]->type, 'Number' );
is( $c1[1]->name, 'bar' );
is( $c1[1]->type, 'Number' );
{
my @a = $form->constraint( [
{ type => 'Regex',
names => [qw/ foo bar /],
},
{ type => 'Required',
names => 'bar',
},
] );
is( $a[0]->name, 'foo' );
is( $a[0]->type, 'Regex' );
is( $a[1]->name, 'bar' );
is( $a[1]->type, 'Regex' );
is( $a[2]->name, 'bar' );
is( $a[2]->type, 'Required' );
}
# $element->constraint
my $ec_element = $form->element('Text')->name('ec');
$ec_element->constraint('Regex')->regex(qr/^\d+$/);
# Valid
{
$form->process(
{ foo => 1,
bar => 2,
ec => 3,
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('ec'), 'ec valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
ok( grep { $_ eq 'ec' } $form->valid );
}
# Invalid
{
$form->process(
{ foo => 1,
bar => 'baz',
ec => 'a',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'bar not valid' );
ok( !$form->valid('ec'), 'ec not valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( !grep { $_ eq 'bar' } $form->valid );
ok( !grep { $_ eq 'ec' } $form->valid );
}
# Empty string Valid
{
$form->process(
{ foo => '',
bar => 2,
ec => '',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( $form->valid('ec'), 'ec not valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
ok( grep { $_ eq 'ec' } $form->valid );
}
# Missing Invalid
{
$form->process(
{ foo => '',
bar => 2,
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
ok( !$form->valid('ec'), 'ec not valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
ok( !grep { $_ eq 'ec' } $form->valid );
}
# zero "0" Valid
{
$form->process(
{ foo => 0,
bar => 1,
ec => 0,
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('ec'), 'ec valid' );
ok( grep { $_ eq 'foo' } $form->valid );
ok( grep { $_ eq 'bar' } $form->valid );
ok( grep { $_ eq 'ec' } $form->valid );
}
HTML-FormFu-2.07/t/constraints/email-mx.t 0000644 0001751 0001752 00000002045 13404751171 016545 0 ustar carl carl use strict;
use warnings;
use Test::RequiresInternet 'cpan.org' => 80;
use Test::More tests => 3;
use HTML::FormFu;
{
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('Email')
->options('mxcheck');
# Valid - Scalar
{
$form->process( { foo => 'cfranks@cpan.org' } );
ok( $form->valid('foo'), 'foo valid - mxcheck scalar' );
}
}
{
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('Email')
->options( ['mxcheck'] );
# Valid - Array
{
$form->process( { foo => 'djzort@cpan.org' } );
ok( $form->valid('foo'), 'foo valid - mxcheck array' );
}
}
{
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('Email')
->options( { 'mxcheck' => 1 } );
# Valid - Hash
{
$form->process(
{ foo => 'djzort@cpan.org', options => { 'mxcheck' => 1 } } );
ok( $form->valid('foo'), 'foo valid - mxcheck hash' );
}
}
HTML-FormFu-2.07/t/constraints/minmaxfields.t 0000644 0001751 0001752 00000002471 13404751171 017517 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 8;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('MinMaxFields')
->others( [qw/ bar baz boz/] )->min(1)->max(2);
$form->element('Text')->name('bar');
$form->element('Text')->name('baz');
$form->element('Text')->name('boz');
# Valid
{
$form->process(
{ foo => 1,
bar => '',
baz => [2],
boz => '',
} );
ok( !$form->has_errors );
$form->process(
{ foo => 1,
bar => '',
baz => '',
boz => '',
} );
ok( !$form->has_errors );
}
# Invalid
{
$form->process(
{ foo => 1,
bar => '',
baz => 2,
boz => '22',
} );
ok( $form->has_errors );
ok( !$form->valid('foo') );
ok( $form->valid('bar') );
ok( $form->valid('baz') );
ok( $form->valid('boz') );
}
{
# Test setting default for max when others is a single element
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('MinMaxFields')
->others('bar');
$form->element('Text')->name('bar');
{
$form->process(
{ foo => 1,
bar => '',
} );
ok( !$form->has_errors );
}
}
HTML-FormFu-2.07/t/constraints/file_size.t 0000644 0001751 0001752 00000003725 13404751171 017013 0 ustar carl carl use strict;
use warnings;
use Test::More;
use HTML::FormFu;
eval "use CGI";
if ($@) {
plan skip_all => 'CGI required';
die $!;
}
plan tests => 10;
# Copied from CGI.pm - http://search.cpan.org/perldoc?CGI
%ENV = (
%ENV,
'SCRIPT_NAME' => '/test.cgi',
'SERVER_NAME' => 'perl.org',
'HTTP_CONNECTION' => 'TE, close',
'REQUEST_METHOD' => 'POST',
'SCRIPT_URI' => 'http://www.perl.org/test.cgi',
'SCRIPT_FILENAME' => '/home/usr/test.cgi',
'SERVER_SOFTWARE' => 'Apache/1.3.27 (Unix) ',
'HTTP_TE' => 'deflate,gzip;q=0.3',
'QUERY_STRING' => '',
'REMOTE_PORT' => '1855',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)',
'SERVER_PORT' => '80',
'REMOTE_ADDR' => '127.0.0.1',
'CONTENT_TYPE' => 'multipart/form-data; boundary=xYzZY',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'PATH' => '/usr/local/bin:/usr/bin:/bin',
'REQUEST_URI' => '/test.cgi',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SCRIPT_URL' => '/test.cgi',
'SERVER_ADDR' => '127.0.0.1',
'DOCUMENT_ROOT' => '/home/develop',
'HTTP_HOST' => 'www.perl.org'
);
my $q;
{
my $file = 't/elements/file_post.txt';
local *STDIN;
open STDIN, "<", $file
or die "missing test file $file";
binmode STDIN;
$q = CGI->new;
}
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/file_size.yml');
$form->process($q);
{
ok( $form->submitted );
ok( !$form->has_errors('hello_world') );
ok( $form->has_errors('does_not_exist_gif') );
ok( $form->valid('hello_world') );
ok( !$form->valid('does_not_exist_gif') );
}
$form->process( { hello_world => 'not a file', } );
{
ok( $form->submitted );
ok( $form->has_errors('hello_world') );
ok( !$form->has_errors('does_not_exist_gif') );
ok( !$form->valid('hello_world') );
ok( !$form->valid('does_not_exist_gif') );
}
HTML-FormFu-2.07/t/constraints/dependon_attach_errors_to_others.yml 0000644 0001751 0001752 00000000246 13404751171 024175 0 ustar carl carl ---
elements:
- name: foo
- name: bar
constraints:
- type: DependOn
others: foo
attach_errors_to_others:
- foo
HTML-FormFu-2.07/t/constraints/ascii.t 0000644 0001751 0001752 00000001131 13404751171 016117 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo');
$form->element('Text')->name('bar');
$form->constraint('ASCII');
# Valid
{
$form->process(
{ foo => 'aaa',
bar => 'bbbbbbb',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => 'aaa',
bar => '日本語',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'bar not valid' );
}
HTML-FormFu-2.07/t/constraints/constraint_when_fields.t 0000644 0001751 0001752 00000004307 13404751171 021572 0 ustar carl carl use strict;
use warnings;
use Test::More 'no_plan';
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/constraint_when_fields.yml');
# Valid
{
$form->process(
{ a => '',
b => '',
c => '',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('a'), 'a valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
}
# Valid
{
$form->process(
{ a => '1',
b => '',
c => '',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('a'), 'a valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
}
# Valid
{
# Bool constraint doesn't run because b & c don't both have values
$form->process(
{ a => 'a',
b => '',
c => '',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('a'), 'a valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
}
# Valid
{
# Bool constraint doesn't run because b & c don't both have values
$form->process(
{ a => 'a',
b => '',
c => '1',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('a'), 'a valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
}
# Valid
{
$form->process(
{ a => '1',
b => '1',
c => '1',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('a'), 'a valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
}
# Valid
{
# Empty is valid
$form->process(
{ a => '',
b => '1',
c => '1',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('a'), 'a valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
}
# Invalid
{
$form->process(
{ a => 'a',
b => '1',
c => '1',
} );
ok( !$form->submitted_and_valid );
ok( !$form->valid('a'), 'a not valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
}
HTML-FormFu-2.07/t/constraints/autoset.t 0000644 0001751 0001752 00000001465 13404751171 016525 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 5;
use HTML::FormFu;
my $form = HTML::FormFu->new;
# Autoset with multiple values
$form->element('Select')->name('foo')->values( [qw/ one two three /] )
->constraint('AutoSet');
# Valid
{
$form->process( { foo => 'two', } );
# Constraint set has 3 values
is_deeply( $form->get_constraint->set, [qw/ one two three /] );
ok( $form->valid('foo') );
}
# Invalid
{
$form->process( { foo => 'yes', } );
ok( $form->has_errors('foo') );
}
# Autoset with a single value
$form->element('Select')->name('bar')->values( [qw/ one /] )
->constraint('AutoSet');
# Valid
{
$form->process( { bar => 'one', } );
ok( $form->valid('bar') );
}
# Invalid
{
$form->process( { bar => 'yes', } );
ok( $form->has_errors('bar') );
}
HTML-FormFu-2.07/t/constraints/maxrange.t 0000644 0001751 0001752 00000001145 13404751171 016636 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('MaxRange')->max(5);
$form->element('Text')->name('bar')->constraint('MaxRange')->max(5);
# Valid
{
$form->process(
{ foo => 3,
bar => 4,
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => 1,
bar => 6,
} );
ok( $form->valid('foo'), 'foo not valid' );
ok( !$form->valid('bar'), 'bar not valid' );
}
HTML-FormFu-2.07/t/constraints/dependon_attach_errors_to_others.t 0000644 0001751 0001752 00000001016 13404751171 023633 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/dependon_attach_errors_to_others.yml');
# Valid
{
$form->process(
{ foo => 'a',
bar => 'b',
} );
ok( $form->submitted_and_valid );
}
# Invalid
{
$form->process(
{ foo => '',
bar => 'b',
} );
ok( !$form->submitted_and_valid );
ok( $form->has_errors('foo') );
ok( !$form->has_errors('bar') );
}
HTML-FormFu-2.07/t/constraints/required_only_on_reps.yml 0000644 0001751 0001752 00000000767 13404751171 022011 0 ustar carl carl ---
elements:
- type: Hidden
name: count
- type: Repeatable
counter_name: count
elements:
- name: foo
constraints:
- type: Required
only_on_reps: 1
- name: bar
constraints:
- type: Required
only_on_reps: 2
- name: buz
constraints:
- type: Required
only_on_reps: [1, 3]
- name: moo
constraints:
- type: Required
HTML-FormFu-2.07/t/constraints/bool.t 0000644 0001751 0001752 00000001107 13404751171 015765 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo');
$form->element('Text')->name('bar');
$form->constraint('Bool');
# Valid
{
$form->process(
{ foo => 1,
bar => 0,
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => '01',
bar => 'a',
} );
ok( !$form->valid('foo'), 'foo not valid' );
ok( !$form->valid('bar'), 'bar not valid' );
}
HTML-FormFu-2.07/t/constraints/constraint_when_any_field.t 0000644 0001751 0001752 00000006756 13404751171 022270 0 ustar carl carl use strict;
use warnings;
use Test::More 'no_plan';
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/constraint_when_any_field.yml');
#$ENV{HTML_FORMFU_DEBUG_PROCESS} = 1;
# Valid
{
$form->process(
{ a => '',
b => '',
c => '',
d => '',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('a'), 'a valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
ok( $form->valid('d'), 'd valid' );
}
# Valid
{
$form->process(
{ a => '1',
b => '',
c => '',
d => '',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('a'), 'a valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
ok( $form->valid('d'), 'd valid' );
}
# Valid
{
$form->process(
{ a => '',
b => '1',
c => '',
d => '',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('a'), 'a valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
ok( $form->valid('d'), 'd valid' );
}
# Valid
{
$form->process(
{ a => '',
b => '',
c => '1',
d => '',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('a'), 'a valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
ok( $form->valid('d'), 'd valid' );
}
# Valid
{
$form->process(
{ a => '',
b => '',
c => '',
d => '1',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('a'), 'a valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
ok( $form->valid('d'), 'd valid' );
}
# Valid
{
$form->process(
{ a => '1',
b => '1',
c => '',
d => '',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('a'), 'a valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
ok( $form->valid('d'), 'd valid' );
}
# Valid
{
$form->process(
{ a => '',
b => '1',
c => '1',
d => '',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('a'), 'a valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
ok( $form->valid('d'), 'd valid' );
}
# Invalid
{
$form->process(
{ a => '1',
b => '1',
c => '1',
d => '',
} );
ok( !$form->submitted_and_valid );
ok( !$form->valid('a'), 'a not valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
ok( $form->valid('d'), 'd valid' );
}
# Invalid
{
$form->process(
{ a => '',
b => '1',
c => '1',
d => '1',
} );
ok( !$form->submitted_and_valid );
ok( !$form->valid('a'), 'a not valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
ok( $form->valid('d'), 'd valid' );
}
# Invalid
{
$form->process(
{ a => '1',
b => '1',
c => '1',
d => '1',
} );
ok( !$form->submitted_and_valid );
ok( !$form->valid('a'), 'a not valid' );
ok( $form->valid('b'), 'b valid' );
ok( $form->valid('c'), 'c valid' );
ok( $form->valid('d'), 'd valid' );
}
HTML-FormFu-2.07/t/constraints/range.t 0000644 0001751 0001752 00000001157 13404751171 016133 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('Range')->min(3)->max(5);
$form->element('Text')->name('bar')->constraint('Range')->min(3)->max(5);
# Valid
{
$form->process(
{ foo => 3,
bar => 4,
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => 1,
bar => 6,
} );
ok( !$form->valid('foo'), 'foo not valid' );
ok( !$form->valid('bar'), 'bar not valid' );
}
HTML-FormFu-2.07/t/constraints/set.t 0000644 0001751 0001752 00000001213 13404751171 015623 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('Set')->set( [qw/ yes no /] );
$form->element('Text')->name('bar')->constraint('Set')->set( [qw/ yes no /] );
# Valid
{
$form->process(
{ foo => 'yes',
bar => 'no',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => 'yes',
bar => 'x',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->has_errors('bar'), 'bar has_errors' );
}
HTML-FormFu-2.07/t/constraints/equal_internals.t 0000644 0001751 0001752 00000000662 13404751171 020225 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 5;
use HTML::FormFu::Constraint::Equal;
ok( HTML::FormFu::Constraint::Equal::_values_eq( '1', '1' ) );
ok( HTML::FormFu::Constraint::Equal::_values_eq( ' ', ' ' ) );
ok( HTML::FormFu::Constraint::Equal::_values_eq( 'aa', 'aa' ) );
ok( HTML::FormFu::Constraint::Equal::_values_eq( ['x'], ['x'] ) );
ok( HTML::FormFu::Constraint::Equal::_values_eq( [ 'a', 'b' ], [ 'b', 'a' ] ) );
HTML-FormFu-2.07/t/constraints/allornone_attach_errors_to_base.t 0000644 0001751 0001752 00000001015 13404751171 023435 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/allornone_attach_errors_to_base.yml');
# Valid
{
$form->process(
{ foo => 'a',
bar => 'b',
} );
ok( $form->submitted_and_valid );
}
# Invalid
{
$form->process(
{ foo => '',
bar => 'b',
} );
ok( !$form->submitted_and_valid );
ok( !$form->has_errors('foo') );
ok( $form->has_errors('bar') );
}
HTML-FormFu-2.07/t/constraints/xml.t 0000644 0001751 0001752 00000000637 13404751171 015641 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 1;
use HTML::FormFu;
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->element('Text')->name('foo');
$form->constraint('Required');
$form->constraint('Regex')->regex(qr/^\d+$/)->message_xml("don't escape ");
$form->process( { foo => 'a' } );
like( $form->get_field('foo'), qr/don't escape / );
HTML-FormFu-2.07/t/constraints/file_minsize.t 0000644 0001751 0001752 00000003511 13404751171 017510 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 7;
use HTML::FormFu;
use CGI;
# Copied from CGI.pm - http://search.cpan.org/perldoc?CGI
%ENV = (
%ENV,
'SCRIPT_NAME' => '/test.cgi',
'SERVER_NAME' => 'perl.org',
'HTTP_CONNECTION' => 'TE, close',
'REQUEST_METHOD' => 'POST',
'SCRIPT_URI' => 'http://www.perl.org/test.cgi',
'SCRIPT_FILENAME' => '/home/usr/test.cgi',
'SERVER_SOFTWARE' => 'Apache/1.3.27 (Unix) ',
'HTTP_TE' => 'deflate,gzip;q=0.3',
'QUERY_STRING' => '',
'REMOTE_PORT' => '1855',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)',
'SERVER_PORT' => '80',
'REMOTE_ADDR' => '127.0.0.1',
'CONTENT_TYPE' => 'multipart/form-data; boundary=xYzZY',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'PATH' => '/usr/local/bin:/usr/bin:/bin',
'REQUEST_URI' => '/test.cgi',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SCRIPT_URL' => '/test.cgi',
'SERVER_ADDR' => '127.0.0.1',
'DOCUMENT_ROOT' => '/home/develop',
'HTTP_HOST' => 'www.perl.org'
);
my $q;
{
my $file = 't/elements/file_post.txt';
local *STDIN;
open STDIN, "<", $file
or die "missing test file $file";
binmode STDIN;
$q = CGI->new;
}
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->load_config_file('t/constraints/file_minsize.yml');
$form->process($q);
{
ok( $form->submitted );
ok( !$form->has_errors('hello_world') );
ok( $form->valid('hello_world') );
}
$form->process( { hello_world => 'not a file', } );
{
ok( $form->submitted );
ok( $form->has_errors('hello_world') );
ok( !$form->valid('hello_world') );
like( "$form", qr/File-size must be at least 1 bytes/ );
}
HTML-FormFu-2.07/t/constraints/not_equal.t 0000644 0001751 0001752 00000001141 13404751171 017017 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('Not_Equal')->others('bar');
$form->element('Text')->name('bar');
# Valid
{
$form->process(
{ foo => 'yada',
bar => 'xxxx',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => 'yada',
bar => 'yada',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->has_errors('bar'), 'bar valid' );
}
HTML-FormFu-2.07/t/constraints/constraint_other_siblings.t 0000644 0001751 0001752 00000001474 13404751171 022320 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 7;
use HTML::FormFu;
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->indicator( sub {1} );
$form->load_config_file('t/constraints/constraint_other_siblings.yml');
# Valid
{
$form->process(
{ foo => 1,
bar => 'a',
baz => [2],
bif => [ 3, 4 ],
} );
ok( !$form->has_errors );
}
# Valid
{
$form->process( {} );
ok( !$form->has_errors );
}
# Invalid
{
$form->process(
{ foo => 1,
bar => '',
baz => [2],
bif => [ 3, 4 ],
} );
ok( $form->has_errors );
ok( $form->valid('foo') );
ok( $form->has_errors('bar') );
ok( $form->valid('baz') );
ok( $form->valid('bif') );
}
HTML-FormFu-2.07/t/constraints/file.t 0000644 0001751 0001752 00000003720 13404751171 015754 0 ustar carl carl use strict;
use warnings;
use Test::More;
use HTML::FormFu;
eval "use CGI";
if ($@) {
plan skip_all => 'CGI required';
die $!;
}
plan tests => 10;
# Copied from CGI.pm - http://search.cpan.org/perldoc?CGI
%ENV = (
%ENV,
'SCRIPT_NAME' => '/test.cgi',
'SERVER_NAME' => 'perl.org',
'HTTP_CONNECTION' => 'TE, close',
'REQUEST_METHOD' => 'POST',
'SCRIPT_URI' => 'http://www.perl.org/test.cgi',
'SCRIPT_FILENAME' => '/home/usr/test.cgi',
'SERVER_SOFTWARE' => 'Apache/1.3.27 (Unix) ',
'HTTP_TE' => 'deflate,gzip;q=0.3',
'QUERY_STRING' => '',
'REMOTE_PORT' => '1855',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)',
'SERVER_PORT' => '80',
'REMOTE_ADDR' => '127.0.0.1',
'CONTENT_TYPE' => 'multipart/form-data; boundary=xYzZY',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'PATH' => '/usr/local/bin:/usr/bin:/bin',
'REQUEST_URI' => '/test.cgi',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SCRIPT_URL' => '/test.cgi',
'SERVER_ADDR' => '127.0.0.1',
'DOCUMENT_ROOT' => '/home/develop',
'HTTP_HOST' => 'www.perl.org'
);
my $q;
{
my $file = 't/elements/file_post.txt';
local *STDIN;
open STDIN, "<", $file
or die "missing test file $file";
binmode STDIN;
$q = CGI->new;
}
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/file.yml');
$form->process($q);
{
ok( $form->submitted );
ok( !$form->has_errors('hello_world') );
ok( !$form->has_errors('does_not_exist_gif') );
ok( $form->valid('hello_world') );
ok( $form->valid('does_not_exist_gif') );
}
$form->process( { hello_world => 'not a file', } );
{
ok( $form->submitted );
ok( $form->has_errors('hello_world') );
ok( !$form->has_errors('does_not_exist_gif') );
ok( !$form->valid('hello_world') );
ok( !$form->valid('does_not_exist_gif') );
}
HTML-FormFu-2.07/t/constraints/allornone_attach_errors_to_others.t 0000644 0001751 0001752 00000001017 13404751171 024031 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/allornone_attach_errors_to_others.yml');
# Valid
{
$form->process(
{ foo => 'a',
bar => 'b',
} );
ok( $form->submitted_and_valid );
}
# Invalid
{
$form->process(
{ foo => '',
bar => 'b',
} );
ok( !$form->submitted_and_valid );
ok( $form->has_errors('foo') );
ok( !$form->has_errors('bar') );
}
HTML-FormFu-2.07/t/constraints/allornone_attach_errors_to_base.yml 0000644 0001751 0001752 00000000226 13404751171 023776 0 ustar carl carl ---
elements:
- name: foo
- name: bar
constraints:
- type: AllOrNone
others: foo
attach_errors_to_base: 1
HTML-FormFu-2.07/t/constraints/repeatable_any_not_increment_field_names.t 0000644 0001751 0001752 00000002545 13404751171 025266 0 ustar carl carl use strict;
use warnings;
use Test::More 'no_plan'; #tests => 10;
use HTML::FormFu;
use lib 't/lib';
use HTMLFormFu::TestLib;
my $form = HTML::FormFu->new;
$form->load_config_file(
't/constraints/repeatable_any_not_increment_field_names.yml');
# Valid
{
$form->process(
{ foo => [ 'a', 'b' ],
count => 2,
} );
ok( $form->submitted_and_valid );
is_deeply(
$form->params,
{ foo => [ 'a', 'b' ],
count => 2,
} );
is_deeply( [ $form->has_errors ], [] );
}
# Valid - 1 missing
{
$form->process(
{ foo => [ 'a', '' ],
count => 2,
} );
ok( $form->submitted_and_valid );
is_deeply(
$form->params,
{ foo => [ 'a', '' ],
count => 2,
} );
is_deeply( [ $form->has_errors ], [] );
}
# Valid - 1 missing
{
$form->process(
{ foo => [ '', 'b' ],
count => 2,
} );
ok( $form->submitted_and_valid );
is_deeply(
$form->params,
{ foo => [ '', 'b' ],
count => 2,
} );
is_deeply( [ $form->has_errors ], [] );
}
# Missing - Invalid
{
$form->process(
{ foo => [ '', '' ],
count => 2,
} );
ok( !$form->submitted_and_valid );
is_deeply( [ $form->has_errors ], ['foo'] );
}
HTML-FormFu-2.07/t/constraints/file_mime.yml 0000644 0001751 0001752 00000000436 13404751171 017322 0 ustar carl carl ---
action: 'http://www.perl.org/test.cgi'
elements:
- type: File
name: hello_world
constraints:
- type: File::MIME
types: ['text/rtf', 'text/plain']
- type: File
name: 100x100_gif
constraints:
- type: File::MIME
regex: '^ image/.* \z'
HTML-FormFu-2.07/t/constraints/constraint_when_any_true_value.t 0000644 0001751 0001752 00000001515 13404751171 023344 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 9;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/constraint_when_any_true_value.yml');
# Valid
{
$form->process(
{ foo => 'a',
bar => 'b',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# valid
{
$form->process(
{ foo => '',
bar => 'b',
} );
ok( $form->submitted_and_valid );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => 'a',
bar => '',
} );
ok( $form->has_errors );
ok( $form->valid('foo'), 'foo valid' );
ok( !$form->valid('bar'), 'bar not valid' );
}
HTML-FormFu-2.07/t/constraints/constraint_other_siblings.yml 0000644 0001751 0001752 00000000232 13404751171 022645 0 ustar carl carl ---
elements:
- name: foo
constraints:
- type: AllOrNone
other_siblings: 1
- name: bar
- name: baz
- name: bif
HTML-FormFu-2.07/t/constraints/constraint_other_siblings_not.yml 0000644 0001751 0001752 00000000226 13404751171 023530 0 ustar carl carl ---
elements:
- name: foo
constraints:
- type: Equal
other_siblings: 1
not: 1
- name: bar
- name: baz
HTML-FormFu-2.07/t/constraints/file_mime.t 0000644 0001751 0001752 00000003671 13404751171 016770 0 ustar carl carl use strict;
use warnings;
use Test::More;
use HTML::FormFu;
eval "use CGI";
if ($@) {
plan skip_all => 'CGI required';
die $!;
}
plan tests => 10;
# Copied from CGI.pm - http://search.cpan.org/perldoc?CGI
%ENV = (
%ENV,
'SCRIPT_NAME' => '/test.cgi',
'SERVER_NAME' => 'perl.org',
'HTTP_CONNECTION' => 'TE, close',
'REQUEST_METHOD' => 'POST',
'SCRIPT_URI' => 'http://www.perl.org/test.cgi',
'SCRIPT_FILENAME' => '/home/usr/test.cgi',
'SERVER_SOFTWARE' => 'Apache/1.3.27 (Unix) ',
'HTTP_TE' => 'deflate,gzip;q=0.3',
'QUERY_STRING' => '',
'REMOTE_PORT' => '1855',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)',
'SERVER_PORT' => '80',
'REMOTE_ADDR' => '127.0.0.1',
'CONTENT_TYPE' => 'multipart/form-data; boundary=xYzZY',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'PATH' => '/usr/local/bin:/usr/bin:/bin',
'REQUEST_URI' => '/test.cgi',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SCRIPT_URL' => '/test.cgi',
'SERVER_ADDR' => '127.0.0.1',
'DOCUMENT_ROOT' => '/home/develop',
'HTTP_HOST' => 'www.perl.org'
);
my $q;
{
my $file = 't/elements/file_post.txt';
local *STDIN;
open STDIN, "<", $file
or die "missing test file $file";
binmode STDIN;
$q = CGI->new;
}
my $form = HTML::FormFu->new;
$form->load_config_file('t/constraints/file_mime.yml');
$form->process($q);
{
ok( $form->submitted );
ok( !$form->has_errors('hello_world') );
ok( !$form->has_errors('100x100_gif') );
ok( $form->valid('hello_world') );
ok( $form->valid('100x100_gif') );
}
$form->process( { hello_world => 'not a file', } );
{
ok( $form->submitted );
ok( $form->has_errors('hello_world') );
ok( !$form->has_errors('100x100_gif') );
ok( !$form->valid('hello_world') );
ok( !$form->valid('100x100_gif') );
}
HTML-FormFu-2.07/t/constraints/file.yml 0000644 0001751 0001752 00000000245 13404751171 016311 0 ustar carl carl ---
action: 'http://www.perl.org/test.cgi'
elements:
- type: File
name: hello_world
- type: File
name: does_not_exist_gif
constraints:
- type: File
HTML-FormFu-2.07/t/constraints/length.t 0000644 0001751 0001752 00000001204 13404751171 016311 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->constraint('Length')->min(3)->max(5);
$form->element('Text')->name('bar')->constraint('Length')->min(3)->max(5);
# Valid
{
$form->process(
{ foo => 'abc',
bar => 'abcd',
} );
ok( $form->valid('foo'), 'foo valid' );
ok( $form->valid('bar'), 'bar valid' );
}
# Invalid
{
$form->process(
{ foo => 'ab',
bar => 'abcdef',
} );
ok( !$form->valid('foo'), 'foo not valid' );
ok( !$form->valid('bar'), 'bar not valid' );
}
HTML-FormFu-2.07/t/00-report-prereqs.dd 0000644 0001751 0001752 00000011263 13404751171 016022 0 ustar carl carl do { my $x = {
'configure' => {
'requires' => {
'ExtUtils::MakeMaker' => '0',
'File::ShareDir::Install' => '0.06'
}
},
'develop' => {
'requires' => {
'File::Spec' => '0',
'IO::Handle' => '0',
'IPC::Open3' => '0',
'Test::CPAN::Meta' => '0',
'Test::EOL' => '0',
'Test::Kwalitee' => '1.21',
'Test::More' => '0.88',
'Test::PAUSE::Permissions' => '0',
'Test::Perl::Critic' => '0',
'Test::Pod' => '1.41'
}
},
'runtime' => {
'requires' => {
'Carp' => '0',
'Class::MOP::Method' => '0',
'Clone' => '0.31',
'Config::Any' => '0.18',
'Cwd' => '0',
'Data::Visitor' => '0.26',
'Data::Visitor::Callback' => '0',
'DateTime' => '0.54',
'DateTime::Format::Builder' => '0.7901',
'DateTime::Format::Natural' => '0',
'DateTime::Format::Strptime' => '1.2000',
'DateTime::Locale' => '0.45',
'Email::Valid' => '0',
'Encode' => '0',
'Exporter' => '5.57',
'Fatal' => '0',
'File::Copy' => '0',
'File::Find' => '0',
'File::ShareDir' => '0',
'File::Spec' => '0',
'File::Temp' => '0',
'HTML::Scrubber' => '0',
'HTML::TokeParser::Simple' => '3.14',
'HTTP::Headers' => '1.64',
'Hash::Flatten' => '0',
'IO::File' => '0',
'JSON::MaybeXS' => '0',
'List::MoreUtils' => '0',
'List::Util' => '1.45',
'Locale::Maketext' => '0',
'Module::Pluggable' => '0',
'Moose' => '1.00',
'Moose::Role' => '0',
'Moose::Util' => '0',
'MooseX::Aliases' => '0',
'MooseX::Attribute::Chained' => 'v1.0.2',
'Number::Format' => '0',
'Path::Class::File' => '0',
'Readonly' => '0',
'Regexp::Common' => '0',
'Scalar::Util' => '0',
'Storable' => '0',
'Task::Weaken' => '0',
'YAML::XS' => '0.32',
'perl' => '5.010'
}
},
'test' => {
'recommends' => {
'CPAN::Meta' => '2.120900'
},
'requires' => {
'CGI' => '3.37',
'ExtUtils::MakeMaker' => '0',
'File::Spec' => '0',
'POSIX' => '0',
'Regexp::Assemble' => '0',
'Test::Exception' => '0',
'Test::Memory::Cycle' => '0',
'Test::More' => '0.92',
'Test::RequiresInternet' => '0'
}
}
};
$x;
} HTML-FormFu-2.07/t/roles/ 0000775 0001751 0001752 00000000000 13404751171 013425 5 ustar carl carl HTML-FormFu-2.07/t/roles/form.t 0000644 0001751 0001752 00000000436 13404751171 014556 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 1;
use HTML::FormFu;
use lib 't/lib';
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->load_config_file('t/roles/form.yml');
is( $form->custom_role_method, "form ID: xxx" );
HTML-FormFu-2.07/t/roles/field.t 0000644 0001751 0001752 00000000671 13404751171 014677 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 1;
use HTML::FormFu;
use lib 't/lib';
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->load_config_file('t/roles/field.yml');
my $expected_form_xhtml = <
EOF
is( "$form", $expected_form_xhtml );
HTML-FormFu-2.07/t/roles/block.yml 0000644 0001751 0001752 00000000154 13404751171 015240 0 ustar carl carl ---
elements:
- type: Block
roles:
- '+HTMLFormFu::MyBlockRole'
elements:
- name: foo
HTML-FormFu-2.07/t/roles/form.yml 0000644 0001751 0001752 00000000063 13404751171 015110 0 ustar carl carl ---
id: xxx
roles:
- '+HTMLFormFu::MyFormRole'
HTML-FormFu-2.07/t/roles/field.yml 0000644 0001751 0001752 00000000134 13404751171 015227 0 ustar carl carl ---
auto_fieldset: 1
elements:
- name: foo
roles:
- '+HTMLFormFu::MyFieldRole'
HTML-FormFu-2.07/t/roles/block.t 0000644 0001751 0001752 00000000657 13404751171 014712 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 1;
use HTML::FormFu;
use lib 't/lib';
my $form = HTML::FormFu->new(
{ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } );
$form->load_config_file('t/roles/block.yml');
my $expected_form_xhtml = <
EOF
is( "$form", $expected_form_xhtml );
HTML-FormFu-2.07/t/04basic.yml 0000644 0001751 0001752 00000000621 13404751171 014246 0 ustar carl carl ---
action: /foo/bar
id: form
auto_id: '%n'
elements:
- type: Fieldset
legend: Jimi
elements:
- name: age
type: Text
comment: x
label: Age
constraints: [Integer, Required]
- name: name
type: Text
label: Name
- name: ok
type: Hidden
value: OK
constraints:
type: Required
name: name
filters:
- HTMLEscape
HTML-FormFu-2.07/t/utils/ 0000775 0001751 0001752 00000000000 13404751171 013441 5 ustar carl carl HTML-FormFu-2.07/t/utils/remove_xml_attribute.t 0000644 0001751 0001752 00000006000 13404751171 020060 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 22;
use HTML::FormFu::Util qw(
literal
remove_xml_attribute
xml_escape
);
{
# remove literal from literal
my %attr = ( key => literal("{key}, "{key}, "{key}, "{key}, "{key}, "{key}, "" );
}
{
# remove string from literal
my %attr = ( key => literal("<foo <bar <foo <bar <foo") );
is( xml_escape( \%attr )->{key},
"<foo <bar <foo <bar <foo" );
remove_xml_attribute( \%attr, "key", "{key}, "<bar <foo <bar <foo" );
remove_xml_attribute( \%attr, "key", "{key}, "<bar <bar <foo" );
remove_xml_attribute( \%attr, "key", "{key}, "<bar <bar" );
remove_xml_attribute( \%attr, "key", "{key}, "<bar" );
remove_xml_attribute( \%attr, "key", "{key}, "" );
}
{
# remove string from string
my %attr = ( key => "{key},
"<foo <bar <foo <bar <foo" );
remove_xml_attribute( \%attr, "key", "{key}, "<bar <foo <bar <foo" );
remove_xml_attribute( \%attr, "key", "{key}, "<bar <bar <foo" );
remove_xml_attribute( \%attr, "key", "{key}, "<bar <bar" );
}
{
# remove literal from string
my %attr = ( key => "{key},
"<foo <bar <foo <bar <foo" );
remove_xml_attribute( \%attr, "key", literal "<foo" );
is( xml_escape( \%attr )->{key}, "<bar <foo <bar <foo" );
remove_xml_attribute( \%attr, "key", literal "<foo" );
is( xml_escape( \%attr )->{key}, "<bar <bar <foo" );
remove_xml_attribute( \%attr, "key", literal "<foo" );
is( xml_escape( \%attr )->{key}, "<bar <bar" );
# ... remove a string
remove_xml_attribute( \%attr, "key", '{key}, "<bar" );
}
{
# doesn't exist
my %attr = ( key => "foo" );
remove_xml_attribute( \%attr, "NOT EXIST", 'bar' );
is_deeply( \%attr, { key => "foo", }, "didn't change attributes", );
}
HTML-FormFu-2.07/t/utils/has_xml_attribute.t 0000644 0001751 0001752 00000002751 13404751171 017347 0 ustar carl carl use strict;
use warnings;
use Test::More tests => 17;
use HTML::FormFu::Util qw(
literal
has_xml_attribute
xml_escape
);
{
# has literal in literal
my %attr = ( key => literal(" literal("<foo <bar <baz") );
ok( has_xml_attribute( \%attr, "key", " " "