DateTest.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  1. <?php defined('SYSPATH') OR die('Kohana bootstrap needs to be included before tests run');
  2. /**
  3. * Tests Date class
  4. *
  5. * @group kohana
  6. * @group kohana.core
  7. * @group kohana.core.date
  8. *
  9. * @package Kohana
  10. * @category Tests
  11. * @author Kohana Team
  12. * @author BRMatt <[email protected]>
  13. * @copyright (c) 2008-2012 Kohana Team
  14. * @license http://kohanaframework.org/license
  15. */
  16. class Kohana_DateTest extends Unittest_TestCase
  17. {
  18. protected $_original_timezone = NULL;
  19. /**
  20. * Ensures we have a consistant timezone for testing.
  21. */
  22. // @codingStandardsIgnoreStart
  23. public function setUp()
  24. // @codingStandardsIgnoreEnd
  25. {
  26. parent::setUp();
  27. $this->_original_timezone = date_default_timezone_get();
  28. date_default_timezone_set('America/Chicago');
  29. }
  30. /**
  31. * Restores original timezone after testing.
  32. */
  33. // @codingStandardsIgnoreStart
  34. public function tearDown()
  35. // @codingStandardsIgnoreEnd
  36. {
  37. date_default_timezone_set($this->_original_timezone);
  38. parent::tearDown();
  39. }
  40. /**
  41. * Provides test data for test_offset()
  42. *
  43. * @return array
  44. */
  45. public function provider_offset()
  46. {
  47. return array(
  48. array(30600, 'Asia/Calcutta', 'America/Argentina/Buenos_Aires'),
  49. );
  50. }
  51. /**
  52. * Tests Date::offset()
  53. *
  54. * @test
  55. * @dataProvider provider_offset
  56. * @covers Date::offset
  57. * @param integer $expected Expected offset
  58. * @param string $remote Remote TZ
  59. * @param string $local Local TZ
  60. * @param integer $now Current timestamp
  61. */
  62. public function test_offset($expected, $remote, $local, $now = NULL)
  63. {
  64. $this->assertSame($expected, Date::offset($remote, $local, $now));
  65. }
  66. /**
  67. * Provides test data for test_date()
  68. *
  69. * @return array
  70. */
  71. public function provider_am_pm()
  72. {
  73. return array(
  74. // All possible values
  75. array(0, 'AM'),
  76. array(1, 'AM'),
  77. array(2, 'AM'),
  78. array(3, 'AM'),
  79. array(4, 'AM'),
  80. array(5, 'AM'),
  81. array(6, 'AM'),
  82. array(7, 'AM'),
  83. array(8, 'AM'),
  84. array(9, 'AM'),
  85. array(10, 'AM'),
  86. array(11, 'AM'),
  87. array(12, 'PM'),
  88. array(13, 'PM'),
  89. array(14, 'PM'),
  90. array(15, 'PM'),
  91. array(16, 'PM'),
  92. array(17, 'PM'),
  93. array(18, 'PM'),
  94. array(19, 'PM'),
  95. array(20, 'PM'),
  96. array(21, 'PM'),
  97. array(22, 'PM'),
  98. array(23, 'PM'),
  99. array(24, 'PM'),
  100. // ampm doesn't validate the hour, so I don't think we should test it..
  101. // test strings are converted
  102. array('0', 'AM'),
  103. array('12', 'PM'),
  104. );
  105. }
  106. /**
  107. * Tests Date::ampm()
  108. *
  109. * @test
  110. * @covers Date::ampm
  111. * @dataProvider provider_am_pm
  112. * @param <type> $hour
  113. * @param <type> $expected
  114. */
  115. public function test_am_pm($hour, $expected)
  116. {
  117. $this->assertSame(
  118. $expected,
  119. Date::ampm($hour)
  120. );
  121. }
  122. /**
  123. * Provides test data for test_adjust()
  124. *
  125. * @return array
  126. */
  127. public function provider_adjust()
  128. {
  129. return array(
  130. // Might as well test all possibilities
  131. array(1, 'am', '01'),
  132. array(2, 'am', '02'),
  133. array(3, 'am', '03'),
  134. array(4, 'am', '04'),
  135. array(5, 'am', '05'),
  136. array(6, 'am', '06'),
  137. array(7, 'am', '07'),
  138. array(8, 'am', '08'),
  139. array(9, 'am', '09'),
  140. array(10, 'am', '10'),
  141. array(11, 'am', '11'),
  142. array(12, 'am', '00'),
  143. array(1, 'pm', '13'),
  144. array(2, 'pm', '14'),
  145. array(3, 'pm', '15'),
  146. array(4, 'pm', '16'),
  147. array(5, 'pm', '17'),
  148. array(6, 'pm', '18'),
  149. array(7, 'pm', '19'),
  150. array(8, 'pm', '20'),
  151. array(9, 'pm', '21'),
  152. array(10, 'pm', '22'),
  153. array(11, 'pm', '23'),
  154. array(12, 'pm', '12'),
  155. // It should also work with strings instead of ints
  156. array('10', 'pm', '22'),
  157. array('10', 'am', '10'),
  158. );
  159. }
  160. /**
  161. * Tests Date::ampm()
  162. *
  163. * @test
  164. * @dataProvider provider_adjust
  165. * @param integer $hour Hour in 12 hour format
  166. * @param string $ampm Either am or pm
  167. * @param string $expected Expected result
  168. */
  169. public function test_adjust($hour, $ampm, $expected)
  170. {
  171. $this->assertSame(
  172. $expected,
  173. Date::adjust($hour, $ampm)
  174. );
  175. }
  176. /**
  177. * Provides test data for test_days()
  178. *
  179. * @return array
  180. */
  181. public function provider_days()
  182. {
  183. return array(
  184. // According to "the rhyme" these should be the same every year
  185. array(9, FALSE, 30),
  186. array(4, FALSE, 30),
  187. array(6, FALSE, 30),
  188. array(11, FALSE, 30),
  189. array(1, FALSE, 31),
  190. array(3, FALSE, 31),
  191. array(5, FALSE, 31),
  192. array(7, FALSE, 31),
  193. array(8, FALSE, 31),
  194. array(10, FALSE, 31),
  195. // February is such a pain
  196. array(2, 2001, 28),
  197. array(2, 2000, 29),
  198. array(2, 2012, 29),
  199. );
  200. }
  201. /**
  202. * Tests Date::days()
  203. *
  204. * @test
  205. * @covers Date::days
  206. * @dataProvider provider_days
  207. * @param integer $month
  208. * @param integer $year
  209. * @param integer $expected
  210. */
  211. public function test_days($month, $year, $expected)
  212. {
  213. $days = Date::days($month, $year);
  214. $this->assertSame(
  215. $expected,
  216. count($days)
  217. );
  218. // This should be a mirrored array, days => days
  219. for ($i = 1; $i <= $expected; ++$i)
  220. {
  221. $this->assertArrayHasKey($i, $days);
  222. // Combining the type check into this saves about 400-500 assertions!
  223. $this->assertSame( (string) $i, $days[$i]);
  224. }
  225. }
  226. /**
  227. * Provides test data for test_formatted_time()
  228. *
  229. * @return array
  230. */
  231. public function provider_formatted_time()
  232. {
  233. return array(
  234. // Test the default format
  235. array('2010-04-16 17:00:00', '5:00PM 16th April 2010'),
  236. // Now we use our own format
  237. // Binary date!
  238. array('01/01/2010 01:00', '1AM 1st January 2010', 'd/m/Y H:i'),
  239. // Timezones (see #3902)
  240. array('2011-04-01 01:23:45 Antarctica/South_Pole', '2011-04-01 01:23:45', 'Y-m-d H:i:s e', 'Antarctica/South_Pole'),
  241. array('2011-04-01 01:23:45 Antarctica/South_Pole', '2011-03-31 14:23:45 Europe/Paris', 'Y-m-d H:i:s e', 'Antarctica/South_Pole'),
  242. array('2011-04-01 01:23:45 Antarctica/South_Pole', '@1301574225', 'Y-m-d H:i:s e', 'Antarctica/South_Pole'),
  243. );
  244. }
  245. /**
  246. * Tests Date::formatted_time()
  247. *
  248. * @test
  249. * @dataProvider provider_formatted_time
  250. * @covers Date::formatted_time
  251. * @ticket 3035 3902
  252. * @param string $expected Expected output
  253. * @param string|integer $datetime_str The datetime timestamp / string
  254. * @param string|null $timestamp_format The output format
  255. * @param string|null $timezone The timezone identifier
  256. */
  257. public function test_formatted_time($expected, $datetime_str, $timestamp_format = NULL, $timezone = NULL)
  258. {
  259. $timestamp = Date::formatted_time($datetime_str, $timestamp_format, $timezone);
  260. $this->assertSame($expected, $timestamp);
  261. }
  262. /**
  263. * Provider for test_months()
  264. *
  265. * @return array Test data
  266. */
  267. public function provider_months()
  268. {
  269. return array(
  270. array(
  271. array(
  272. 1 => "1",
  273. 2 => "2",
  274. 3 => "3",
  275. 4 => "4",
  276. 5 => "5",
  277. 6 => "6",
  278. 7 => "7",
  279. 8 => "8",
  280. 9 => "9",
  281. 10 => "10",
  282. 11 => "11",
  283. 12 => "12"
  284. ),
  285. NULL
  286. ),
  287. array(
  288. array(
  289. 1 => "1",
  290. 2 => "2",
  291. 3 => "3",
  292. 4 => "4",
  293. 5 => "5",
  294. 6 => "6",
  295. 7 => "7",
  296. 8 => "8",
  297. 9 => "9",
  298. 10 => "10",
  299. 11 => "11",
  300. 12 => "12"
  301. ),
  302. 'Guinness'
  303. ),
  304. array(
  305. array(
  306. 1 => "January",
  307. 2 => "February",
  308. 3 => "March",
  309. 4 => "April",
  310. 5 => "May",
  311. 6 => "June",
  312. 7 => "July",
  313. 8 => "August",
  314. 9 => "September",
  315. 10 => "October",
  316. 11 => "November",
  317. 12 => "December"
  318. ),
  319. Date::MONTHS_LONG
  320. ),
  321. array(
  322. array(
  323. 1 => "Jan",
  324. 2 => "Feb",
  325. 3 => "Mar",
  326. 4 => "Apr",
  327. 5 => "May",
  328. 6 => "Jun",
  329. 7 => "Jul",
  330. 8 => "Aug",
  331. 9 => "Sep",
  332. 10 => "Oct",
  333. 11 => "Nov",
  334. 12 => "Dec"
  335. ),
  336. Date::MONTHS_SHORT
  337. )
  338. );
  339. }
  340. /**
  341. * Date::months() should allow the user to specify different format types, defaulting
  342. * to a mirrored month number => month number array if format is NULL or unrecognised
  343. *
  344. * @test
  345. * @dataProvider provider_months
  346. * @covers Date::months
  347. */
  348. public function test_months($expected, $format)
  349. {
  350. $months = Date::months($format);
  351. $this->assertSame($expected, $months);
  352. }
  353. /**
  354. * Provides test data for test_span()
  355. *
  356. * @return array
  357. */
  358. public function provider_span()
  359. {
  360. $time = time();
  361. return array(
  362. // Test that it must specify an output format
  363. array(
  364. $time,
  365. $time,
  366. '',
  367. FALSE
  368. ),
  369. // Test that providing only one output just returns that output
  370. array(
  371. $time - 30,
  372. $time,
  373. 'seconds',
  374. 30
  375. ),
  376. // Random tests
  377. array(
  378. $time - 30,
  379. $time,
  380. 'years,months,weeks,days,hours,minutes,seconds',
  381. array('years' => 0, 'months' => 0, 'weeks' => 0, 'days' => 0, 'hours' => 0, 'minutes' => 0, 'seconds' => 30),
  382. ),
  383. array(
  384. $time - (60 * 60 * 24 * 782) + (60 * 25),
  385. $time,
  386. 'years,months,weeks,days,hours,minutes,seconds',
  387. array('years' => 2, 'months' => 1, 'weeks' => 3, 'days' => 0, 'hours' => 1, 'minutes' => 28, 'seconds' => 24),
  388. ),
  389. // Should be able to compare with the future & that it only uses formats specified
  390. array(
  391. $time + (60 * 60 * 24 * 15) + (60 * 5),
  392. $time,
  393. 'weeks,days,hours,minutes,seconds',
  394. array('weeks' => 2, 'days' => 1, 'hours' => 0, 'minutes' => 5, 'seconds' => 0),
  395. ),
  396. array(
  397. // Add a bit of extra time to account for phpunit processing
  398. $time + (14 * 31 * 24* 60 * 60) + (79 * 80),
  399. NULL,
  400. 'months,years',
  401. array('months' => 2, 'years' => 1),
  402. ),
  403. );
  404. }
  405. /**
  406. * Tests Date::span()
  407. *
  408. * @test
  409. * @covers Date::span
  410. * @dataProvider provider_span
  411. * @param integer $time1 Time in the past
  412. * @param integer $time2 Time to compare against
  413. * @param string $output Units to output
  414. * @param array $expected Array of $outputs => values
  415. */
  416. public function test_span($time1, $time2, $output, $expected)
  417. {
  418. $this->assertSame(
  419. $expected,
  420. Date::span($time1, $time2, $output)
  421. );
  422. }
  423. /**
  424. * Provides test data to test_fuzzy_span
  425. *
  426. * This test data is provided on the assumption that it
  427. * won't take phpunit more than 30 seconds to get the
  428. * data from this provider to the test... ;)
  429. *
  430. * @return array Test Data
  431. */
  432. public function provider_fuzzy_span()
  433. {
  434. $now = time();
  435. return array(
  436. array('moments ago', $now - 30, $now),
  437. array('in moments', $now + 30, $now),
  438. array('a few minutes ago', $now - 10*60, $now),
  439. array('in a few minutes', $now + 10*60, $now),
  440. array('less than an hour ago', $now - 45*60, $now),
  441. array('in less than an hour', $now + 45*60, $now),
  442. array('a couple of hours ago', $now - 2*60*60, $now),
  443. array('in a couple of hours', $now + 2*60*60, $now),
  444. array('less than a day ago', $now - 12*60*60, $now),
  445. array('in less than a day', $now + 12*60*60, $now),
  446. array('about a day ago', $now - 30*60*60, $now),
  447. array('in about a day', $now + 30*60*60, $now),
  448. array('a couple of days ago', $now - 3*24*60*60, $now),
  449. array('in a couple of days', $now + 3*24*60*60, $now),
  450. array('less than a week ago', $now - 5*24*60*60, $now),
  451. array('in less than a week', $now + 5*24*60*60, $now),
  452. array('about a week ago', $now - 9*24*60*60, $now),
  453. array('in about a week', $now + 9*24*60*60, $now),
  454. array('less than a month ago', $now - 20*24*60*60, $now),
  455. array('in less than a month', $now + 20*24*60*60, $now),
  456. array('about a month ago', $now - 40*24*60*60, $now),
  457. array('in about a month', $now + 40*24*60*60, $now),
  458. array('a couple of months ago', $now - 3*30*24*60*60, $now),
  459. array('in a couple of months', $now + 3*30*24*60*60, $now),
  460. array('less than a year ago', $now - 7*31*24*60*60, $now),
  461. array('in less than a year', $now + 7*31*24*60*60, $now),
  462. array('about a year ago', $now - 18*31*24*60*60, $now),
  463. array('in about a year', $now + 18*31*24*60*60, $now),
  464. array('a couple of years ago', $now - 3*12*31*24*60*60, $now),
  465. array('in a couple of years', $now + 3*12*31*24*60*60, $now),
  466. array('a few years ago', $now - 5*12*31*24*60*60, $now),
  467. array('in a few years', $now + 5*12*31*24*60*60, $now),
  468. array('about a decade ago', $now - 11*12*31*24*60*60, $now),
  469. array('in about a decade', $now + 11*12*31*24*60*60, $now),
  470. array('a couple of decades ago', $now - 20*12*31*24*60*60, $now),
  471. array('in a couple of decades', $now + 20*12*31*24*60*60, $now),
  472. array('several decades ago', $now - 50*12*31*24*60*60, $now),
  473. array('in several decades', $now + 50*12*31*24*60*60, $now),
  474. array('a long time ago', $now - pow(10,10), $now),
  475. array('in a long time', $now + pow(10,10), $now),
  476. );
  477. }
  478. /**
  479. * Test of Date::fuzy_span()
  480. *
  481. * @test
  482. * @dataProvider provider_fuzzy_span
  483. * @param string $expected Expected output
  484. * @param integer $timestamp Timestamp to use
  485. * @param integer $local_timestamp The local timestamp to use
  486. */
  487. public function test_fuzzy_span($expected, $timestamp, $local_timestamp)
  488. {
  489. $this->assertSame(
  490. $expected,
  491. Date::fuzzy_span($timestamp, $local_timestamp)
  492. );
  493. }
  494. /**
  495. * Provides test data for test_years()
  496. *
  497. * @return array Test Data
  498. */
  499. public function provider_years()
  500. {
  501. return array(
  502. array(
  503. array (
  504. 2005 => '2005',
  505. 2006 => '2006',
  506. 2007 => '2007',
  507. 2008 => '2008',
  508. 2009 => '2009',
  509. 2010 => '2010',
  510. 2011 => '2011',
  511. 2012 => '2012',
  512. 2013 => '2013',
  513. 2014 => '2014',
  514. 2015 => '2015',
  515. ),
  516. 2005,
  517. 2015
  518. ),
  519. );
  520. }
  521. /**
  522. * Tests Data::years()
  523. *
  524. * @test
  525. * @dataProvider provider_years
  526. */
  527. public function test_years($expected, $start = FALSE, $end = FALSE)
  528. {
  529. $this->assertSame(
  530. $expected,
  531. Date::years($start, $end)
  532. );
  533. }
  534. public function provider_hours()
  535. {
  536. return array(
  537. array(
  538. array(
  539. 1 => '1',
  540. 2 => '2',
  541. 3 => '3',
  542. 4 => '4',
  543. 5 => '5',
  544. 6 => '6',
  545. 7 => '7',
  546. 8 => '8',
  547. 9 => '9',
  548. 10 => '10',
  549. 11 => '11',
  550. 12 => '12',
  551. ),
  552. ),
  553. );
  554. }
  555. /**
  556. * Test for Date::hours
  557. *
  558. * @test
  559. * @dataProvider provider_hours
  560. */
  561. public function test_hours($expected, $step = 1, $long = FALSE, $start = NULL)
  562. {
  563. $this->assertSame(
  564. $expected,
  565. Date::hours($step, $long, $start)
  566. );
  567. }
  568. /**
  569. * Provides test data for test_seconds
  570. *
  571. * @return array Test data
  572. */
  573. public function provider_seconds()
  574. {
  575. return array(
  576. array(
  577. // Thank god for var_export()
  578. array (
  579. 0 => '00', 1 => '01', 2 => '02', 3 => '03', 4 => '04',
  580. 5 => '05', 6 => '06', 7 => '07', 8 => '08', 9 => '09',
  581. 10 => '10', 11 => '11', 12 => '12', 13 => '13', 14 => '14',
  582. 15 => '15', 16 => '16', 17 => '17', 18 => '18', 19 => '19',
  583. 20 => '20', 21 => '21', 22 => '22', 23 => '23', 24 => '24',
  584. 25 => '25', 26 => '26', 27 => '27', 28 => '28', 29 => '29',
  585. 30 => '30', 31 => '31', 32 => '32', 33 => '33', 34 => '34',
  586. 35 => '35', 36 => '36', 37 => '37', 38 => '38', 39 => '39',
  587. 40 => '40', 41 => '41', 42 => '42', 43 => '43', 44 => '44',
  588. 45 => '45', 46 => '46', 47 => '47', 48 => '48', 49 => '49',
  589. 50 => '50', 51 => '51', 52 => '52', 53 => '53', 54 => '54',
  590. 55 => '55', 56 => '56', 57 => '57', 58 => '58', 59 => '59',
  591. ),
  592. 1,
  593. 0,
  594. 60
  595. ),
  596. );
  597. }
  598. /**
  599. *
  600. * @test
  601. * @dataProvider provider_seconds
  602. * @covers Date::seconds
  603. */
  604. public function test_seconds($expected, $step = 1, $start = 0, $end = 60)
  605. {
  606. $this->assertSame(
  607. $expected,
  608. Date::seconds($step, $start, $end)
  609. );
  610. }
  611. /**
  612. * Provides test data for test_minutes
  613. *
  614. * @return array Test data
  615. */
  616. public function provider_minutes()
  617. {
  618. return array(
  619. array(
  620. array(
  621. 0 => '00', 5 => '05', 10 => '10',
  622. 15 => '15', 20 => '20', 25 => '25',
  623. 30 => '30', 35 => '35', 40 => '40',
  624. 45 => '45', 50 => '50', 55 => '55',
  625. ),
  626. 5,
  627. ),
  628. );
  629. }
  630. /**
  631. *
  632. * @test
  633. * @dataProvider provider_minutes
  634. */
  635. public function test_minutes($expected, $step)
  636. {
  637. $this->assertSame(
  638. $expected,
  639. Date::minutes($step)
  640. );
  641. }
  642. /**
  643. * This tests that the minutes helper defaults to using a $step of 5
  644. * and thus returns an array of 5 minute itervals
  645. *
  646. * @test
  647. * @covers Date::minutes
  648. */
  649. public function test_minutes_defaults_to_using_step_of5()
  650. {
  651. $minutes = array(
  652. 0 => '00', 5 => '05', 10 => '10',
  653. 15 => '15', 20 => '20', 25 => '25',
  654. 30 => '30', 35 => '35', 40 => '40',
  655. 45 => '45', 50 => '50', 55 => '55',
  656. );
  657. $this->assertSame(
  658. $minutes,
  659. Date::minutes()
  660. );
  661. }
  662. /**
  663. * Provids for test_unix2dos
  664. *
  665. * @return array Test Data
  666. */
  667. public function provider_unix2dos()
  668. {
  669. return array(
  670. array(
  671. 1024341746,
  672. 1281786936
  673. ),
  674. array(
  675. 2162688,
  676. 315554400
  677. )
  678. );
  679. }
  680. /**
  681. * Test Date::unix2dos()
  682. *
  683. * You should always pass a timestamp as otherwise the current
  684. * date/time would be used and that's oviously variable
  685. *
  686. * Geert seems to be the only person who knows how unix2dos() works
  687. * so we just throw in some random values and see what happens
  688. *
  689. * @test
  690. * @dataProvider provider_unix2dos
  691. * @covers Date::unix2dos
  692. * @param integer $expected Expected output
  693. * @param integer $timestamp Input timestamp
  694. */
  695. public function test_unix2dos($expected, $timestamp)
  696. {
  697. $this->assertSame($expected, Date::unix2dos($timestamp));
  698. }
  699. /**
  700. * Provides test data for test_dos2unix
  701. *
  702. * @return array Test data
  703. */
  704. public function provider_dos2unix()
  705. {
  706. return array(
  707. array(
  708. 1281786936,
  709. 1024341746,
  710. ),
  711. array(
  712. 315554400,
  713. 2162688,
  714. ),
  715. );
  716. }
  717. /**
  718. * Tests Date::dos2unix
  719. *
  720. * @test
  721. * @dataProvider provider_dos2unix
  722. * @param integer $expected Expected output
  723. * @param integer $timestamp Input timestamp
  724. */
  725. public function test_dos2unix($expected, $timestamp)
  726. {
  727. $this->assertEquals($expected, Date::dos2unix($timestamp));
  728. }
  729. }