forked from jenssegers/date
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
153 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<?php | ||
|
||
use Jenssegers\Date\Date; | ||
use Symfony\Component\Translation\Loader\ArrayLoader; | ||
use Symfony\Component\Translation\Translator; | ||
|
||
class TranslationHuTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function setUp() | ||
{ | ||
date_default_timezone_set('UTC'); | ||
Date::setLocale('hu'); | ||
} | ||
|
||
public function testGetsAndSetsTranslator() | ||
{ | ||
$translator = new Translator('hu'); | ||
$translator->addLoader('array', new ArrayLoader()); | ||
$this->assertNotEquals($translator, Date::getTranslator()); | ||
|
||
Date::setTranslator($translator); | ||
$this->assertEquals($translator, Date::getTranslator()); | ||
} | ||
|
||
public function testTimespanTranslated() | ||
{ | ||
$date = new Date(1403619368); | ||
$date = $date->sub('-100 days -3 hours -20 minutes'); | ||
|
||
$this->assertSame('3 hónap, 1 hét, 1 nap, 3 óra, 20 perc', $date->timespan(1403619368)); | ||
} | ||
|
||
public function testAgoTranslated() | ||
{ | ||
|
||
$date = Date::parse('-1 minute'); | ||
$this->assertSame('1 perce', $date->diffForHumans()); | ||
|
||
$date = Date::parse('-21 hours'); | ||
$this->assertSame('21 órája', $date->ago()); | ||
|
||
$date = Date::parse('-5 days'); | ||
$this->assertSame('5 napja', $date->ago()); | ||
|
||
$date = Date::parse('-3 weeks'); | ||
$this->assertSame('3 hete', $date->ago()); | ||
|
||
$date = Date::parse('-6 months'); | ||
$this->assertSame('6 hónapja', $date->ago()); | ||
|
||
$date = Date::parse('-10 years'); | ||
$this->assertSame('10 éve', $date->ago()); | ||
} | ||
|
||
public function testFromNowTranslated() | ||
{ | ||
|
||
$date = Date::parse('+1 minute'); | ||
$this->assertSame('1 perc múlva', $date->ago()); | ||
|
||
$date = Date::parse('+21 hours'); | ||
$this->assertSame('21 óra múlva', $date->ago()); | ||
|
||
$date = Date::parse('+5 days'); | ||
$this->assertSame('5 nap múlva', $date->ago()); | ||
|
||
$date = Date::parse('+3 weeks'); | ||
$this->assertSame('3 hét múlva', $date->ago()); | ||
|
||
$date = Date::parse('+6 months'); | ||
$this->assertSame('6 hónap múlva', $date->ago()); | ||
|
||
$date = Date::parse('+10 years'); | ||
$this->assertSame('10 év múlva', $date->ago()); | ||
} | ||
|
||
public function testAfterTranslated() | ||
{ | ||
$date = Date::parse('+21 hours'); | ||
$this->assertSame('21 órával később', $date->ago(Date::now())); | ||
|
||
$date = Date::parse('+5 days'); | ||
$this->assertSame('5 nappal később', $date->ago(Date::now())); | ||
|
||
$date = Date::parse('+3 weeks'); | ||
$this->assertSame('3 héttel később', $date->ago(Date::now())); | ||
|
||
$date = Date::parse('+6 months'); | ||
$this->assertSame('6 hónappal később', $date->ago(Date::now())); | ||
|
||
$date = Date::parse('+10 years'); | ||
$this->assertSame('10 évvel később', $date->ago(Date::now())); | ||
} | ||
|
||
public function testBeforeTranslated() | ||
{ | ||
$date = Date::parse('-21 hours'); | ||
$this->assertSame('21 órával korábban', $date->ago(Date::now())); | ||
|
||
$date = Date::parse('-5 days'); | ||
$this->assertSame('5 nappal korábban', $date->ago(Date::now())); | ||
|
||
$date = Date::parse('-3 weeks'); | ||
$this->assertSame('3 héttel korábban', $date->ago(Date::now())); | ||
|
||
$date = Date::parse('-6 months'); | ||
$this->assertSame('6 hónappal korábban', $date->ago(Date::now())); | ||
|
||
$date = Date::parse('-10 years'); | ||
$this->assertSame('10 évvel korábban', $date->ago(Date::now())); | ||
} | ||
|
||
public function testCreateFromFormat() | ||
{ | ||
$date = Date::createFromFormat('Y. F d.', '2015. január 1.'); | ||
$this->assertSame('2015-01-01', $date->format('Y-m-d')); | ||
|
||
$date = Date::createFromFormat('Y. F d., D', '2015. március 21., szombat'); | ||
$this->assertSame('2015-03-21', $date->format('Y-m-d')); | ||
} | ||
} |