Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
8fe28ca9
Commit
8fe28ca9
authored
Jan 13, 2012
by
stefanooldeman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test formatDate on correct input
parent
7c1c2adf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
4 deletions
+36
-4
tests/Solarium/Query/HelperTest.php
tests/Solarium/Query/HelperTest.php
+36
-4
No files found.
tests/Solarium/Query/HelperTest.php
View file @
8fe28ca9
...
...
@@ -187,29 +187,50 @@ class Solarium_Query_HelperTest extends PHPUnit_Framework_TestCase
public
function
testFormatTimestampInput
()
{
$actual
=
$this
->
_helper
->
formatDate
(
strtotime
(
'2011-10-01'
));
$this
->
assertNotEquals
(
false
,
$
this
->
_helper
->
formatDate
(
strtotime
(
'2011-10-01'
))
,
$
actual
,
'Expects timestamp input to be accpted'
);
$this
->
assertEquals
(
$this
->
_mockFormatDateOutput
(
strtotime
(
'2011-10-01'
)),
$actual
,
'Expects formatDate with Timstamp input to output ISO8601 with stripped timezone'
);
}
public
function
testFormatDateStringInput
()
{
$actual
=
$this
->
_helper
->
formatDate
(
date
(
'Y-m-d'
,
strtotime
(
'2011-10-01'
)));
$this
->
assertNotEquals
(
false
,
$
this
->
_helper
->
formatDate
(
date
(
'Y-m-d'
,
strtotime
(
'2011-10-01'
)))
,
$
actual
,
'Expects date string inputs to be accepted'
);
$this
->
assertEquals
(
$this
->
_mockFormatDateOutput
(
strtotime
(
'2011-10-01'
)),
$actual
,
'Expects formatDate with String input to output ISO8601 with stripped timezone'
);
}
public
function
testFormatDateTimeInput
()
{
$actual
=
$this
->
_helper
->
formatDate
(
new
DateTime
(
strtotime
(
'2011-10-01'
)));
$this
->
assertNotEquals
(
false
,
$
this
->
_helper
->
formatDate
(
new
DateTime
(
strtotime
(
'2011-10-01'
)))
,
$
actual
,
'Expects DateTime object to be accepted'
);
$this
->
assertEquals
(
$this
->
_mockFormatDateOutput
(
strtotime
(
'2011-10-01'
)),
$actual
,
'Expects formatDate with DateTime input to output ISO8601 with stripped timezone'
);
}
public
function
testFormatDate
()
...
...
@@ -218,6 +239,17 @@ class Solarium_Query_HelperTest extends PHPUnit_Framework_TestCase
$expected
=
strtoupper
(
'Z'
);
$actual
=
substr
(
$this
->
_helper
->
formatDate
(
time
()),
19
,
20
);
$this
->
assertEquals
(
$expected
,
$actual
,
'Expects last charachter to be uppercased Z'
);
$this
->
assertEquals
(
$this
->
_mockFormatDateOutput
(
time
()),
$this
->
_helper
->
formatDate
(
time
())
);
}
protected
function
_mockFormatDateOutput
(
$timestamp
)
{
$date
=
new
DateTime
(
$timestamp
);
return
strstr
(
$date
->
format
(
DateTime
::
ISO8601
),
'+'
,
true
)
.
'Z'
;
}
public
function
testAssemble
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment