UtilityTest.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. <?php
  2. namespace Tools\TestCase\Utility;
  3. use Tools\Utility\Utility;
  4. use Cake\TestSuite\TestCase;
  5. use Cake\Core\Plugin;
  6. use Cake\Core\Configure;
  7. /**
  8. * @covers Utility
  9. */
  10. class UtilityTest extends TestCase {
  11. /**
  12. * UtilityTest::testInArray()
  13. *
  14. * @covers Utility::inArray
  15. * @return void
  16. */
  17. public function testInArray() {
  18. $res = Utility::inArray(2, array(1, 2, 3));
  19. $this->assertTrue($res);
  20. $res = Utility::inArray(4, array(1, 2, 7));
  21. $this->assertFalse($res);
  22. $res = Utility::inArray('2', array(1, 2, 3));
  23. $this->assertTrue($res);
  24. $res = Utility::inArray(2, array('1x', '2x', '3x'));
  25. $this->assertFalse($res);
  26. $res = Utility::inArray('3x', array('1x', '2x', '3x'));
  27. $this->assertTrue($res);
  28. $res = Utility::inArray(3, array('1', '2', '3'));
  29. $this->assertTrue($res);
  30. $res = Utility::inArray('2x', array(1, 2, 3));
  31. $this->assertFalse($res);
  32. }
  33. public function testTokenize() {
  34. $res = Utility::tokenize('');
  35. $this->assertSame(array(), $res);
  36. $res = Utility::tokenize('some');
  37. $this->assertSame(array('some'), $res);
  38. $res = Utility::tokenize('some, thing');
  39. $this->assertSame(array('some', 'thing'), $res);
  40. $res = Utility::tokenize(',some,,, ,, thing,');
  41. $this->assertSame(array('some', 'thing'), array_values($res));
  42. }
  43. /**
  44. * UtilityTest::testPregMatch()
  45. *
  46. * @covers Utility::pregMatch
  47. * @return void
  48. */
  49. public function testPregMatch() {
  50. $string = '<abc>';
  51. preg_match('/\<(\w+)\>/', $string, $matches);
  52. $this->assertSame(array($string, 'abc'), $matches);
  53. $matches = Utility::pregMatch('/\<(\w+)\>/', $string);
  54. $this->assertSame(array($string, 'abc'), $matches);
  55. $string = '<äöü>';
  56. preg_match('/\<(.+)\>/', $string, $matches);
  57. $this->assertSame(array($string, 'äöü'), $matches);
  58. $matches = Utility::pregMatch('/\<(.+)\>/', $string);
  59. $this->assertSame(array($string, 'äöü'), $matches);
  60. $string = 'D-81245 München';
  61. preg_match('/(*UTF8)([\w+])-([a-z0-9]+)\s+\b([\w\s]+)\b/iu', $string, $matches);
  62. $expected = array(
  63. $string,
  64. 'D',
  65. '81245',
  66. 'München'
  67. );
  68. $this->assertSame($expected, $matches);
  69. // we dont need the utf8 hack:
  70. $matches = Utility::pregMatch('/([\w+])-([a-z0-9]+)\s+\b([\w\s]+)\b/iu', $string);
  71. $this->assertSame($expected, $matches);
  72. }
  73. /**
  74. * UtilityTest::testPregMatchWithPatternEscape()
  75. *
  76. * @covers Utility::pregMatch
  77. * @return void
  78. */
  79. public function testPregMatchWithPatternEscape() {
  80. $string = 'http://www.example.com/s?q=php.net+docs';
  81. $res = preg_quote($string);
  82. $this->assertSame('http\://www\.example\.com/s\?q\=php\.net\+docs', $res);
  83. $string = 'http://www.example.com/s?q=php.net+docs';
  84. $res = preg_quote($string, '/');
  85. $this->assertSame('http\:\/\/www\.example\.com\/s\?q\=php\.net\+docs', $res);
  86. $res = '/a\s*' . $res . '\s*z/i';
  87. $string = 'a ' . $string . ' z';
  88. $matches = Utility::pregMatch($res, $string);
  89. $expected = array($string);
  90. $this->assertSame($expected, $matches);
  91. }
  92. /**
  93. * UtilityTest::testPregMatchAll()
  94. *
  95. * @covers Utility::pregMatchAll
  96. * @return void
  97. */
  98. public function testPregMatchAll() {
  99. $string = 'D-81245 München';
  100. preg_match_all('/(*UTF8)([\w+])-([a-z0-9]+)\s+\b([\w\s]+)\b/iu', $string, $matches, PREG_SET_ORDER);
  101. $expected = array(
  102. array(
  103. $string,
  104. 'D',
  105. '81245',
  106. 'München'
  107. )
  108. );
  109. $this->assertSame($expected, $matches);
  110. // we dont need the utf8 hack:
  111. $matches = Utility::pregMatchAll('/([\w+])-([a-z0-9]+)\s+\b([\w\s]+)\b/iu', $string);
  112. $this->assertSame($expected, $matches);
  113. }
  114. /**
  115. * UtilityTest::testStrSplit()
  116. *
  117. * @covers Utility::strSplit
  118. * @return void
  119. */
  120. public function testStrSplit() {
  121. $res = str_split('some äöü string', 7);
  122. $expected = array('some äö', 'ü strin', 'g');
  123. $this->assertNotSame($expected, $res);
  124. $res = Utility::strSplit('some äöü string', 7);
  125. $this->assertSame($expected, $res);
  126. }
  127. /**
  128. * UtilityTest::testUrlEncode()
  129. *
  130. * @covers Utility::urlEncode
  131. * @return void
  132. */
  133. public function testUrlEncode() {
  134. $res = Utility::urlEncode('Some/cool=value+more-infos');
  135. $this->assertSame('U29tZS9jb29sPXZhbHVlK21vcmUtaW5mb3M_', $res);
  136. }
  137. /**
  138. * UtilityTest::testUrlDecode()
  139. *
  140. * @covers Utility::urlDecode
  141. * @return void
  142. */
  143. public function testUrlDecode() {
  144. $res = Utility::urlDecode('U29tZS9jb29sPXZhbHVlK21vcmUtaW5mb3M_');
  145. $this->assertSame('Some/cool=value+more-infos', $res);
  146. }
  147. /**
  148. * UtilityTest::testTypeCast()
  149. *
  150. * @covers Utility::typeCast
  151. * @return void
  152. */
  153. public function testTypeCast() {
  154. $res = Utility::typeCast(2, 'string');
  155. $this->assertNotSame(2, $res);
  156. $this->assertSame('2', $res);
  157. }
  158. /**
  159. * UtilityTest::testGetClientIp()
  160. *
  161. * @covers Utility::getClientIp
  162. * @return void
  163. */
  164. public function testGetClientIp() {
  165. $res = Utility::getClientIp();
  166. $this->assertEquals(env('REMOTE_ADDR'), $res);
  167. }
  168. /**
  169. * UtilityTest::testFileExists()
  170. *
  171. * @covers Utility::fileExists
  172. * @return void
  173. */
  174. public function testFileExists() {
  175. $res = Utility::fileExists('http://www.spiegel.de/static/sys/v10/icons/home_v2.png');
  176. $this->assertTrue($res);
  177. $res = Utility::fileExists(Plugin::path('Tools') . 'tests' . DS . 'test_files' . DS . 'img' . DS . 'hotel.jpg');
  178. $this->assertTrue($res);
  179. $res = Utility::fileExists('http://www.spiegel.de/static/sys/v10/icons/home_v2_inexistent.png');
  180. $this->assertFalse($res);
  181. $res = Utility::fileExists(Plugin::path('Tools') . 'tests' . DS . 'test_files' . DS . 'img' . DS . 'fooooo.jpg');
  182. $this->assertFalse($res);
  183. }
  184. /**
  185. * UtilityTest::testUrlExists()
  186. *
  187. * @covers Utility::urlExists
  188. * @return void
  189. */
  190. public function testUrlExists() {
  191. $res = Utility::urlExists('http://www.spiegel.de');
  192. $this->assertTrue($res);
  193. $res = Utility::urlExists('http://www.spiegel.de/some/inexistent.img');
  194. $this->assertFalse($res);
  195. }
  196. /**
  197. * UtilityTest::testGetReferer()
  198. *
  199. * @covers Utility::getReferer
  200. * @return void
  201. */
  202. public function testGetReferer() {
  203. $res = Utility::getReferer();
  204. $this->assertEquals(env('HTTP_REFERER'), $res);
  205. $res = Utility::getReferer(true);
  206. $this->assertEquals(env('HTTP_REFERER'), $res);
  207. $_SERVER['HTTP_REFERER'] = '/foo/bar';
  208. $res = Utility::getReferer(true);
  209. $base = Configure::read('App.fullBaseUrl');
  210. if (!$base) {
  211. $base = ''; //'http://localhost';
  212. }
  213. $this->assertEquals($base . env('HTTP_REFERER'), $res);
  214. }
  215. /**
  216. * UtilityTest::testGetHeaderFromUrl()
  217. *
  218. * @covers Utility::getHeaderFromUrl
  219. * @return void
  220. */
  221. public function testGetHeaderFromUrl() {
  222. $res = Utility::getHeaderFromUrl('http://www.spiegel.de');
  223. $this->assertTrue(is_array($res) && count($res) > 1);
  224. //$this->assertEquals('HTTP/1.0 200 OK', $res[0]);
  225. }
  226. /**
  227. * UtilityTest::testAutoPrefixUrl()
  228. *
  229. * @covers Utility::autoPrefixUrl
  230. * @return void
  231. */
  232. public function testAutoPrefixUrl() {
  233. $res = Utility::autoPrefixUrl('www.spiegel.de');
  234. $this->assertEquals('http://www.spiegel.de', $res);
  235. }
  236. /**
  237. * UtilityTest::testCleanUrl()
  238. *
  239. * @covers Utility::cleanUrl
  240. * @return void
  241. */
  242. public function testCleanUrl() {
  243. $res = Utility::cleanUrl('www.spiegel.de');
  244. $this->assertEquals('http://www.spiegel.de', $res);
  245. $res = Utility::cleanUrl('http://');
  246. $this->assertEquals('', $res);
  247. $res = Utility::cleanUrl('http://www');
  248. $this->assertEquals('', $res);
  249. $res = Utility::cleanUrl('spiegel.de');
  250. $this->assertEquals('http://spiegel.de', $res);
  251. $res = Utility::cleanUrl('spiegel.de', true);
  252. //echo returns($res);
  253. $this->assertEquals('http://www.spiegel.de', $res);
  254. }
  255. /**
  256. * UtilityTest::testDeep()
  257. *
  258. * @covers Utility::trimDeep
  259. * @return void
  260. */
  261. public function testDeep() {
  262. $is = array(
  263. 'f some',
  264. 'e 49r ' => 'rf r ',
  265. 'er' => array(array('ee' => array('rr ' => ' tt ')))
  266. );
  267. $expected = array(
  268. 'f some',
  269. 'e 49r ' => 'rf r',
  270. 'er' => array(array('ee' => array('rr ' => 'tt')))
  271. );
  272. //$this->assertSame($expected, $is);
  273. $res = Utility::trimDeep($is);
  274. $this->assertSame($expected, $res);
  275. //$res = CommonComponent::trimDeep($is);
  276. //$this->assertSame($expected, $res);
  277. }
  278. //TODO: move to boostrap
  279. public function _testDeepFunction() {
  280. $is = array(
  281. 'f some',
  282. 'e 49r ' => 'rf r ',
  283. 'er' => array(array('ee' => array('rr ' => ' tt ')))
  284. );
  285. $expected = array(
  286. 'f some',
  287. 'e 49r ' => 'rf r',
  288. 'er' => array(array('ee' => array('rr ' => 'tt')))
  289. );
  290. $result = Utility::deep('trim', $is);
  291. $this->assertSame($expected, $result);
  292. }
  293. /**
  294. * TestCountDim method
  295. *
  296. * @return void
  297. */
  298. public function testCountDim() {
  299. $data = array('one', '2', 'three');
  300. $result = Utility::countDim($data);
  301. $this->assertEquals(1, $result);
  302. $data = array('1' => '1.1', '2', '3');
  303. $result = Utility::countDim($data);
  304. $this->assertEquals(1, $result);
  305. $data = array('1' => array('1.1' => '1.1.1'), '2', '3' => array('3.1' => '3.1.1'));
  306. $result = Utility::countDim($data);
  307. $this->assertEquals(2, $result);
  308. $data = array('1' => '1.1', '2', '3' => array('3.1' => '3.1.1'));
  309. $result = Utility::countDim($data);
  310. $this->assertEquals(1, $result);
  311. $data = array('1' => '1.1', '2', '3' => array('3.1' => '3.1.1'));
  312. $result = Utility::countDim($data, true);
  313. $this->assertEquals(2, $result);
  314. $data = array('1' => array('1.1' => '1.1.1'), '2', '3' => array('3.1' => array('3.1.1' => '3.1.1.1')));
  315. $result = Utility::countDim($data);
  316. $this->assertEquals(2, $result);
  317. $data = array('1' => array('1.1' => '1.1.1'), '2', '3' => array('3.1' => array('3.1.1' => '3.1.1.1')));
  318. $result = Utility::countDim($data, true);
  319. $this->assertEquals(3, $result);
  320. $data = array('1' => array('1.1' => '1.1.1'), array('2' => array('2.1' => array('2.1.1' => '2.1.1.1'))), '3' => array('3.1' => array('3.1.1' => '3.1.1.1')));
  321. $result = Utility::countDim($data, true);
  322. $this->assertEquals(4, $result);
  323. $data = array('1' => array('1.1' => '1.1.1'), array('2' => array('2.1' => array('2.1.1' => array('2.1.1.1')))), '3' => array('3.1' => array('3.1.1' => '3.1.1.1')));
  324. $result = Utility::countDim($data, true);
  325. $this->assertEquals(5, $result);
  326. $data = array('1' => array('1.1' => '1.1.1'), array('2' => array('2.1' => array('2.1.1' => array('2.1.1.1' => '2.1.1.1.1')))), '3' => array('3.1' => array('3.1.1' => '3.1.1.1')));
  327. $result = Utility::countDim($data, true);
  328. $this->assertEquals(5, $result);
  329. $set = array('1' => array('1.1' => '1.1.1'), array('2' => array('2.1' => array('2.1.1' => array('2.1.1.1' => '2.1.1.1.1')))), '3' => array('3.1' => array('3.1.1' => '3.1.1.1')));
  330. $result = Utility::countDim($set, false, 0);
  331. $this->assertEquals(2, $result);
  332. $result = Utility::countDim($set, true);
  333. $this->assertEquals(5, $result);
  334. $data = array('one' => array(null), array('null' => null), 'three' => array(true, false, null));
  335. $result = Utility::countDim($data, true);
  336. $this->assertEquals(2, $result);
  337. }
  338. /**
  339. * UtilityTest::testExpand()
  340. *
  341. * @return void
  342. */
  343. public function testExpandList() {
  344. $is = array(
  345. 'Some.Deep.Value1',
  346. 'Some.Deep.Value2',
  347. 'Some.Even.Deeper.Nested.Value',
  348. 'Empty.',
  349. '0.1.2',
  350. '.EmptyString'
  351. );
  352. $result = Utility::expandList($is);
  353. $expected = array(
  354. 'Some' => array(
  355. 'Deep' => array('Value1', 'Value2'),
  356. 'Even' => array('Deeper' => array('Nested' => array('Value')))
  357. ),
  358. 'Empty' => array(''),
  359. '0' => array('1' => array('2')),
  360. '' => array('EmptyString')
  361. );
  362. $this->assertSame($expected, $result);
  363. }
  364. /**
  365. * UtilityTest::testExpandListWithKeyLessListInvalid()
  366. *
  367. * @expectedException RuntimeException
  368. * @return void
  369. */
  370. public function testExpandListWithKeyLessListInvalid() {
  371. $is = array(
  372. 'Some',
  373. 'ValueOnly',
  374. );
  375. Utility::expandList($is);
  376. }
  377. /**
  378. * UtilityTest::testExpandListWithKeyLessList()
  379. *
  380. * @return void
  381. */
  382. public function testExpandListWithKeyLessList() {
  383. $is = array(
  384. 'Some',
  385. 'Thing',
  386. '.EmptyString'
  387. );
  388. $result = Utility::expandList($is, '.', '');
  389. $expected = array(
  390. '' => array('Some', 'Thing', 'EmptyString'),
  391. );
  392. $this->assertSame($expected, $result);
  393. }
  394. /**
  395. * UtilityTest::testFlatten()
  396. *
  397. * @return void
  398. */
  399. public function testFlatten() {
  400. $is = array(
  401. 'Some' => array(
  402. 'Deep' => array('Value1', 'Value2'),
  403. 'Even' => array('Deeper' => array('Nested' => array('Value')))
  404. ),
  405. 'Empty' => array(''),
  406. '0' => array('1' => array('2')),
  407. //'ValueOnly',
  408. '' => array('EmptyString')
  409. );
  410. $result = Utility::flattenList($is);
  411. $expected = array(
  412. 'Some.Deep.Value1',
  413. 'Some.Deep.Value2',
  414. 'Some.Even.Deeper.Nested.Value',
  415. 'Empty.',
  416. '0.1.2',
  417. //'1.ValueOnly'
  418. '.EmptyString'
  419. );
  420. $this->assertSame($expected, $result);
  421. // Test integers als booleans
  422. $is = array(
  423. 'Some' => array(
  424. 'Deep' => array(true),
  425. 'Even' => array('Deeper' => array('Nested' => array(false, true)))
  426. ),
  427. 'Integer' => array('Value' => array(-3)),
  428. );
  429. $result = Utility::flattenList($is);
  430. $expected = array(
  431. 'Some.Deep.1',
  432. 'Some.Even.Deeper.Nested.0',
  433. 'Some.Even.Deeper.Nested.1',
  434. 'Integer.Value.-3',
  435. );
  436. $this->assertSame($expected, $result);
  437. }
  438. /**
  439. * UtilityTest::testArrayFlattenBasic()
  440. *
  441. * @covers Utility::arrayFlatten
  442. * @return void
  443. */
  444. public function testArrayFlattenBasic() {
  445. $strings = array(
  446. 'a' => array('a' => 'A'),
  447. 'b' => array('b' => 'B', 'c' => 'C'),
  448. 'c' => array(),
  449. 'd' => array(array(array('z' => 'Z'), 'y' => 'Y'))
  450. );
  451. $result = Utility::arrayFlatten($strings);
  452. $expected = array(
  453. 'a' => 'A',
  454. 'b' => 'B',
  455. 'c' => 'C',
  456. 'z' => 'Z',
  457. 'y' => 'Y'
  458. );
  459. $this->assertSame($expected, $result);
  460. }
  461. /**
  462. * Test that deeper nested values overwrite higher ones.
  463. *
  464. * @covers Utility::arrayFlatten
  465. * @return void
  466. */
  467. public function testArrayFlatten() {
  468. $array = array(
  469. 'a' => 1,
  470. 'b' => array('h' => false, 'c' => array('d' => array('f' => 'g', 'h' => true))),
  471. 'k' => 'm',
  472. );
  473. $res = Utility::arrayFlatten($array);
  474. $expected = array(
  475. 'a' => 1,
  476. 'h' => true,
  477. 'f' => 'g',
  478. 'k' => 'm',
  479. );
  480. $this->assertSame($expected, $res);
  481. }
  482. /**
  483. * UtilityTest::testArrayFlattenAndPreserveKeys()
  484. *
  485. * @covers Utility::arrayFlatten
  486. * @return void
  487. */
  488. public function testArrayFlattenAndPreserveKeys() {
  489. $array = array(
  490. 0 => 1,
  491. 1 => array('c' => array('d' => array('g', 'h' => true))),
  492. 2 => 'm',
  493. );
  494. $res = Utility::arrayFlatten($array, true);
  495. $expected = array(
  496. 0 => 'g',
  497. 'h' => true,
  498. 2 => 'm',
  499. );
  500. $this->assertSame($expected, $res);
  501. }
  502. /**
  503. * UtilityTest::testArrayShiftKeys()
  504. *
  505. * @covers Utility::arrayShiftKeys
  506. * @return void
  507. */
  508. public function testArrayShiftKeys() {
  509. $array = array(
  510. 'a' => 1,
  511. 'b' => array('c' => array('d' => array('f' => 'g', 'h' => true))),
  512. 'k' => 'm',
  513. );
  514. $res = Utility::arrayShiftKeys($array);
  515. $expected = 'a';
  516. $this->assertSame($expected, $res);
  517. $expected = array(
  518. 'b' => array('c' => array('d' => array('f' => 'g', 'h' => true))),
  519. 'k' => 'm',
  520. );
  521. $this->assertSame($expected, $array);
  522. }
  523. /**
  524. * UtilityTest::testTime()
  525. *
  526. * @covers Utility::returnElapsedTime
  527. * @return void
  528. */
  529. public function testTime() {
  530. Utility::startClock();
  531. time_nanosleep(0, 200000000);
  532. $res = Utility::returnElapsedTime();
  533. $this->assertTrue(round($res, 1) === 0.2);
  534. time_nanosleep(0, 100000000);
  535. $res = Utility::returnElapsedTime(8, true);
  536. $this->assertTrue(round($res, 1) === 0.3);
  537. time_nanosleep(0, 100000000);
  538. $res = Utility::returnElapsedTime();
  539. $this->assertTrue(round($res, 1) === 0.1);
  540. }
  541. /**
  542. * UtilityTest::testLogicalAnd()
  543. *
  544. * @covers Utility::logicalAnd
  545. * @return void
  546. */
  547. public function testLogicalAnd() {
  548. $array = array(
  549. 'a' => 1,
  550. 'b' => 1,
  551. 'c' => 0,
  552. 'd' => 1,
  553. );
  554. $is = Utility::logicalAnd($array);
  555. $this->assertFalse($is);
  556. $array = array(
  557. 'a' => 1,
  558. 'b' => 1,
  559. 'c' => 1,
  560. 'd' => 1,
  561. );
  562. $is = Utility::logicalAnd($array);
  563. $this->assertTrue($is);
  564. }
  565. /**
  566. * UtilityTest::testLogicalOr()
  567. *
  568. * @covers Utility::logicalOr
  569. * @return void
  570. */
  571. public function testLogicalOr() {
  572. $array = array(
  573. 'a' => 0,
  574. 'b' => 1,
  575. 'c' => 0,
  576. 'd' => 1,
  577. );
  578. $is = Utility::logicalOr($array);
  579. $this->assertTrue($is);
  580. $array = array(
  581. 'a' => 1,
  582. 'b' => 1,
  583. 'c' => 1,
  584. 'd' => 1,
  585. );
  586. $is = Utility::logicalOr($array);
  587. $this->assertTrue($is);
  588. $array = array(
  589. 'a' => 0,
  590. 'b' => 0,
  591. 'c' => 0,
  592. 'd' => 0,
  593. );
  594. $is = Utility::logicalOr($array);
  595. $this->assertFalse($is);
  596. }
  597. /**
  598. * UtilityTest::testIsValidSaveAll()
  599. *
  600. * @covers Utility::isValidSaveAll
  601. * @return void
  602. */
  603. public function testIsValidSaveAll() {
  604. $result = Utility::isValidSaveAll(array());
  605. $this->assertFalse($result);
  606. $result = Utility::isValidSaveAll(array(true, true));
  607. $this->assertTrue($result);
  608. $result = Utility::isValidSaveAll(array(true, false));
  609. $this->assertFalse($result);
  610. }
  611. }