Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_documentlink.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 
7 namespace Dcp\Pu;
8 /**
9  * @author Anakeen
10  * @package Dcp\Pu
11  */
12 require_once 'PU_testcase_dcp_document.php';
13 
15 {
16  protected static $outputDir;
17 
18  protected function setUp()
19  {
20  // nothing
21 
22  }
23 
24  protected function tearDown()
25  {
26  // nothing
27 
28  }
29 
30  public static function setUpBeforeClass()
31  {
32  parent::setUpBeforeClass();
33 
34  self::connectUser();
35  self::beginTransaction();
36  // family
37  self::importDocument("PU_data_dcp_documentlink.ods");
38  // three documents : linkOne, linkTwo and linkThree
39  self::importDocument("PU_data_dcp_documentslink.xml");
40  }
41 
42  public static function tearDownAfterClass()
43  {
44  self::rollbackTransaction();
45  }
46  /**
47  * @dataProvider dataAttrLinks
48  */
49  public function testAttrLinkCompose($docName, $link, $expectedLink)
50  {
51 
52  $doc = new_doc(self::$dbaccess, $docName);
53  $this->assertTrue($doc->isAlive() , "document $docName is not alive");
54  $url = $doc->urlWhatEncode($link);
55  $this->assertEquals($expectedLink, $url, "url link is not correctly encoded");
56  }
57  /**
58  * @dataProvider dataParamLinks
59  */
60  public function testParamLinkCompose($docName, $link, array $params, $expectedLink)
61  {
62 
63  $doc = new_doc(self::$dbaccess, $docName);
64  $this->assertTrue($doc->isAlive() , "document $docName is not alive");
65  foreach ($params as $k => $v) {
66  $this->getApplication()->SetVolatileParam($k, $v);
67  }
68 
69  $url = $doc->urlWhatEncode($link);
70  $this->assertEquals($expectedLink, $url, "url link is not correctly encoded");
71  }
72 
73  public function dataParamLinks()
74  {
75  return array(
76  array(
77  "linkOne",
78  "http://www.test.com/{PU_TEST1}",
79  array(
80  "PU_TEST1" => "testOne"
81  ) ,
82  "http://www.test.com/testOne"
83  ) ,
84  array(
85  "linkOne",
86  "http://www.test.com/{PU_TEST2}",
87  array(
88  "PU_TEST2" => "test Two"
89  ) ,
90  "http://www.test.com/test%20Two"
91  )
92  );
93  }
94 
95  public function dataAttrLinks()
96  {
97  return array(
98  array(
99  "linkOne",
100  "http://www.test.com/",
101  "http://www.test.com/"
102  ) ,
103  array(
104  "linkThree",
105  "http://test.com/%tst_title%/",
106  "http://test.com/Test/"
107  ) ,
108  array(
109  "linkThree",
110  "http://test.com/?title=%tst_title%&long=%tst_longtext%",
111  "http://test.com/?title=Test&long=Long"
112  ) ,
113  array(
114  "linkOne",
115  "http://test.com/?title=%tst_title%&long=%tst_longtext%",
116  "http://test.com/?title=Arbre%20%2B%20Feuilles&long=La%20nature%20est%20jolie%20%3Cen%20automne%3E"
117  ) ,
118  array(
119  "linkOne",
120  "http://test.com/?title=%aa_one%",
121  "http://test.com/?title=Un"
122  ) ,
123  array(
124  "linkOne",
125  "http://test.com/?title=%AA_ONE%",
126  "http://test.com/?title=Un"
127  ) ,
128  array(
129  "linkTwo",
130  "http://test.com/?title=%tst_title%",
131  "http://test.com/?title=Joe%20%26%20Jane"
132  ) ,
133  array(
134  "linkTwo",
135  "http://test.com/?long=%tst_longtext%",
136  "http://test.com/?long=Premi%C3%A8re%20ligne%5CnEt%20deuxi%C3%A8me%20ligne"
137  ) ,
138  array(
139  "linkTwo",
140  "http://test.com/?date=%tst_coldate%",
141  'http://test.com/?date=2011-11-01%5Cn2011-11-02'
142  ) ,
143  array(
144  "linkTwo",
145  "http://test.com/?date=%tst_nothing%",
146  false
147  ) ,
148  array(
149  "linkTwo",
150  "http://test.com/?title=%title%",
151  "http://test.com/?title=Joe%20%26%20Jane"
152  ) ,
153  array(
154  "linkTwo",
155  "http://test.com/?title=%TITLE%",
156  "http://test.com/?title=Joe%20%26%20Jane"
157  ) ,
158  array(
159  "linkTwo",
160  "http://test.com/?title=%T%",
161  "http://test.com/?title=Joe%20%26%20Jane"
162  ) ,
163  array(
164  "linkTwo",
165  "http://test.com/?title=%%2T",
166  "http://test.com/?title=%2T"
167  ) ,
168  array(
169  "linkTwo",
170  "http://test.com/?title=%3A",
171  "http://test.com/?title=%3A"
172  ) ,
173  array(
174  "linkTwo",
175  "http://test.com/?title=%3A%3ATest%28%29",
176  "http://test.com/?title=%3A%3ATest%28%29"
177  ) ,
178  array(
179  "linkTwo",
180  "http://test.com/?title=%3A%3A%T%%28%29",
181  "http://test.com/?title=%3A%3AJoe%20%26%20Jane%28%29"
182  ) ,
183  array(
184  "linkTwo",
185  "http://test.com/?title=%TITLE%&option=%?OPTIONONE%",
186  "http://test.com/?title=Joe%20%26%20Jane&option="
187  ) ,
188  array(
189  "linkTwo",
190  "http://test.com/?title=%TITLE%&option1=%?OPTIONONE%&hard=true&option2=%?OPTIONTWO%",
191  "http://test.com/?title=Joe%20%26%20Jane&option1=&hard=true&option2="
192  ) ,
193  array(
194  "linkTwo",
195  "::linkOne()",
196  "::linkOne()"
197  ) ,
198  array(
199  "linkTwo",
200  "%::linkOne()%",
201  "http://www.test.net/"
202  ) ,
203  array(
204  "linkTwo",
205  "%::linkOne()%?a=%T%",
206  "http://www.test.net/?a=Joe%20%26%20Jane"
207  ) ,
208  array(
209  "linkTwo",
210  "%::linkTwo()%",
211  "http://www.test.net/?b=Joe%20%26%20Jane"
212  )
213  );
214  }
215 }
216 ?>
$dbaccess
Definition: checkVault.php:17
← centre documentaire © anakeen