Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_applicationparameters.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 
13 require_once 'PU_testcase_dcp.php';
14 
16 {
17 
18  const appName = "DCPTEST1";
19  /**
20  * @return \Application
21  */
22  private function initTestApplication()
23  {
24  $appTest = new \Application(self::$dbaccess);
25  $appTest->name = self::appName;
26  $appTest->Add();
27  $parent = null;
28  $appTest->set(self::appName, $parent);
29  return $appTest;
30  }
31  /**
32  * @dataProvider dataParameters
33  */
34  public function testGetParam($parameters, array $expectedValues)
35  {
36 
37  $appTest = $this->initTestApplication();
38  $this->assertTrue($appTest->isAffected() , sprintf("DCPTEST app not found"));
39  $appTest->param->DelStatic($appTest->id);
40  $appTest->InitAllParam($parameters, $update = true);
41 
42  foreach ($expectedValues as $k => $v) {
43  $this->assertEquals($v, $appTest->GetParam($k) , sprintf("wrong value for %s", $k));
44  }
45  }
46  /**
47  * @dataProvider dataGlobParameters
48  */
49  public function testGlobParam(array $parameters, array $expectedGlob, array $expectedNoGlob)
50  {
51 
52  $appTest = $this->initTestApplication();
53  $this->assertTrue($appTest->isAffected() , sprintf("DCPTEST app not found"));
54  $appTest->InitAllParam($parameters, $update = true);
55  $this->globParamTest($appTest, $expectedGlob, $expectedNoGlob);
56  }
57  /**
58  * @dataProvider dataGlobMigrParameters
59  */
60  public function testGlobMigrParam(array $parameters1, array $parameters2, array $expectedGlob, array $expectedNoGlob)
61  {
62 
63  $appTest = $this->initTestApplication();
64  $this->assertTrue($appTest->isAffected() , sprintf("DCPTEST app not found"));
65  $appTest->InitAllParam($parameters1, $update = true);
66  $appTest->InitAllParam($parameters2, $update = true);
67  $this->globParamTest($appTest, $expectedGlob, $expectedNoGlob);
68  }
69  /**
70  * @dataProvider dataGlobParameters
71  */
72  protected function globParamTest(\Application & $appTest, array $expectedGlob, array $expectedNoGlob)
73  {
74  foreach ($expectedGlob as $globId) {
75  $p = new \Param(self::$dbaccess, array(
76  $globId,
77  PARAM_GLB,
78  $appTest->id
79  ));
80  $this->assertTrue($p->isAffected() , sprintf("not paramvalue glob %s", $globId));
81  $pdef = new \ParamDef(self::$dbaccess, $globId);
82  $this->assertTrue($pdef->isAffected() , sprintf("not paramdef %s", $globId));
83  $this->assertEquals('Y', $pdef->isglob, sprintf("not a paramdef glob %s", $globId));
84  }
85 
86  foreach ($expectedNoGlob as $globId) {
87  $p = new \Param(self::$dbaccess, array(
88  $globId,
89  PARAM_APP,
90  $appTest->id
91  ));
92  $this->assertTrue($p->isAffected() , sprintf("not paramvalue app %s", $globId));
93  $pdef = new \ParamDef(self::$dbaccess, $globId);
94  $this->assertTrue($pdef->isAffected() , sprintf("not paramdef %s", $globId));
95  $this->assertEquals('N', $pdef->isglob, sprintf("not a paramdef app %s", $globId));
96  }
97  }
98  public function dataParameters()
99  {
100  return array(
101  array(
102  array(
103  "VERSION" => "0.3.2-2",
104  "TST_NAMEP1" => array(
105  "val" => "Zoo Land",
106  "descr" => N_("Name of the zoo") ,
107  "global" => "N",
108  "user" => "N"
109  ) ,
110  "TST_GLOB1" => array(
111  "val" => "Glob one",
112  "descr" => N_("Name of the glob") ,
113  "global" => "N",
114  "user" => "N"
115  )
116  ) ,
117  array(
118  "TST_NAMEP1" => "Zoo Land",
119  "VERSION" => "0.3.2-2",
120  "TST_GLOB1" => "Glob one"
121  )
122  ) ,
123  array(
124  array(
125  "VERSION" => "0.3.2-2",
126  "TST_NAMEP1" => array(
127  "val" => "Zoo Land",
128  "descr" => N_("Name of the zoo") ,
129  "global" => "Y",
130  "user" => "N"
131  ) ,
132  "TST_GLOB2" => array(
133  "val" => "Glob two",
134  "descr" => N_("Name of the glob") ,
135  "global" => "N",
136  "user" => "Y"
137  )
138  ) ,
139  array(
140  "TST_NAMEP1" => "Zoo Land",
141  "VERSION" => "0.3.2-2",
142  "TST_GLOB2" => "Glob two"
143  )
144  )
145  );
146  }
147 
148  public function dataGlobParameters()
149  {
150  return array(
151  array(
152  array(
153  "VERSION" => "0.3.2-2",
154  "TST_NAMEP1" => array(
155  "val" => "Zoo Land",
156  "descr" => N_("Name of the zoo") ,
157  "global" => "N",
158  "user" => "N"
159  ) ,
160  "TST_GLOB1" => array(
161  "val" => "Glob one",
162  "descr" => N_("Name of the glob") ,
163  "global" => "Y",
164  "user" => "N"
165  )
166  ) ,
167  "glob" => array(
168  "TST_GLOB1"
169  ) ,
170  "noglob" => array(
171  "TST_NAMEP1",
172  "VERSION"
173  )
174  )
175  );
176  }
177 
178  public function dataGlobMigrParameters()
179  {
180  return array(
181  array(
182  "conf1" => array(
183  "VERSION" => "0.3.2-2",
184  "TST_NAMEP1" => array(
185  "val" => "Zoo Land",
186  "descr" => N_("Name of the zoo") ,
187  "global" => "N",
188  "user" => "N"
189  ) ,
190  "TST_GLOB1" => array(
191  "val" => "Glob one",
192  "descr" => N_("Name of the glob") ,
193  "global" => "Y",
194  "user" => "N"
195  )
196  ) ,
197  "conf2" => array(
198  "TST_NAMEP1" => array(
199  "val" => "Zoo Land",
200  "descr" => N_("Name of the zoo") ,
201  "global" => "Y",
202  "user" => "N"
203  ) ,
204  "TST_GLOB1" => array(
205  "val" => "Glob one",
206  "descr" => N_("Name of the glob") ,
207  "global" => "N",
208  "user" => "N"
209  )
210  ) ,
211  "glob" => array(
212 
213  "TST_NAMEP1"
214  ) ,
215  "noglob" => array(
216  "TST_GLOB1",
217  "VERSION"
218  )
219  )
220  );
221  }
222 }
223 ?>
const PARAM_APP
Definition: Class.Param.php:21
testGlobMigrParam(array $parameters1, array $parameters2, array $expectedGlob, array $expectedNoGlob)
testGetParam($parameters, array $expectedValues)
const PARAM_GLB
Definition: Class.Param.php:23
globParamTest(\Application &$appTest, array $expectedGlob, array $expectedNoGlob)
testGlobParam(array $parameters, array $expectedGlob, array $expectedNoGlob)
$dbaccess
Definition: checkVault.php:17
N_($s)
Definition: Lib.Common.php:18
← centre documentaire © anakeen