CFDBTransformParserTest

The Contact Form DB CFDBTransformParserTest class.

Defined (1)

The class is defined in the following location(s).

/phpunit/CFDBTransformParserTest.php  
  1. class CFDBTransformParserTest extends PHPUnit_Framework_TestCase { 
  2.  
  3. public function test_parse_1_1() { 
  4. $p = new CFDBTransformParser; 
  5. $p->parse('last_name=funct'); 
  6. $e = $p->getExpressionTree(); 
  7.  
  8. $this->assertEquals(1, count($e)); 
  9. $this->assertEquals("last_name", $e[0][0]); 
  10. $this->assertEquals("=", $e[0][1]); 
  11. $this->assertEquals("funct", $e[0][2]); 
  12.  
  13. public function test_parse_1_2() { 
  14. $p = new CFDBTransformParser; 
  15. $p->parse('last_name=funct()'); 
  16. $e = $p->getExpressionTree(); 
  17.  
  18. $this->assertEquals(1, count($e)); 
  19. $this->assertEquals("last_name", $e[0][0]); 
  20. $this->assertEquals("=", $e[0][1]); 
  21. $this->assertEquals("funct", $e[0][2]); 
  22.  
  23.  
  24. // 1 arg 
  25.  
  26. public function test_parse_2_1() { 
  27. $p = new CFDBTransformParser; 
  28. $p->parse('last_name=strtoupper(last_name)'); 
  29. $e = $p->getExpressionTree(); 
  30.  
  31. $this->assertEquals(1, count($e)); 
  32. $this->assertEquals("last_name", $e[0][0]); 
  33. $this->assertEquals("=", $e[0][1]); 
  34. $this->assertEquals("strtoupper", $e[0][2]); 
  35. $this->assertEquals("last_name", $e[0][3]); 
  36.  
  37. // multiple args 
  38.  
  39. public function test_parse_2_2() { 
  40. $p = new CFDBTransformParser; 
  41. $p->parse('name=funct(first_name, last_name)'); 
  42. $e = $p->getExpressionTree(); 
  43.  
  44. $this->assertEquals(1, count($e)); 
  45. $this->assertEquals("name", $e[0][0]); 
  46. $this->assertEquals("=", $e[0][1]); 
  47. $this->assertEquals("funct", $e[0][2]); 
  48. $this->assertEquals("first_name", $e[0][3]); 
  49. $this->assertEquals("last_name", $e[0][4]); 
  50.  
  51. public function test_parse_2_3() { 
  52. $p = new CFDBTransformParser; 
  53. $p->parse('name=funct(first_name, last_name)'); 
  54. $e = $p->getExpressionTree(); 
  55.  
  56. $this->assertEquals(1, count($e)); 
  57. $this->assertEquals("name", $e[0][0]); 
  58. $this->assertEquals("=", $e[0][1]); 
  59. $this->assertEquals("funct", $e[0][2]); 
  60. $this->assertEquals("first_name", $e[0][3]); 
  61. $this->assertEquals("last_name", $e[0][4]); 
  62.  
  63. public function test_parse_2_4() { 
  64. $p = new CFDBTransformParser; 
  65. $p->parse('name=funct(first_name, middle_name, last_name)'); 
  66. $e = $p->getExpressionTree(); 
  67.  
  68. $this->assertEquals(1, count($e)); 
  69. $this->assertEquals("name", $e[0][0]); 
  70. $this->assertEquals("=", $e[0][1]); 
  71. $this->assertEquals("funct", $e[0][2]); 
  72. $this->assertEquals("first_name", $e[0][3]); 
  73. $this->assertEquals("middle_name", $e[0][4]); 
  74. $this->assertEquals("last_name", $e[0][5]); 
  75.  
  76. // multiples 
  77. public function test_parse_3_1() { 
  78. $p = new CFDBTransformParser; 
  79. $p->parse('first_name=funct1&&last_name=funct2'); 
  80. $e = $p->getExpressionTree(); 
  81.  
  82. $this->assertEquals(2, count($e)); 
  83. $this->assertEquals("first_name", $e[0][0]); 
  84. $this->assertEquals("=", $e[0][1]); 
  85. $this->assertEquals("funct1", $e[0][2]); 
  86.  
  87. $this->assertEquals("last_name", $e[1][0]); 
  88. $this->assertEquals("=", $e[1][1]); 
  89. $this->assertEquals("funct2", $e[1][2]); 
  90.  
  91. public function test_parse_3_2() { 
  92. $p = new CFDBTransformParser; 
  93. $p->parse('first_name=funct1()&&last_name=funct2()'); 
  94. $e = $p->getExpressionTree(); 
  95.  
  96. $this->assertEquals(2, count($e)); 
  97. $this->assertEquals("first_name", $e[0][0]); 
  98. $this->assertEquals("=", $e[0][1]); 
  99. $this->assertEquals("funct1", $e[0][2]); 
  100.  
  101. $this->assertEquals("last_name", $e[1][0]); 
  102. $this->assertEquals("=", $e[1][1]); 
  103. $this->assertEquals("funct2", $e[1][2]); 
  104.  
  105. public function test_parse_4_1() { 
  106. $p = new CFDBTransformParser; 
  107. $p->parse('first_name=funct1(x_name)&&last_name=funct2()'); 
  108. $e = $p->getExpressionTree(); 
  109.  
  110. $this->assertEquals(2, count($e)); 
  111. $this->assertEquals("first_name", $e[0][0]); 
  112. $this->assertEquals("=", $e[0][1]); 
  113. $this->assertEquals("funct1", $e[0][2]); 
  114. $this->assertEquals("x_name", $e[0][3]); 
  115.  
  116. $this->assertEquals("last_name", $e[1][0]); 
  117. $this->assertEquals("=", $e[1][1]); 
  118. $this->assertEquals("funct2", $e[1][2]); 
  119.  
  120. public function test_parse_4_2() { 
  121. $p = new CFDBTransformParser; 
  122. $p->parse('first_name=funct1()&&last_name=funct2(x_name)'); 
  123. $e = $p->getExpressionTree(); 
  124.  
  125. $this->assertEquals(2, count($e)); 
  126. $this->assertEquals("first_name", $e[0][0]); 
  127. $this->assertEquals("=", $e[0][1]); 
  128. $this->assertEquals("funct1", $e[0][2]); 
  129.  
  130. $this->assertEquals("last_name", $e[1][0]); 
  131. $this->assertEquals("=", $e[1][1]); 
  132. $this->assertEquals("funct2", $e[1][2]); 
  133. $this->assertEquals("x_name", $e[1][3]); 
  134.  
  135. public function test_parse_4_3() { 
  136. $p = new CFDBTransformParser; 
  137. $p->parse('first_name=funct1(y_name)&&last_name=funct2(x_name)'); 
  138. $e = $p->getExpressionTree(); 
  139.  
  140. $this->assertEquals(2, count($e)); 
  141. $this->assertEquals("first_name", $e[0][0]); 
  142. $this->assertEquals("=", $e[0][1]); 
  143. $this->assertEquals("funct1", $e[0][2]); 
  144. $this->assertEquals("y_name", $e[0][3]); 
  145.  
  146. $this->assertEquals("last_name", $e[1][0]); 
  147. $this->assertEquals("=", $e[1][1]); 
  148. $this->assertEquals("funct2", $e[1][2]); 
  149. $this->assertEquals("x_name", $e[1][3]); 
  150.  
  151. public function test_parse_4_4() { 
  152. $p = new CFDBTransformParser; 
  153. $p->parse('first_name=funct1(y1_name, y2_name)&&last_name=funct2(x1_name, x2_name)'); 
  154. $e = $p->getExpressionTree(); 
  155.  
  156. $this->assertEquals(2, count($e)); 
  157. $this->assertEquals("first_name", $e[0][0]); 
  158. $this->assertEquals("=", $e[0][1]); 
  159. $this->assertEquals("funct1", $e[0][2]); 
  160. $this->assertEquals("y1_name", $e[0][3]); 
  161. $this->assertEquals("y2_name", $e[0][4]); 
  162.  
  163. $this->assertEquals("last_name", $e[1][0]); 
  164. $this->assertEquals("=", $e[1][1]); 
  165. $this->assertEquals("funct2", $e[1][2]); 
  166. $this->assertEquals("x1_name", $e[1][3]); 
  167. $this->assertEquals("x2_name", $e[1][4]); 
  168.  
  169. public function test_parse_4_5() { 
  170. $p = new CFDBTransformParser; 
  171. $p->parse(' first_name=funct1(y1_name, y2_name) && last_name=funct2( x1_name, x2_name)'); 
  172. $e = $p->getExpressionTree(); 
  173.  
  174. $this->assertEquals(2, count($e)); 
  175. $this->assertEquals("first_name", $e[0][0]); 
  176. $this->assertEquals("=", $e[0][1]); 
  177. $this->assertEquals("funct1", $e[0][2]); 
  178. $this->assertEquals("y1_name", $e[0][3]); 
  179. $this->assertEquals("y2_name", $e[0][4]); 
  180.  
  181. $this->assertEquals("last_name", $e[1][0]); 
  182. $this->assertEquals("=", $e[1][1]); 
  183. $this->assertEquals("funct2", $e[1][2]); 
  184. $this->assertEquals("x1_name", $e[1][3]); 
  185. $this->assertEquals("x2_name", $e[1][4]); 
  186.  
  187. public function test_parse_5_1() { 
  188. $p = new CFDBTransformParser; 
  189. $p->parse('xxxx'); 
  190. $e = $p->getExpressionTree(); 
  191. $this->assertEquals(1, count($e)); 
  192. $this->assertEquals(1, count($e[0])); 
  193. $this->assertEquals("xxxx", $e[0][0]); 
  194.  
  195. public function test_parse_5_2() { 
  196. $p = new CFDBTransformParser; 
  197. $p->parse('xxxx&&yyyy'); 
  198. $e = $p->getExpressionTree(); 
  199. $this->assertEquals(2, count($e)); 
  200.  
  201. $this->assertEquals(1, count($e[0])); 
  202. $this->assertEquals("xxxx", $e[0][0]); 
  203.  
  204. $this->assertEquals(1, count($e[1])); 
  205. $this->assertEquals("yyyy", $e[1][0]); 
  206.  
  207. public function test_parse_5_3() { 
  208. $p = new CFDBTransformParser; 
  209. $p->parse('xxxx&&first_name=funct1(y1_name, y2_name)&&yyy&&last_name=funct2( x1_name, x2_name)'); 
  210. $e = $p->getExpressionTree(); 
  211.  
  212. $this->assertEquals(4, count($e)); 
  213.  
  214. $this->assertEquals(1, count($e[0])); 
  215. $this->assertEquals("xxxx", $e[0][0]); 
  216.  
  217. $this->assertEquals("first_name", $e[1][0]); 
  218. $this->assertEquals("=", $e[1][1]); 
  219. $this->assertEquals("funct1", $e[1][2]); 
  220. $this->assertEquals("y1_name", $e[1][3]); 
  221. $this->assertEquals("y2_name", $e[1][4]); 
  222.  
  223. $this->assertEquals(1, count($e[2])); 
  224. $this->assertEquals("yyy", $e[2][0]); 
  225.  
  226. $this->assertEquals("last_name", $e[3][0]); 
  227. $this->assertEquals("=", $e[3][1]); 
  228. $this->assertEquals("funct2", $e[3][2]); 
  229. $this->assertEquals("x1_name", $e[3][3]); 
  230. $this->assertEquals("x2_name", $e[3][4]); 
  231.  
  232. public function test_parse_6() { 
  233. $p = new CFDBTransformParser; 
  234. $p->parse(''); 
  235. $e = $p->getExpressionTree(); 
  236. $this->assertEquals(0, count($e)); 
  237.  
  238. // Evaluation Tests 
  239.  
  240. // Test function that changes a field 
  241. public function test_eval_function_assign_1() { 
  242. $t = new CFDBTransformParser; 
  243. $t->parse('fname=strtoupper(fname)'); 
  244. $t->setupTransforms(); 
  245.  
  246. $data = array( 
  247. array('fname' => 'mike', 'lname' => 'simpson'),  
  248. array('fname' => 'oya', 'lname' => 'simpson') 
  249. ); 
  250. $source = new ArrayDataIterator($data); 
  251. $t->setDataSource($source); 
  252. $iter = $t->getIterator(); 
  253.  
  254. $iter->nextRow(); 
  255. $this->assertEquals('MIKE', $iter->row['fname']); 
  256. $this->assertEquals('simpson', $iter->row['lname']); 
  257.  
  258. $iter->nextRow(); 
  259. $this->assertEquals('OYA', $iter->row['fname']); 
  260. $this->assertEquals('simpson', $iter->row['lname']); 
  261.  
  262. // Test function that takes in entire entry and modifies it 
  263. public function test_eval_function_mutate_1() { 
  264. $t = new CFDBTransformParser; 
  265. $t->parse('upperall'); 
  266. $t->setupTransforms(); 
  267.  
  268. $data = array( 
  269. array('fname' => 'mike', 'lname' => 'simpson'),  
  270. array('fname' => 'oya', 'lname' => 'turkel') 
  271. ); 
  272. $source = new ArrayDataIterator($data); 
  273. $t->setDataSource($source); 
  274. $iter = $t->getIterator(); 
  275.  
  276. $iter->nextRow(); 
  277. $this->assertEquals('MIKE', $iter->row['fname']); 
  278. $this->assertEquals('SIMPSON', $iter->row['lname']); 
  279.  
  280. $iter->nextRow(); 
  281. $this->assertEquals('OYA', $iter->row['fname']); 
  282. $this->assertEquals('TURKEL', $iter->row['lname']); 
  283.  
  284. // test class 
  285. public function test_eval_class_1() { 
  286. $t = new CFDBTransformParser; 
  287. $t->parse('SortByLname'); 
  288. $t->setupTransforms(); 
  289.  
  290. $data = array( 
  291. array('fname' => 'mike', 'lname' => 'BBBBB'),  
  292. array('fname' => 'mike', 'lname' => 'CCCCC'),  
  293. array('fname' => 'mike', 'lname' => 'AAAAA') 
  294. ); 
  295. $source = new ArrayDataIterator($data); 
  296. $t->setDataSource($source); 
  297. $iter = $t->getIterator(); 
  298.  
  299. $iter->nextRow(); 
  300. $this->assertEquals('mike', $iter->row['fname']); 
  301. $this->assertEquals('AAAAA', $iter->row['lname']); 
  302.  
  303. $iter->nextRow(); 
  304. $this->assertEquals('mike', $iter->row['fname']); 
  305. $this->assertEquals('BBBBB', $iter->row['lname']); 
  306.  
  307. $iter->nextRow(); 
  308. $this->assertEquals('mike', $iter->row['fname']); 
  309. $this->assertEquals('CCCCC', $iter->row['lname']); 
  310.  
  311. public function test_eval_class_2() { 
  312. $t = new CFDBTransformParser; 
  313. $t->parse('UpperAllClass'); 
  314. $t->setupTransforms(); 
  315.  
  316. $data = array( 
  317. array('fname' => 'mike', 'lname' => 'simpson'),  
  318. array('fname' => 'oya', 'lname' => 'turkel') 
  319. ); 
  320. $source = new ArrayDataIterator($data); 
  321. $t->setDataSource($source); 
  322. $iter = $t->getIterator(); 
  323.  
  324. $iter->nextRow(); 
  325. $this->assertEquals('MIKE', $iter->row['fname']); 
  326. $this->assertEquals('SIMPSON', $iter->row['lname']); 
  327.  
  328. $iter->nextRow(); 
  329. $this->assertEquals('OYA', $iter->row['fname']); 
  330. $this->assertEquals('TURKEL', $iter->row['lname']); 
  331.  
  332. // test class with constructor 
  333. public function test_eval_class_with_ctr_1() { 
  334. $t = new CFDBTransformParser; 
  335. $t->parse('SortByField(lname)'); 
  336. $t->setupTransforms(); 
  337.  
  338. $data = array( 
  339. array('fname' => 'xxxx', 'lname' => 'BBBBB'),  
  340. array('fname' => 'yyyy', 'lname' => 'CCCCC'),  
  341. array('fname' => 'zzzz', 'lname' => 'AAAAA') 
  342. ); 
  343. $source = new ArrayDataIterator($data); 
  344. $t->setDataSource($source); 
  345. $iter = $t->getIterator(); 
  346.  
  347. $iter->nextRow(); 
  348. $this->assertEquals('zzzz', $iter->row['fname']); 
  349. $this->assertEquals('AAAAA', $iter->row['lname']); 
  350.  
  351. $iter->nextRow(); 
  352. $this->assertEquals('xxxx', $iter->row['fname']); 
  353. $this->assertEquals('BBBBB', $iter->row['lname']); 
  354.  
  355. $iter->nextRow(); 
  356. $this->assertEquals('yyyy', $iter->row['fname']); 
  357. $this->assertEquals('CCCCC', $iter->row['lname']); 
  358.  
  359. public function test_eval_class_with_ctr_2() { 
  360. $t = new CFDBTransformParser; 
  361. $t->parse('SortByField(fname)'); 
  362. $t->setupTransforms(); 
  363.  
  364. $data = array( 
  365. array('fname' => 'zzzz', 'lname' => 'AAAAA'),  
  366. array('fname' => 'yyyy', 'lname' => 'CCCCC'),  
  367. array('fname' => 'xxxx', 'lname' => 'BBBBB') 
  368. ); 
  369. $source = new ArrayDataIterator($data); 
  370. $t->setDataSource($source); 
  371. $iter = $t->getIterator(); 
  372.  
  373. $iter->nextRow(); 
  374. $this->assertEquals('xxxx', $iter->row['fname']); 
  375. $this->assertEquals('BBBBB', $iter->row['lname']); 
  376.  
  377. $iter->nextRow(); 
  378. $this->assertEquals('yyyy', $iter->row['fname']); 
  379. $this->assertEquals('CCCCC', $iter->row['lname']); 
  380.  
  381. $iter->nextRow(); 
  382. $this->assertEquals('zzzz', $iter->row['fname']); 
  383. $this->assertEquals('AAAAA', $iter->row['lname']); 
  384.  
  385.  
  386. // test chain of transforms all assign functions 
  387. public function test_eval_function_chain_assign_1() { 
  388. $t = new CFDBTransformParser; 
  389. $t->parse('fname=strtoupper(fname)&&lname=strtoupper(lname)'); 
  390. $t->setupTransforms(); 
  391.  
  392. $data = array( 
  393. array('fname' => 'mike', 'lname' => 'simpson'),  
  394. array('fname' => 'oya', 'lname' => 'turkel') 
  395. ); 
  396. $source = new ArrayDataIterator($data); 
  397. $t->setDataSource($source); 
  398. $iter = $t->getIterator(); 
  399.  
  400. $iter->nextRow(); 
  401. $this->assertEquals('MIKE', $iter->row['fname']); 
  402. $this->assertEquals('SIMPSON', $iter->row['lname']); 
  403.  
  404. $iter->nextRow(); 
  405. $this->assertEquals('OYA', $iter->row['fname']); 
  406. $this->assertEquals('TURKEL', $iter->row['lname']); 
  407.  
  408. // test chain of transforms all functions 
  409. public function test_eval_function_chain_mutate_1() { 
  410. $t = new CFDBTransformParser; 
  411. $t->parse('upperall&&reverseall'); 
  412. $t->setupTransforms(); 
  413.  
  414. $data = array( 
  415. array('fname' => 'mike', 'lname' => 'simpson'),  
  416. array('fname' => 'oya', 'lname' => 'turkel') 
  417. ); 
  418. $source = new ArrayDataIterator($data); 
  419. $t->setDataSource($source); 
  420. $iter = $t->getIterator(); 
  421.  
  422. $iter->nextRow(); 
  423. $this->assertEquals('EKIM', $iter->row['fname']); 
  424. $this->assertEquals('NOSPMIS', $iter->row['lname']); 
  425.  
  426. $iter->nextRow(); 
  427. $this->assertEquals('AYO', $iter->row['fname']); 
  428. $this->assertEquals('LEKRUT', $iter->row['lname']); 
  429.  
  430. // test chain of transforms assign & mutate functions 
  431. public function test_eval_function_chain_assign_and_mutate_1() { 
  432. $t = new CFDBTransformParser; 
  433. $t->parse('lname=strtoupper(lname)&&reverseall'); 
  434. $t->setupTransforms(); 
  435.  
  436. $data = array( 
  437. array('fname' => 'mike', 'lname' => 'simpson'),  
  438. array('fname' => 'oya', 'lname' => 'turkel') 
  439. ); 
  440. $source = new ArrayDataIterator($data); 
  441. $t->setDataSource($source); 
  442. $iter = $t->getIterator(); 
  443.  
  444. $iter->nextRow(); 
  445. $this->assertEquals('ekim', $iter->row['fname']); 
  446. $this->assertEquals('NOSPMIS', $iter->row['lname']); 
  447.  
  448. $iter->nextRow(); 
  449. $this->assertEquals('ayo', $iter->row['fname']); 
  450. $this->assertEquals('LEKRUT', $iter->row['lname']); 
  451.  
  452. public function test_eval_function_chain_assign_and_mutate_2() { 
  453. $t = new CFDBTransformParser; 
  454. $t->parse('reverseall&&lname=strtoupper(lname)'); 
  455. $t->setupTransforms(); 
  456.  
  457. $data = array( 
  458. array('fname' => 'mike', 'lname' => 'simpson'),  
  459. array('fname' => 'oya', 'lname' => 'turkel') 
  460. ); 
  461. $source = new ArrayDataIterator($data); 
  462. $t->setDataSource($source); 
  463. $iter = $t->getIterator(); 
  464.  
  465. $iter->nextRow(); 
  466. $this->assertEquals('ekim', $iter->row['fname']); 
  467. $this->assertEquals('NOSPMIS', $iter->row['lname']); 
  468.  
  469. $iter->nextRow(); 
  470. $this->assertEquals('ayo', $iter->row['fname']); 
  471. $this->assertEquals('LEKRUT', $iter->row['lname']); 
  472.  
  473. // test chain of transforms all classes 
  474. public function test_eval_class_chain_1() { 
  475. $t = new CFDBTransformParser; 
  476. $t->parse('SortByField(fname)&&UpperAllClass'); 
  477. $t->setupTransforms(); 
  478.  
  479. $data = array( 
  480. array('fname' => 'zzzz', 'lname' => 'AAAAA'),  
  481. array('fname' => 'yyyy', 'lname' => 'CCCCC'),  
  482. array('fname' => 'xxxx', 'lname' => 'BBBBB') 
  483. ); 
  484. $source = new ArrayDataIterator($data); 
  485. $t->setDataSource($source); 
  486. $iter = $t->getIterator(); 
  487.  
  488. $iter->nextRow(); 
  489. $this->assertEquals('XXXX', $iter->row['fname']); 
  490. $this->assertEquals('BBBBB', $iter->row['lname']); 
  491.  
  492. $iter->nextRow(); 
  493. $this->assertEquals('YYYY', $iter->row['fname']); 
  494. $this->assertEquals('CCCCC', $iter->row['lname']); 
  495.  
  496. $iter->nextRow(); 
  497. $this->assertEquals('ZZZZ', $iter->row['fname']); 
  498. $this->assertEquals('AAAAA', $iter->row['lname']); 
  499.  
  500. public function test_eval_class_chain_2() { 
  501. $t = new CFDBTransformParser; 
  502. $t->parse('UpperAllClass&&SortByField(fname)'); 
  503. $t->setupTransforms(); 
  504.  
  505. $data = array( 
  506. array('fname' => 'zzzz', 'lname' => 'AAAAA'),  
  507. array('fname' => 'yyyy', 'lname' => 'CCCCC'),  
  508. array('fname' => 'xxxx', 'lname' => 'BBBBB') 
  509. ); 
  510. $source = new ArrayDataIterator($data); 
  511. $t->setDataSource($source); 
  512. $iter = $t->getIterator(); 
  513.  
  514. $iter->nextRow(); 
  515. $this->assertEquals('XXXX', $iter->row['fname']); 
  516. $this->assertEquals('BBBBB', $iter->row['lname']); 
  517.  
  518. $iter->nextRow(); 
  519. $this->assertEquals('YYYY', $iter->row['fname']); 
  520. $this->assertEquals('CCCCC', $iter->row['lname']); 
  521.  
  522. $iter->nextRow(); 
  523. $this->assertEquals('ZZZZ', $iter->row['fname']); 
  524. $this->assertEquals('AAAAA', $iter->row['lname']); 
  525.  
  526. // test chain of transforms mixed functions and classes 
  527. public function test_eval_class_chain_mixed_1() { 
  528. $t = new CFDBTransformParser; 
  529. $t->parse('upperall&&SortByField(fname)'); 
  530. $t->setupTransforms(); 
  531.  
  532. $data = array( 
  533. array('fname' => 'zzzz', 'lname' => 'AAAAA'),  
  534. array('fname' => 'yyyy', 'lname' => 'CCCCC'),  
  535. array('fname' => 'xxxx', 'lname' => 'BBBBB') 
  536. ); 
  537. $source = new ArrayDataIterator($data); 
  538. $t->setDataSource($source); 
  539. $iter = $t->getIterator(); 
  540.  
  541. $iter->nextRow(); 
  542. $this->assertEquals('XXXX', $iter->row['fname']); 
  543. $this->assertEquals('BBBBB', $iter->row['lname']); 
  544.  
  545. $iter->nextRow(); 
  546. $this->assertEquals('YYYY', $iter->row['fname']); 
  547. $this->assertEquals('CCCCC', $iter->row['lname']); 
  548.  
  549. $iter->nextRow(); 
  550. $this->assertEquals('ZZZZ', $iter->row['fname']); 
  551. $this->assertEquals('AAAAA', $iter->row['lname']); 
  552.  
  553. public function test_eval_class_chain_mixed_2() { 
  554. $t = new CFDBTransformParser; 
  555. $t->parse('SortByField(fname)&&upperall'); 
  556. $t->setupTransforms(); 
  557.  
  558. $data = array( 
  559. array('fname' => 'zzzz', 'lname' => 'AAAAA'),  
  560. array('fname' => 'yyyy', 'lname' => 'CCCCC'),  
  561. array('fname' => 'xxxx', 'lname' => 'BBBBB') 
  562. ); 
  563. $source = new ArrayDataIterator($data); 
  564. $t->setDataSource($source); 
  565. $iter = $t->getIterator(); 
  566.  
  567. $iter->nextRow(); 
  568. $this->assertEquals('XXXX', $iter->row['fname']); 
  569. $this->assertEquals('BBBBB', $iter->row['lname']); 
  570.  
  571. $iter->nextRow(); 
  572. $this->assertEquals('YYYY', $iter->row['fname']); 
  573. $this->assertEquals('CCCCC', $iter->row['lname']); 
  574.  
  575. $iter->nextRow(); 
  576. $this->assertEquals('ZZZZ', $iter->row['fname']); 
  577. $this->assertEquals('AAAAA', $iter->row['lname']); 
  578.  
  579.