mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 22:32:40 +08:00
PSR-2 compliance
This commit is contained in:
@ -180,7 +180,9 @@ class Formatter extends Component
|
|||||||
if ($value === null) {
|
if ($value === null) {
|
||||||
return $this->nullDisplay;
|
return $this->nullDisplay;
|
||||||
}
|
}
|
||||||
return str_replace('<p></p>', '',
|
return str_replace(
|
||||||
|
'<p></p>',
|
||||||
|
'',
|
||||||
'<p>' . preg_replace('/[\r\n]{2,}/', "</p>\n<p>", Html::encode($value)) . '</p>'
|
'<p>' . preg_replace('/[\r\n]{2,}/', "</p>\n<p>", Html::encode($value)) . '</p>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -269,7 +269,7 @@ class FormatterTest extends TestCase
|
|||||||
$dateThen = new DateTime('2014-02-28');
|
$dateThen = new DateTime('2014-02-28');
|
||||||
$this->assertSame('a month ago', $this->formatter->asRelativeTime($dateThen, $dateNow));
|
$this->assertSame('a month ago', $this->formatter->asRelativeTime($dateThen, $dateNow));
|
||||||
|
|
||||||
// Relative to current time tests (can't test with seconds though)
|
// Relative to current time tests (can't test with seconds though due to the tests computation time)
|
||||||
$this->assertSame('4 minutes ago', $this->formatter->asRelativeTime($this->buildDateSubIntervals('now', [$interval_244_seconds])));
|
$this->assertSame('4 minutes ago', $this->formatter->asRelativeTime($this->buildDateSubIntervals('now', [$interval_244_seconds])));
|
||||||
$this->assertSame('a minute ago', $this->formatter->asRelativeTime($this->buildDateSubIntervals('now', [$interval_1_minute])));
|
$this->assertSame('a minute ago', $this->formatter->asRelativeTime($this->buildDateSubIntervals('now', [$interval_1_minute])));
|
||||||
$this->assertSame('33 minutes ago', $this->formatter->asRelativeTime($this->buildDateSubIntervals('now', [$interval_33_minutes])));
|
$this->assertSame('33 minutes ago', $this->formatter->asRelativeTime($this->buildDateSubIntervals('now', [$interval_33_minutes])));
|
||||||
@ -335,7 +335,7 @@ class FormatterTest extends TestCase
|
|||||||
$this->assertSame('in a month', $this->formatter->asRelativeTime($this->buildDateSubIntervals('2014-03-03', [$interval_1_month]), $dateNow));
|
$this->assertSame('in a month', $this->formatter->asRelativeTime($this->buildDateSubIntervals('2014-03-03', [$interval_1_month]), $dateNow));
|
||||||
$this->assertSame('in 28 days', $this->formatter->asRelativeTime($dateThen, $dateNow));
|
$this->assertSame('in 28 days', $this->formatter->asRelativeTime($dateThen, $dateNow));
|
||||||
|
|
||||||
// Relative to current time tests (can't test with seconds though)
|
// Relative to current time tests (can't test with seconds though due to the tests computation time)
|
||||||
// We add 5 seconds to compensate for tests computation time
|
// We add 5 seconds to compensate for tests computation time
|
||||||
$interval_5_seconds = new DateInterval('PT5S');
|
$interval_5_seconds = new DateInterval('PT5S');
|
||||||
$interval_5_seconds->invert = true;
|
$interval_5_seconds->invert = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user