CakeNumberTest.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. <?php
  2. /**
  3. * CakeNumberTest file
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
  8. * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice
  12. *
  13. * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
  15. * @package Cake.Test.Case.View.Helper
  16. * @since CakePHP(tm) v 1.2.0.4206
  17. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  18. */
  19. App::uses('View', 'View');
  20. App::uses('CakeNumber', 'Utility');
  21. /**
  22. * CakeNumberTest class
  23. *
  24. * @package Cake.Test.Case.Utility
  25. */
  26. class CakeNumberTest extends CakeTestCase {
  27. /**
  28. * setUp method
  29. *
  30. * @return void
  31. */
  32. public function setUp() {
  33. parent::setUp();
  34. $this->Number = new CakeNumber();
  35. }
  36. /**
  37. * tearDown method
  38. *
  39. * @return void
  40. */
  41. public function tearDown() {
  42. parent::tearDown();
  43. unset($this->Number);
  44. }
  45. /**
  46. * testFormatAndCurrency method
  47. *
  48. * @return void
  49. */
  50. public function testFormat() {
  51. $value = '100100100';
  52. $result = $this->Number->format($value, '#');
  53. $expected = '#100,100,100';
  54. $this->assertEquals($expected, $result);
  55. $result = $this->Number->format($value, 3);
  56. $expected = '100,100,100.000';
  57. $this->assertEquals($expected, $result);
  58. $result = $this->Number->format($value);
  59. $expected = '100,100,100';
  60. $this->assertEquals($expected, $result);
  61. $result = $this->Number->format($value, '-');
  62. $expected = '100-100-100';
  63. $this->assertEquals($expected, $result);
  64. $value = 0.00001;
  65. $result = $this->Number->format($value, array('places' => 1));
  66. $expected = '$0.0';
  67. $this->assertEquals($expected, $result);
  68. $value = -0.00001;
  69. $result = $this->Number->format($value, array('places' => 1));
  70. $expected = '$0.0';
  71. $this->assertEquals($expected, $result);
  72. }
  73. /**
  74. * testFormatDelta method
  75. *
  76. * @return void
  77. */
  78. public function testFormatDelta() {
  79. $value = '100100100';
  80. $result = $this->Number->formatDelta($value);
  81. $expected = '+100,100,100.00';
  82. $this->assertEquals($expected, $result);
  83. $result = $this->Number->formatDelta($value, array('before' => '', 'after' => ''));
  84. $expected = '+100,100,100.00';
  85. $this->assertEquals($expected, $result);
  86. $result = $this->Number->formatDelta($value, array('before' => '[', 'after' => ']'));
  87. $expected = '[+100,100,100.00]';
  88. $this->assertEquals($expected, $result);
  89. $result = $this->Number->formatDelta(-$value, array('before' => '[', 'after' => ']'));
  90. $expected = '[-100,100,100.00]';
  91. $this->assertEquals($expected, $result);
  92. $value = 0;
  93. $result = $this->Number->formatDelta($value, array('places' => 1, 'before' => '[', 'after' => ']'));
  94. $expected = '[0.0]';
  95. $this->assertEquals($expected, $result);
  96. $value = 0.0001;
  97. $result = $this->Number->formatDelta($value, array('places' => 1, 'before' => '[', 'after' => ']'));
  98. $expected = '[0.0]';
  99. $this->assertEquals($expected, $result);
  100. $value = 9876.1234;
  101. $result = $this->Number->formatDelta($value, array('places' => 1, 'decimals' => ',', 'thousands' => '.'));
  102. $expected = '+9.876,1';
  103. $this->assertEquals($expected, $result);
  104. }
  105. /**
  106. * testMultibyteFormat
  107. *
  108. * @return void
  109. */
  110. public function testMultibyteFormat() {
  111. $value = '5199100.0006';
  112. $result = $this->Number->format($value, array(
  113. 'thousands' => '&nbsp;',
  114. 'decimals' => '&amp;',
  115. 'places' => 3,
  116. 'escape' => false,
  117. 'before' => '',
  118. ));
  119. $expected = '5&nbsp;199&nbsp;100&amp;001';
  120. $this->assertEquals($expected, $result);
  121. $value = 1000.45;
  122. $result = $this->Number->format($value, array(
  123. 'thousands' => ',,',
  124. 'decimals' => '.a',
  125. 'escape' => false,
  126. ));
  127. $expected = '$1,,000.a45';
  128. $this->assertEquals($expected, $result);
  129. $value = 519919827593784.00;
  130. $this->Number->addFormat('RUR', array(
  131. 'thousands' => 'ø€ƒ‡™',
  132. 'decimals' => '(§.§)',
  133. 'escape' => false,
  134. 'wholeSymbol' => '€',
  135. 'wholePosition' => 'after',
  136. ));
  137. $result = $this->Number->currency($value, 'RUR');
  138. $expected = '519ø€ƒ‡™919ø€ƒ‡™827ø€ƒ‡™593ø€ƒ‡™784(§.§)00€';
  139. $this->assertEquals($expected, $result);
  140. $value = '13371337.1337';
  141. $result = CakeNumber::format($value, array(
  142. 'thousands' => '- |-| /-\ >< () |2 -',
  143. 'decimals' => '- £€€† -',
  144. 'before' => ''
  145. ));
  146. $expected = '13- |-| /-\ &gt;&lt; () |2 -371- |-| /-\ &gt;&lt; () |2 -337- £€€† -13';
  147. $this->assertEquals($expected, $result);
  148. }
  149. /**
  150. * Test currency method.
  151. *
  152. * @return void
  153. */
  154. public function testCurrency() {
  155. $value = '100100100';
  156. $result = $this->Number->currency($value);
  157. $expected = '$100,100,100.00';
  158. $this->assertEquals($expected, $result);
  159. $result = $this->Number->currency($value, '#');
  160. $expected = '#100,100,100.00';
  161. $this->assertEquals($expected, $result);
  162. $result = $this->Number->currency($value, false);
  163. $expected = '100,100,100.00';
  164. $this->assertEquals($expected, $result);
  165. $result = $this->Number->currency($value, 'USD');
  166. $expected = '$100,100,100.00';
  167. $this->assertEquals($expected, $result);
  168. $result = $this->Number->currency($value, 'EUR');
  169. $expected = '&#8364;100.100.100,00';
  170. $this->assertEquals($expected, $result);
  171. $result = $this->Number->currency($value, 'GBP');
  172. $expected = '&#163;100,100,100.00';
  173. $this->assertEquals($expected, $result);
  174. $result = $this->Number->currency($value, '', array('thousands' => ' ', 'wholeSymbol' => '€', 'wholePosition' => 'after', 'decimals' => ',', 'zero' => 'Gratuit'));
  175. $expected = '100 100 100,00€';
  176. $this->assertEquals($expected, $result);
  177. $result = $this->Number->currency(1000.45, null, array('after' => 'øre', 'before' => 'Kr. ', 'decimals' => ',', 'thousands' => '.'));
  178. $expected = 'Kr. 1.000,45';
  179. $this->assertEquals($expected, $result);
  180. $result = $this->Number->currency(0.5, 'USD');
  181. $expected = '50c';
  182. $this->assertEquals($expected, $result);
  183. $result = $this->Number->currency(0.5, null, array('after' => 'øre'));
  184. $expected = '50øre';
  185. $this->assertEquals($expected, $result);
  186. $result = $this->Number->currency(1, null, array('wholeSymbol' => '$ '));
  187. $expected = '$ 1.00';
  188. $this->assertEquals($expected, $result);
  189. $result = $this->Number->currency(1, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after'));
  190. $expected = '1.00 $';
  191. $this->assertEquals($expected, $result);
  192. $result = $this->Number->currency(0.2, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after', 'fractionSymbol' => 'cents'));
  193. $expected = '20cents';
  194. $this->assertEquals($expected, $result);
  195. $result = $this->Number->currency(0.2, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after', 'fractionSymbol' => 'cents', 'fractionPosition' => 'before'));
  196. $expected = 'cents20';
  197. $this->assertEquals($expected, $result);
  198. $result = $this->Number->currency(311, 'USD', array('wholePosition' => 'after'));
  199. $expected = '311.00$';
  200. $this->assertEquals($expected, $result);
  201. $result = $this->Number->currency(0.2, 'EUR');
  202. $expected = '&#8364;0,20';
  203. $this->assertEquals($expected, $result);
  204. $result = $this->Number->currency(12, null, array('wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents', 'fractionPosition' => 'after'));
  205. $expected = '12.00 dollars';
  206. $this->assertEquals($expected, $result);
  207. $result = $this->Number->currency(0.12, null, array('wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents', 'fractionPosition' => 'after'));
  208. $expected = '12 cents';
  209. $this->assertEquals($expected, $result);
  210. $result = $this->Number->currency(0.5, null, array('fractionSymbol' => false, 'fractionPosition' => 'before', 'wholeSymbol' => '$'));
  211. $expected = '$0.50';
  212. $this->assertEquals($expected, $result);
  213. $result = $this->Number->currency(0, 'GBP');
  214. $expected = '&#163;0.00';
  215. $this->assertEquals($expected, $result);
  216. $result = $this->Number->currency(0.00000, 'GBP');
  217. $expected = '&#163;0.00';
  218. $this->assertEquals($expected, $result);
  219. $result = $this->Number->currency('0.00000', 'GBP');
  220. $expected = '&#163;0.00';
  221. $this->assertEquals($expected, $result);
  222. }
  223. /**
  224. * Test adding currency format options to the number helper
  225. *
  226. * @return void
  227. */
  228. public function testCurrencyAddFormat() {
  229. $this->Number->addFormat('NOK', array('before' => 'Kr. '));
  230. $result = $this->Number->currency(1000, 'NOK');
  231. $expected = 'Kr. 1,000.00';
  232. $this->assertEquals($expected, $result);
  233. $this->Number->addFormat('Other', array('before' => '$$ ', 'after' => 'c!'));
  234. $result = $this->Number->currency(0.22, 'Other');
  235. $expected = '22c!';
  236. $this->assertEquals($expected, $result);
  237. $result = $this->Number->currency(-10, 'Other');
  238. $expected = '($$ 10.00)';
  239. $this->assertEquals($expected, $result);
  240. $this->Number->addFormat('Other2', array('before' => '$ ', 'after' => false));
  241. $result = $this->Number->currency(0.22, 'Other2');
  242. $expected = '$ 0.22';
  243. $this->assertEquals($expected, $result);
  244. }
  245. /**
  246. * Test default currency
  247. *
  248. * @return void
  249. */
  250. public function testDefaultCurrency() {
  251. $result = $this->Number->defaultCurrency();
  252. $this->assertEquals('USD', $result);
  253. $this->Number->addFormat('NOK', array('before' => 'Kr. '));
  254. $this->Number->defaultCurrency('NOK');
  255. $result = $this->Number->defaultCurrency();
  256. $this->assertEquals('NOK', $result);
  257. $result = $this->Number->currency(1000);
  258. $expected = 'Kr. 1,000.00';
  259. $this->assertEquals($expected, $result);
  260. $result = $this->Number->currency(2000);
  261. $expected = 'Kr. 2,000.00';
  262. $this->assertEquals($expected, $result);
  263. $this->Number->defaultCurrency('EUR');
  264. $result = $this->Number->currency(1000);
  265. $expected = '&#8364;1.000,00';
  266. $this->assertEquals($expected, $result);
  267. $result = $this->Number->currency(2000);
  268. $expected = '&#8364;2.000,00';
  269. $this->assertEquals($expected, $result);
  270. $this->Number->defaultCurrency('USD');
  271. }
  272. /**
  273. * testCurrencyPositive method
  274. *
  275. * @return void
  276. */
  277. public function testCurrencyPositive() {
  278. $value = '100100100';
  279. $result = $this->Number->currency($value);
  280. $expected = '$100,100,100.00';
  281. $this->assertEquals($expected, $result);
  282. $result = $this->Number->currency($value, 'USD', array('before' => '#'));
  283. $expected = '#100,100,100.00';
  284. $this->assertEquals($expected, $result);
  285. $result = $this->Number->currency($value, false);
  286. $expected = '100,100,100.00';
  287. $this->assertEquals($expected, $result);
  288. $result = $this->Number->currency($value, 'USD');
  289. $expected = '$100,100,100.00';
  290. $this->assertEquals($expected, $result);
  291. $result = $this->Number->currency($value, 'EUR');
  292. $expected = '&#8364;100.100.100,00';
  293. $this->assertEquals($expected, $result);
  294. $result = $this->Number->currency($value, 'GBP');
  295. $expected = '&#163;100,100,100.00';
  296. $this->assertEquals($expected, $result);
  297. }
  298. /**
  299. * testCurrencyNegative method
  300. *
  301. * @return void
  302. */
  303. public function testCurrencyNegative() {
  304. $value = '-100100100';
  305. $result = $this->Number->currency($value);
  306. $expected = '($100,100,100.00)';
  307. $this->assertEquals($expected, $result);
  308. $result = $this->Number->currency($value, 'EUR');
  309. $expected = '(&#8364;100.100.100,00)';
  310. $this->assertEquals($expected, $result);
  311. $result = $this->Number->currency($value, 'GBP');
  312. $expected = '(&#163;100,100,100.00)';
  313. $this->assertEquals($expected, $result);
  314. $result = $this->Number->currency($value, 'USD', array('negative' => '-'));
  315. $expected = '-$100,100,100.00';
  316. $this->assertEquals($expected, $result);
  317. $result = $this->Number->currency($value, 'EUR', array('negative' => '-'));
  318. $expected = '-&#8364;100.100.100,00';
  319. $this->assertEquals($expected, $result);
  320. $result = $this->Number->currency($value, 'GBP', array('negative' => '-'));
  321. $expected = '-&#163;100,100,100.00';
  322. $this->assertEquals($expected, $result);
  323. }
  324. /**
  325. * testCurrencyCentsPositive method
  326. *
  327. * @return void
  328. */
  329. public function testCurrencyCentsPositive() {
  330. $value = '0.99';
  331. $result = $this->Number->currency($value, 'USD');
  332. $expected = '99c';
  333. $this->assertEquals($expected, $result);
  334. $result = $this->Number->currency($value, 'EUR');
  335. $expected = '&#8364;0,99';
  336. $this->assertEquals($expected, $result);
  337. $result = $this->Number->currency($value, 'GBP');
  338. $expected = '99p';
  339. $this->assertEquals($expected, $result);
  340. }
  341. /**
  342. * testCurrencyCentsNegative method
  343. *
  344. * @return void
  345. */
  346. public function testCurrencyCentsNegative() {
  347. $value = '-0.99';
  348. $result = $this->Number->currency($value, 'USD');
  349. $expected = '(99c)';
  350. $this->assertEquals($expected, $result);
  351. $result = $this->Number->currency($value, 'EUR');
  352. $expected = '(&#8364;0,99)';
  353. $this->assertEquals($expected, $result);
  354. $result = $this->Number->currency($value, 'GBP');
  355. $expected = '(99p)';
  356. $this->assertEquals($expected, $result);
  357. $result = $this->Number->currency($value, 'USD', array('negative' => '-'));
  358. $expected = '-99c';
  359. $this->assertEquals($expected, $result);
  360. $result = $this->Number->currency($value, 'EUR', array('negative' => '-'));
  361. $expected = '-&#8364;0,99';
  362. $this->assertEquals($expected, $result);
  363. $result = $this->Number->currency($value, 'GBP', array('negative' => '-'));
  364. $expected = '-99p';
  365. $this->assertEquals($expected, $result);
  366. }
  367. /**
  368. * testCurrencyZero method
  369. *
  370. * @return void
  371. */
  372. public function testCurrencyZero() {
  373. $value = '0';
  374. $result = $this->Number->currency($value, 'USD');
  375. $expected = '$0.00';
  376. $this->assertEquals($expected, $result);
  377. $result = $this->Number->currency($value, 'EUR');
  378. $expected = '&#8364;0,00';
  379. $this->assertEquals($expected, $result);
  380. $result = $this->Number->currency($value, 'GBP');
  381. $expected = '&#163;0.00';
  382. $this->assertEquals($expected, $result);
  383. $result = $this->Number->currency($value, 'GBP', array('zero' => 'FREE!'));
  384. $expected = 'FREE!';
  385. $this->assertEquals($expected, $result);
  386. }
  387. /**
  388. * testCurrencyOptions method
  389. *
  390. * @return void
  391. */
  392. public function testCurrencyOptions() {
  393. $value = '1234567.89';
  394. $result = $this->Number->currency($value, null, array('before' => 'GBP'));
  395. $expected = 'GBP1,234,567.89';
  396. $this->assertEquals($expected, $result);
  397. $result = $this->Number->currency($value, 'GBP', array('places' => 0));
  398. $expected = '&#163;1,234,568';
  399. $this->assertEquals($expected, $result);
  400. $result = $this->Number->currency('1234567.8912345', null, array('before' => 'GBP', 'places' => 3));
  401. $expected = 'GBP1,234,567.891';
  402. $this->assertEquals($expected, $result);
  403. $result = $this->Number->currency('650.120001', null, array('before' => 'GBP', 'places' => 4));
  404. $expected = 'GBP650.1200';
  405. $this->assertEquals($expected, $result);
  406. $result = $this->Number->currency($value, 'GBP', array('escape' => true));
  407. $expected = '&amp;#163;1,234,567.89';
  408. $this->assertEquals($expected, $result);
  409. $result = $this->Number->currency('0.35', 'USD', array('after' => false));
  410. $expected = '$0.35';
  411. $this->assertEquals($expected, $result);
  412. $result = $this->Number->currency('0.35', 'GBP', array('after' => false));
  413. $expected = '&#163;0.35';
  414. $this->assertEquals($expected, $result);
  415. $result = $this->Number->currency('0.35', 'GBP');
  416. $expected = '35p';
  417. $this->assertEquals($expected, $result);
  418. $result = $this->Number->currency('0.35', 'EUR');
  419. $expected = '&#8364;0,35';
  420. $this->assertEquals($expected, $result);
  421. }
  422. /**
  423. * testToReadableSize method
  424. *
  425. * @return void
  426. */
  427. public function testToReadableSize() {
  428. $result = $this->Number->toReadableSize(0);
  429. $expected = '0 Bytes';
  430. $this->assertEquals($expected, $result);
  431. $result = $this->Number->toReadableSize(1);
  432. $expected = '1 Byte';
  433. $this->assertEquals($expected, $result);
  434. $result = $this->Number->toReadableSize(45);
  435. $expected = '45 Bytes';
  436. $this->assertEquals($expected, $result);
  437. $result = $this->Number->toReadableSize(1023);
  438. $expected = '1023 Bytes';
  439. $this->assertEquals($expected, $result);
  440. $result = $this->Number->toReadableSize(1024);
  441. $expected = '1 KB';
  442. $this->assertEquals($expected, $result);
  443. $result = $this->Number->toReadableSize(1024 * 512);
  444. $expected = '512 KB';
  445. $this->assertEquals($expected, $result);
  446. $result = $this->Number->toReadableSize(1024 * 1024 - 1);
  447. $expected = '1.00 MB';
  448. $this->assertEquals($expected, $result);
  449. $result = $this->Number->toReadableSize(1024 * 1024 * 512);
  450. $expected = '512.00 MB';
  451. $this->assertEquals($expected, $result);
  452. $result = $this->Number->toReadableSize(1024 * 1024 * 1024 - 1);
  453. $expected = '1.00 GB';
  454. $this->assertEquals($expected, $result);
  455. $result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 512);
  456. $expected = '512.00 GB';
  457. $this->assertEquals($expected, $result);
  458. $result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 1024 - 1);
  459. $expected = '1.00 TB';
  460. $this->assertEquals($expected, $result);
  461. $result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 1024 * 512);
  462. $expected = '512.00 TB';
  463. $this->assertEquals($expected, $result);
  464. $result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 1024 * 1024 - 1);
  465. $expected = '1024.00 TB';
  466. $this->assertEquals($expected, $result);
  467. $result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 1024 * 1024 * 1024);
  468. $expected = (1024 * 1024) . '.00 TB';
  469. $this->assertEquals($expected, $result);
  470. }
  471. /**
  472. * test toReadableSize() with locales
  473. *
  474. * @return void
  475. */
  476. public function testReadableSizeLocalized() {
  477. $restore = setlocale(LC_NUMERIC, 0);
  478. setlocale(LC_NUMERIC, 'de_DE');
  479. $result = $this->Number->toReadableSize(1321205);
  480. $this->assertRegExp('/1[,.]26 MB/', $result);
  481. $result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 512);
  482. $this->assertRegExp('/512[,.]00 GB/', $result);
  483. setlocale(LC_NUMERIC, $restore);
  484. }
  485. /**
  486. * testToPercentage method
  487. *
  488. * @return void
  489. */
  490. public function testToPercentage() {
  491. $result = $this->Number->toPercentage(45, 0);
  492. $expected = '45%';
  493. $this->assertEquals($expected, $result);
  494. $result = $this->Number->toPercentage(45, 2);
  495. $expected = '45.00%';
  496. $this->assertEquals($expected, $result);
  497. $result = $this->Number->toPercentage(0, 0);
  498. $expected = '0%';
  499. $this->assertEquals($expected, $result);
  500. $result = $this->Number->toPercentage(0, 4);
  501. $expected = '0.0000%';
  502. $this->assertEquals($expected, $result);
  503. }
  504. /**
  505. * testFromReadableSize
  506. *
  507. * @dataProvider filesizes
  508. * @return void
  509. */
  510. public function testFromReadableSize($params, $expected) {
  511. $result = $this->Number->fromReadableSize($params['size'], $params['default']);
  512. $this->assertEquals($expected, $result);
  513. }
  514. /**
  515. * testFromReadableSize
  516. *
  517. * @expectedException CakeException
  518. * @return void
  519. */
  520. public function testFromReadableSizeException() {
  521. $this->Number->fromReadableSize('bogus', false);
  522. }
  523. /**
  524. * filesizes dataprovider
  525. *
  526. * @return array
  527. */
  528. public function filesizes() {
  529. return array(
  530. array(array('size' => '512B', 'default' => false), 512),
  531. array(array('size' => '1KB', 'default' => false), 1024),
  532. array(array('size' => '1.5KB', 'default' => false), 1536),
  533. array(array('size' => '1MB', 'default' => false), 1048576),
  534. array(array('size' => '1mb', 'default' => false), 1048576),
  535. array(array('size' => '1.5MB', 'default' => false), 1572864),
  536. array(array('size' => '1GB', 'default' => false), 1073741824),
  537. array(array('size' => '1.5GB', 'default' => false), 1610612736),
  538. array(array('size' => '1K', 'default' => false), 1024),
  539. array(array('size' => '1.5K', 'default' => false), 1536),
  540. array(array('size' => '1M', 'default' => false), 1048576),
  541. array(array('size' => '1m', 'default' => false), 1048576),
  542. array(array('size' => '1.5M', 'default' => false), 1572864),
  543. array(array('size' => '1G', 'default' => false), 1073741824),
  544. array(array('size' => '1.5G', 'default' => false), 1610612736),
  545. array(array('size' => '512', 'default' => 'Unknown type'), 512),
  546. array(array('size' => '2VB', 'default' => 'Unknown type'), 'Unknown type')
  547. );
  548. }
  549. }