UtilityTest.php 16 KB

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