1<?php 2 3require_once DOKU_INC . 'inc/parser/xhtml.php'; 4 5/** 6 * @group plugin_data 7 * @group plugins 8 */ 9class syntax_plugin_dataau_table_test extends DokuWikiTest { 10 11 protected $pluginsEnabled = array('dataau', 'sqlite'); 12 13 private $exampleEntry; 14 15 function __construct() { 16 $this->exampleEntry = "---- datatable employees----\n" 17 . "cols : %pageid%, employees, deadline_dt, website_url, volume\n" 18 . 'headers : Details, "Assigned Employees \#no", stuff outside quotes """Deadline, ", Personal website, $$$'."\n" 19 . "max : 10\n" 20 . "filter : type=web development\n" 21 . "sort : ^volume\n" 22 . "dynfilters: 1\n" 23 . "summarize : 1\n" 24 . "align : c\n" 25 . "rownumbers: 1\n" 26 . "widths : 50px, 20em, - , 10%\n" 27 . "----"; 28 } 29 30 function testHandle() { 31 $plugin = new syntax_plugin_dataau_table(); 32 33 $handler = new Doku_Handler(); 34 $result = $plugin->handle($this->exampleEntry, 0, 10, $handler); 35 36 $dataau = array( 37 'classes' => 'employees', 38 'limit' => 10, 39 'dynfilters' => 1, 40 'summarize' => 1, 41 'rownumbers' => 1, 42 'sepbyheaders' => '', 43 'headers' => array( 44 '0' => 'Details', 45 '1' => 'Assigned Employees #no', 46 '2' => '"Deadline, ', 47 '3' => 'Personal website', 48 '4' => '$$$' 49 ), 50 'widths' => array( 51 '0' => '50px', 52 '1' => '20em', 53 '2' => '-', 54 '3' => '10%' 55 ), 56 'filter' => array( 57 '0' => array( 58 'key' => 'type', 59 'value' => 'web development', 60 'compare' => '=', 61 'colname' => 'type', 62 'type' => '', 63 'logic' => 'AND' 64 ) 65 ), 66 'cols' => array( 67 '%pageid%' => array( 68 'colname' => '%pageid%', 69 'multi' => '', 70 'key' => '%pageid%', 71 'origkey' => '%pageid%', 72 'title' => 'Title', 73 'type' => 'page', 74 ), 75 'employee' => array( 76 'colname' => 'employees', 77 'multi' => 1, 78 'key' => 'employee', 79 'origkey' => 'employee', 80 'title' => 'employee', 81 'type' => '' 82 ), 83 'deadline' => array( 84 'colname' => 'deadline_dt', 85 'multi' => '', 86 'key' => 'deadline', 87 'origkey' => 'deadline', 88 'title' => 'deadline', 89 'type' => 'dt' 90 ), 91 'website' => array( 92 'colname' => 'website_url', 93 'multi' => '', 94 'key' => 'website', 95 'origkey' => 'website', 96 'title' => 'website', 97 'type' => 'url' 98 ), 99 'volume' => array( 100 'colname' => 'volume', 101 'multi' => '', 102 'key' => 'volume', 103 'origkey' => 'volume', 104 'title' => 'volume', 105 'type' => '' 106 ), 107 108 ), 109 'sort' => array( 110 '0' => 'volume', 111 '1' => 'DESC' 112 ), 113 'align' => array( 114 '0' => 'center' 115 ), 116 'sql' => "SELECT \" \" || pages.page, group_concat(\" \" || T1.value,' 117'), group_concat(\" \" || T2.value,' 118'), group_concat(\" \" || T3.value,' 119'), group_concat(\" \" || T4.value,' 120') 121 FROM ( 122 SELECT DISTINCT pages.pid AS pid 123 FROM pages LEFT JOIN dataau AS T1 ON T1.pid = pages.pid AND T1.key = 'type' 124 WHERE 1 = 1 AND T1.value = 'web development' 125 ) AS W1 126 LEFT JOIN dataau AS T1 ON T1.pid = W1.pid AND T1.key = 'employee' LEFT JOIN dataau AS T2 ON T2.pid = W1.pid AND T2.key = 'deadline' LEFT JOIN dataau AS T3 ON T3.pid = W1.pid AND T3.key = 'website' LEFT JOIN dataau AS T4 ON T4.pid = W1.pid AND T4.key = 'volume' 127 LEFT JOIN pages ON W1.pid=pages.pid 128 GROUP BY W1.pid 129 ORDER BY T4.value DESC LIMIT 11", 130 'cur_param' => array() 131 132); 133 $this->assertEquals($dataau, $result, 'Data array corrupted'); 134 } 135 136} 137 138 139