Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
0aa75d84
Unverified
Commit
0aa75d84
authored
Apr 07, 2018
by
Michael Moravec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compatibility for pre-2.7 DateIntervalType format
parent
d4a96deb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
DateIntervalType.php
lib/Doctrine/DBAL/Types/DateIntervalType.php
+9
-2
DateIntervalTest.php
tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php
+15
-0
No files found.
lib/Doctrine/DBAL/Types/DateIntervalType.php
View file @
0aa75d84
...
@@ -56,10 +56,17 @@ class DateIntervalType extends Type
...
@@ -56,10 +56,17 @@ class DateIntervalType extends Type
return
$value
;
return
$value
;
}
}
$negative
=
false
;
if
(
isset
(
$value
[
0
])
&&
(
$value
[
0
]
===
'+'
||
$value
[
0
]
===
'-'
))
{
$negative
=
$value
[
0
]
===
'-'
;
$value
=
substr
(
$value
,
1
);
}
try
{
try
{
$interval
=
new
\DateInterval
(
substr
(
$value
,
1
)
);
$interval
=
new
\DateInterval
(
$value
);
if
(
substr
(
$value
,
0
,
1
)
===
'-'
)
{
if
(
$negative
)
{
$interval
->
invert
=
1
;
$interval
->
invert
=
1
;
}
}
...
...
tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php
View file @
0aa75d84
...
@@ -67,6 +67,14 @@ final class DateIntervalTest extends DbalTestCase
...
@@ -67,6 +67,14 @@ final class DateIntervalTest extends DbalTestCase
self
::
assertEquals
(
'-P02Y00M01DT01H02M03S'
,
$interval
->
format
(
DateIntervalType
::
FORMAT
));
self
::
assertEquals
(
'-P02Y00M01DT01H02M03S'
,
$interval
->
format
(
DateIntervalType
::
FORMAT
));
}
}
public
function
testDateIntervalFormatWithoutSignConvertsToPHPValue
()
:
void
{
$interval
=
$this
->
type
->
convertToPHPValue
(
'P02Y00M01DT01H02M03S'
,
$this
->
platform
);
self
::
assertInstanceOf
(
\DateInterval
::
class
,
$interval
);
self
::
assertEquals
(
'+P02Y00M01DT01H02M03S'
,
$interval
->
format
(
DateIntervalType
::
FORMAT
));
}
public
function
testInvalidDateIntervalFormatConversion
()
:
void
public
function
testInvalidDateIntervalFormatConversion
()
:
void
{
{
$this
->
expectException
(
ConversionException
::
class
);
$this
->
expectException
(
ConversionException
::
class
);
...
@@ -79,6 +87,13 @@ final class DateIntervalTest extends DbalTestCase
...
@@ -79,6 +87,13 @@ final class DateIntervalTest extends DbalTestCase
self
::
assertNull
(
$this
->
type
->
convertToPHPValue
(
null
,
$this
->
platform
));
self
::
assertNull
(
$this
->
type
->
convertToPHPValue
(
null
,
$this
->
platform
));
}
}
public
function
testDateIntervalEmptyStringConversion
()
:
void
{
$this
->
expectException
(
ConversionException
::
class
);
$this
->
type
->
convertToPHPValue
(
''
,
$this
->
platform
);
}
/**
/**
* @group DBAL-1288
* @group DBAL-1288
*/
*/
...
...
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