DeTest::testDiffForHumansLocalizedInGerman()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 33
rs 8.8571
cc 1
eloc 21
nc 1
nop 0
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
class DeTest extends AbstractTestCase
18
{
19
    public function testDiffForHumansLocalizedInGerman()
20
    {
21
        Date::setLocale('de');
22
23
        $scope = $this;
24
        $this->wrapWithTestNow(
25
            function () use ($scope) {
26
                $d = Date::now()->addYear();
27
                $scope->assertSame('in 1 Jahr', $d->diffForHumans());
28
29
                $d = Date::now()->addYears(2);
30
                $scope->assertSame('in 2 Jahren', $d->diffForHumans());
31
32
                $d = Date::now()->subYear();
33
                $scope->assertSame('1 Jahr später', Date::now()->diffForHumans($d));
34
35
                $d = Date::now()->subYears(2);
36
                $scope->assertSame('2 Jahre später', Date::now()->diffForHumans($d));
37
38
                $d = Date::now()->addYear();
39
                $scope->assertSame('1 Jahr zuvor', Date::now()->diffForHumans($d));
40
41
                $d = Date::now()->addYears(2);
42
                $scope->assertSame('2 Jahre zuvor', Date::now()->diffForHumans($d));
43
44
                $d = Date::now()->subYear();
45
                $scope->assertSame('vor 1 Jahr', $d->diffForHumans());
46
47
                $d = Date::now()->subYears(2);
48
                $scope->assertSame('vor 2 Jahren', $d->diffForHumans());
49
            }
50
        );
51
    }
52
}
53