Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qfq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
typo3
qfq
Commits
1ff36bc5
Commit
1ff36bc5
authored
7 years ago
by
Elias Villiger
Committed by
bbaer
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Feature #5064 - Add unit tests for doDateTime
parent
3f47a3e9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
extension/qfq/qfq/store/FillStoreForm.php
+2
-2
2 additions, 2 deletions
extension/qfq/qfq/store/FillStoreForm.php
extension/qfq/tests/phpunit/FillStoreFormTest.php
+36
-15
36 additions, 15 deletions
extension/qfq/tests/phpunit/FillStoreFormTest.php
with
38 additions
and
17 deletions
extension/qfq/qfq/store/FillStoreForm.php
+
2
−
2
View file @
1ff36bc5
...
...
@@ -302,7 +302,7 @@ class FillStoreForm {
}
/**
* Check $value as date/datime/time value and convert it to FORMAT_DATE_INTERNATIONAL.
* Check $value as date/dat
et
ime/time value and convert it to FORMAT_DATE_INTERNATIONAL.
*
* @param array $formElement - if not set, set $formElement[FE_DATE_FORMAT]
* @param string $value - date/datetime/time value in format FORMAT_DATE_INTERNATIONAL or FORMAT_DATE_GERMAN
...
...
@@ -310,7 +310,7 @@ class FillStoreForm {
* @return string - checked datetime string
* @throws UserFormException
*/
p
rivate
function
doDateTime
(
array
&
$formElement
,
$value
)
{
p
ublic
function
doDateTime
(
array
&
$formElement
,
$value
)
{
$regexp
=
Support
::
dateTimeRegexp
(
$formElement
[
FE_TYPE
],
$formElement
[
FE_DATE_FORMAT
]);
...
...
This diff is collapsed.
Click to expand it.
extension/qfq/tests/phpunit/FillStoreFormTest.php
+
36
−
15
View file @
1ff36bc5
...
...
@@ -19,23 +19,44 @@ class FillStoreFormTest extends \PHPUnit_Framework_TestCase {
* @throws CodeException
* @throws UserFormException
*/
public
function
testFake
()
{
# Violates SANITIZE class: SANITIZE string is always an empty string.
# Access are cached: use new variables for every test.
public
function
testDoDateTime
()
{
$formElement
=
[
FE_TYPE
=>
FE_TYPE_DATE
,
FE_DATE_FORMAT
=>
FORMAT_DATE_INTERNATIONAL
,
FE_SHOW_SECONDS
=>
0
];
$msg
=
'doDateTime fails'
;
$val
=
'2010-03-31'
;
$this
->
assertEquals
(
$val
,
FillStoreForm
::
doDateTime
(
$formElement
,
$val
),
$msg
);
$val
=
'2010-02-28'
;
$this
->
assertEquals
(
$val
,
FillStoreForm
::
doDateTime
(
$formElement
,
$val
),
$msg
);
$val
=
'2012-02-29'
;
$this
->
assertEquals
(
$val
,
FillStoreForm
::
doDateTime
(
$formElement
,
$val
),
$msg
);
$formElement
[
FE_DATE_FORMAT
]
=
FORMAT_DATE_GERMAN
;
$this
->
assertEquals
(
$val
,
FillStoreForm
::
doDateTime
(
$formElement
,
'29.02.2012'
),
$msg
);
}
# Check ''
// $this->assertEquals('', Sanitize::sanitize('', SANITIZE_ALLOW_ALNUMX), "SANITIZE_ALNUMX fails");
$this
->
assertEquals
(
''
,
''
);
/**
* @expectedException \qfq\UserFormException
*/
public
function
testDoDateTimeInvalidDate
()
{
$formElement
=
[
FE_TYPE
=>
FE_TYPE_DATE
,
FE_DATE_FORMAT
=>
FORMAT_DATE_INTERNATIONAL
,
FE_SHOW_SECONDS
=>
0
];
$val
=
'2010-02-29'
;
$this
->
assertEquals
(
$val
,
FillStoreForm
::
doDateTime
(
$formElement
,
$val
),
"doDateTime is passing when it shouldn't"
);
}
/**
* @expectedException \qfq\UserFormException
*/
public
function
testDoDateTimeInvalidDateWithTime
()
{
$formElement
=
[
FE_TYPE
=>
FE_TYPE_DATE
,
FE_DATE_FORMAT
=>
FORMAT_DATE_INTERNATIONAL
,
FE_SHOW_SECONDS
=>
0
];
$val
=
'2010-02-31 23:25'
;
$this
->
assertEquals
(
$val
,
FillStoreForm
::
doDateTime
(
$formElement
,
$val
),
"doDateTime is passing when it shouldn't"
);
}
//
// /**
// * @expectedException \qfq\UserFormException
// */
// public function testSanitizeExceptionMinMaxMissingMin() {
// Sanitize::sanitize(56, SANITIZE_ALLOW_MIN_MAX, '|45');
// }
//
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment