1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace HMLB\Date\Tests\Localization; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Date package. |
7
|
|
|
* |
8
|
|
|
* (c) Hugues Maignol <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
use HMLB\Date\Date; |
15
|
|
|
use HMLB\Date\Tests\AbstractTestCase; |
16
|
|
|
|
17
|
|
View Code Duplication |
class FrTest extends AbstractTestCase |
|
|
|
|
18
|
|
|
{ |
19
|
|
|
public function testDiffForHumansLocalizedInFrench() |
20
|
|
|
{ |
21
|
|
|
Date::setLocale('fr'); |
22
|
|
|
|
23
|
|
|
$scope = $this; |
24
|
|
|
$this->wrapWithTestNow( |
25
|
|
|
function () use ($scope) { |
26
|
|
|
|
27
|
|
|
$d = Date::now()->subSecond(); |
28
|
|
|
$scope->assertSame('il y a 1 seconde', $d->diffForHumans()); |
29
|
|
|
|
30
|
|
|
$d = Date::now()->subSeconds(2); |
31
|
|
|
$scope->assertSame('il y a 2 secondes', $d->diffForHumans()); |
32
|
|
|
|
33
|
|
|
$d = Date::now()->subMinute(); |
34
|
|
|
$scope->assertSame('il y a 1 minute', $d->diffForHumans()); |
35
|
|
|
|
36
|
|
|
$d = Date::now()->subMinutes(2); |
37
|
|
|
$scope->assertSame('il y a 2 minutes', $d->diffForHumans()); |
38
|
|
|
|
39
|
|
|
$d = Date::now()->subHour(); |
40
|
|
|
$scope->assertSame('il y a 1 heure', $d->diffForHumans()); |
41
|
|
|
|
42
|
|
|
$d = Date::now()->subHours(2); |
43
|
|
|
$scope->assertSame('il y a 2 heures', $d->diffForHumans()); |
44
|
|
|
|
45
|
|
|
$d = Date::now()->subDay(); |
46
|
|
|
$scope->assertSame('il y a 1 jour', $d->diffForHumans()); |
47
|
|
|
|
48
|
|
|
$d = Date::now()->subDays(2); |
49
|
|
|
$scope->assertSame('il y a 2 jours', $d->diffForHumans()); |
50
|
|
|
|
51
|
|
|
$d = Date::now()->subWeek(); |
52
|
|
|
$scope->assertSame('il y a 1 semaine', $d->diffForHumans()); |
53
|
|
|
|
54
|
|
|
$d = Date::now()->subWeeks(2); |
55
|
|
|
$scope->assertSame('il y a 2 semaines', $d->diffForHumans()); |
56
|
|
|
|
57
|
|
|
$d = Date::now()->subMonth(); |
58
|
|
|
$scope->assertSame('il y a 1 mois', $d->diffForHumans()); |
59
|
|
|
|
60
|
|
|
$d = Date::now()->subMonths(2); |
61
|
|
|
$scope->assertSame('il y a 2 mois', $d->diffForHumans()); |
62
|
|
|
|
63
|
|
|
$d = Date::now()->subYear(); |
64
|
|
|
$scope->assertSame('il y a 1 an', $d->diffForHumans()); |
65
|
|
|
|
66
|
|
|
$d = Date::now()->subYears(2); |
67
|
|
|
$scope->assertSame('il y a 2 ans', $d->diffForHumans()); |
68
|
|
|
|
69
|
|
|
$d = Date::now()->addSecond(); |
70
|
|
|
$scope->assertSame('dans 1 seconde', $d->diffForHumans()); |
71
|
|
|
|
72
|
|
|
$d = Date::now()->addSecond(); |
73
|
|
|
$d2 = Date::now(); |
74
|
|
|
$scope->assertSame('1 seconde après', $d->diffForHumans($d2)); |
75
|
|
|
$scope->assertSame('1 seconde avant', $d2->diffForHumans($d)); |
76
|
|
|
|
77
|
|
|
$scope->assertSame('1 seconde', $d->diffForHumans($d2, true)); |
78
|
|
|
$scope->assertSame('2 secondes', $d2->diffForHumans($d->addSecond(), true)); |
79
|
|
|
} |
80
|
|
|
); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.