DateTest.php 17 KB

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