for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SMW\Tests;
use SMWDITime as DITime;
/**
* @covers \SMWDITime
*
* @license GNU GPL v2+
* @since 2.4
* @author mwjames
*/
class DITimeTest extends \PHPUnit_Framework_TestCase {
public function testCanConstruct() {
$this->assertInstanceOf(
'\SMWDITime',
new DITime( DITime::CM_GREGORIAN, 1970 )
);
}
public function testNewFromTimestamp() {
$instance = DITime::newFromTimestamp( '1362200400' );
$instance
public function testNewFromDateTime() {
$instance = DITime::newFromDateTime(
new \DateTime( '2012-07-08 11:14:15.638276' )
$this->assertEquals(
'15.638276',
$instance->getSecond()
new \DateTime( '1582-10-04' )
DITime::CM_JULIAN,
$instance->getCalendarModel()
new \DateTime( '1582-10-05' )
DITime::CM_GREGORIAN,
public function testDateTimeRoundTrip() {
$dateTime = new \DateTime( '2012-07-08 11:14:15.638276' );
$dateTime
$dateTime,
$instance->asDateTime()
public function testDateTimeWithLargeMs() {
$dateTime = new \DateTime( '1300-11-02 12:03:25.888500' );
$instance = new DITime(
2, 1300, 11, 02, 12, 03, 25.888499949
11
integer
boolean
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
2
12
3
25.888499949
double
public function testDateTimeWithHistoricDate() {
$dateTime = new \DateTime( '-0900-02-02 00:00:00' );
2, -900, 02, 02
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: