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
bc0a4a47
Commit
bc0a4a47
authored
Sep 05, 2015
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#869 - DBAL-1293 - restoring logic around summer time tests
parent
00595fc5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
13 deletions
+30
-13
DateTest.php
tests/Doctrine/Tests/DBAL/Types/DateTest.php
+30
-13
No files found.
tests/Doctrine/Tests/DBAL/Types/DateTest.php
View file @
bc0a4a47
...
...
@@ -10,22 +10,39 @@ class DateTest extends \Doctrine\Tests\DbalTestCase
/**
* @var MockPlatform
*/
private
$
_
platform
;
private
$platform
;
/**
* @var \Doctrine\DBAL\Types\DateType
*/
private
$
_
type
;
private
$type
;
/**
* @var string
*/
private
$currentTimezone
;
/**
* {@inheritDoc}
*/
protected
function
setUp
()
{
$this
->
_platform
=
new
MockPlatform
();
$this
->
_type
=
Type
::
getType
(
'date'
);
$this
->
platform
=
new
MockPlatform
();
$this
->
type
=
Type
::
getType
(
'date'
);
$this
->
currentTimezone
=
date_default_timezone_get
();
}
/**
* {@inheritDoc}
*/
protected
function
tearDown
()
{
date_default_timezone_set
(
$this
->
currentTimezone
);
}
public
function
testDateConvertsToDatabaseValue
()
{
$this
->
assertInternalType
(
'string'
,
$this
->
_type
->
convertToDatabaseValue
(
new
\DateTime
(),
$this
->
_
platform
));
$this
->
assertInternalType
(
'string'
,
$this
->
type
->
convertToDatabaseValue
(
new
\DateTime
(),
$this
->
platform
));
}
/**
...
...
@@ -37,21 +54,21 @@ class DateTest extends \Doctrine\Tests\DbalTestCase
{
$this
->
setExpectedException
(
'Doctrine\DBAL\Types\ConversionException'
);
$this
->
_type
->
convertToDatabaseValue
(
$value
,
$this
->
_
platform
);
$this
->
type
->
convertToDatabaseValue
(
$value
,
$this
->
platform
);
}
public
function
testDateConvertsToPHPValue
()
{
// Birthday of jwage and also birthday of Doctrine. Send him a present ;)
$this
->
assertTrue
(
$this
->
_type
->
convertToPHPValue
(
'1985-09-01'
,
$this
->
_
platform
)
$this
->
type
->
convertToPHPValue
(
'1985-09-01'
,
$this
->
platform
)
instanceof
\DateTime
);
}
public
function
testDateResetsNonDatePartsToZeroUnixTimeValues
()
{
$date
=
$this
->
_type
->
convertToPHPValue
(
'1985-09-01'
,
$this
->
_
platform
);
$date
=
$this
->
type
->
convertToPHPValue
(
'1985-09-01'
,
$this
->
platform
);
$this
->
assertEquals
(
'00:00:00'
,
$date
->
format
(
'H:i:s'
));
}
...
...
@@ -60,11 +77,11 @@ class DateTest extends \Doctrine\Tests\DbalTestCase
{
date_default_timezone_set
(
'Europe/Berlin'
);
$date
=
$this
->
_type
->
convertToPHPValue
(
'2009-08-01'
,
$this
->
_
platform
);
$date
=
$this
->
type
->
convertToPHPValue
(
'2009-08-01'
,
$this
->
platform
);
$this
->
assertEquals
(
'00:00:00'
,
$date
->
format
(
'H:i:s'
));
$this
->
assertEquals
(
'2009-08-01'
,
$date
->
format
(
'Y-m-d'
));
$date
=
$this
->
_type
->
convertToPHPValue
(
'2009-11-01'
,
$this
->
_
platform
);
$date
=
$this
->
type
->
convertToPHPValue
(
'2009-11-01'
,
$this
->
platform
);
$this
->
assertEquals
(
'00:00:00'
,
$date
->
format
(
'H:i:s'
));
$this
->
assertEquals
(
'2009-11-01'
,
$date
->
format
(
'Y-m-d'
));
}
...
...
@@ -72,18 +89,18 @@ class DateTest extends \Doctrine\Tests\DbalTestCase
public
function
testInvalidDateFormatConversion
()
{
$this
->
setExpectedException
(
'Doctrine\DBAL\Types\ConversionException'
);
$this
->
_type
->
convertToPHPValue
(
'abcdefg'
,
$this
->
_
platform
);
$this
->
type
->
convertToPHPValue
(
'abcdefg'
,
$this
->
platform
);
}
public
function
testNullConversion
()
{
$this
->
assertNull
(
$this
->
_type
->
convertToPHPValue
(
null
,
$this
->
_
platform
));
$this
->
assertNull
(
$this
->
type
->
convertToPHPValue
(
null
,
$this
->
platform
));
}
public
function
testConvertDateTimeToPHPValue
()
{
$date
=
new
\DateTime
(
"now"
);
$this
->
assertSame
(
$date
,
$this
->
_type
->
convertToPHPValue
(
$date
,
$this
->
_
platform
));
$this
->
assertSame
(
$date
,
$this
->
type
->
convertToPHPValue
(
$date
,
$this
->
platform
));
}
/**
...
...
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