8 protected function setUp() {
20 $this->assertInternalType(
'string',
$timestamp->getTimestamp() );
21 $this->assertNotEmpty(
$timestamp->getTimestamp() );
22 $this->assertNotEquals(
false, strtotime(
$timestamp->getTimestamp(
TS_MW ) ) );
30 $this->assertEquals(
'1406833268',
$timestamp->__toString() );
35 [
'1406833268',
'1406833269',
'00 00 00 01' ],
36 [
'1406833268',
'1406833329',
'00 00 01 01' ],
37 [
'1406833268',
'1406836929',
'00 01 01 01' ],
38 [
'1406833268',
'1406923329',
'01 01 01 01' ],
46 public function testDiff( $timestamp1, $timestamp2, $expected ) {
49 $diff = $timestamp1->diff( $timestamp2 );
50 $this->assertEquals( $expected, $diff->format(
'%D %H %I %S' ) );
70 $this->assertEquals( $expected, (
string)
$timestamp->getTimestamp( $format ) );
110 [
TS_UNIX,
'1343761268',
'20120731190108' ],
111 [
TS_MW,
'20120731190108',
'20120731190108' ],
112 [
TS_DB,
'2012-07-31 19:01:08',
'20120731190108' ],
113 [
TS_ISO_8601,
'2012-07-31T19:01:08Z',
'20120731190108' ],
115 [
TS_EXIF,
'2012:07:31 19:01:08',
'20120731190108' ],
116 [
TS_RFC2822,
'Tue, 31 Jul 2012 19:01:08 GMT',
'20120731190108' ],
117 [
TS_ORACLE,
'31-07-2012 19:01:08.000000',
'20120731190108' ],
118 [
TS_POSTGRES,
'2012-07-31 19:01:08 GMT',
'20120731190108' ],
120 [
TS_ISO_8601,
'9999-12-31T23:59:59Z',
'99991231235959' ],
121 [
TS_UNIX,
'-62135596801',
'00001231235959' ]
132 [
TS_MW,
'-62167219201' ],
133 [
TS_MW,
'253402300800' ],
149 $user = $this->getMock(
'User' );
150 $user->expects( $this->any() )
151 ->method(
'getOption' )
152 ->with(
'timecorrection' )
153 ->will( $this->returnValue( $timeCorrection ) );
155 $user->expects( $this->any() )
156 ->method(
'getDatePreference' )
157 ->will( $this->returnValue( $dateFormat ) );
164 $tsTime->getHumanTimestamp( $currentTime,
$user ),
176 'Yesterday at 17:00',
177 '"Yesterday" across years',
216 '15:15, January 30, 1991',
224 'Yesterday at 23:00',
225 '"Yesterday" across years with time correction',
233 'Recent weekday with time correction',
241 'Today at another time with time correction',
249 'Another month with dmy'
257 'Another month with ISO-8601'
264 '1991-01-30T15:15:00',
265 'Different year with ISO-8601',
282 $user = $this->getMock(
'User' );
283 $user->expects( $this->any() )
284 ->method(
'getOption' )
285 ->with(
'timecorrection' )
286 ->will( $this->returnValue( $timeCorrection ) );
293 $tsTime->getRelativeTimestamp( $currentTime,
$user ),
306 '"Yesterday" across years',
321 '6 minutes and 30 seconds ago',
322 'Combination of multiple units',
337 '2 decades, 1 year, 168 days, 2 hours, 8 minutes and 48 seconds ago',
346 '"Yesterday" across years with time correction',
354 'Recent weekday with time correction',
361 '9 hours and 17 minutes ago',
362 'Today at another time with time correction',
const TS_RFC2822
RFC 2822 format, for E-mail and HTTP headers.
testInvalidParse()
Test an invalid timestamp.
static provideHumanTimestampTests()
static provideValidTimestamps()
Returns a list of valid timestamps in the format: [ type, timestamp_of_type, timestamp_in_MW ]...
testToString()
MWTimestamp::__toString.
testOutOfRangeTimestamps($format, $input)
Test an out of range timestamp provideOutOfRangeTimestamps TimestampException MWTimestamp.
static provideOutOfRangeTimestamps()
Returns a list of out of range timestamps in the format: [ type, timestamp_of_type ]...
testValidOutput($format, $expected, $original)
Test outputting valid timestamps to different formats.
const TS_EXIF
An Exif timestamp (YYYY:MM:DD HH:MM:SS)
testHumanTimestamp($tsTime, $currentTime, $timeCorrection, $dateFormat, $expectedOutput, $desc)
provideHumanTimestampTests MWTimestamp::getHumanTimestamp
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
const TS_ORACLE
Oracle format time.
const TS_DB
MySQL DATETIME (YYYY-MM-DD HH:MM:SS)
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
static provideValidTimestampDifferences()
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
testValidParse($format, $original, $expected)
Test parsing of valid timestamps and outputing to MW format.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
testDiff($timestamp1, $timestamp2, $expected)
provideValidTimestampDifferences MWTimestamp::diff
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
testRelativeTimestamp($tsTime, $currentTime, $timeCorrection, $dateFormat, $expectedOutput, $desc)
provideRelativeTimestampTests MWTimestamp::getRelativeTimestamp
const TS_POSTGRES
Postgres format time.
Library for creating and parsing MW-style timestamps.
testInvalidOutput()
Test requesting an invalid output format.
testConstructWithNoTimestamp()
MWTimestamp::__construct.
static provideRelativeTimestampTests()
Tests timestamp parsing and output.
const TS_ISO_8601_BASIC
ISO 8601 basic format with no timezone: 19860209T200000Z.