Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_attributeslashes.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_commonfamily.php';
14 
16 {
17  /**
18  * import TST_SLASHFAMILY1 family
19  * @static
20  * @return string
21  */
22  protected static function getCommonImportFile()
23  {
24  return "PU_data_dcp_attributeslashes.ods";
25  }
26 
27  protected $famName = 'TST_SLASHFAMILY1';
28  /**
29  * @dataProvider dataOption
30  */
31  public function testOption($attrid, $optname, $expectedvalue)
32  {
33  static $d = null;
34  if ($d === null) {
35  $d = createDoc(self::$dbaccess, $this->famName);
36  $this->assertTrue(is_object($d) , sprintf("cannot create %s document", $this->famName));
37  }
38  $oa = $d->getAttribute($attrid);
39  $this->assertNotEmpty($oa, sprintf("attribute %s not found in %s family", $attrid, $this->famName));
40  $value = $oa->getOption($optname);
41  $this->assertEquals($expectedvalue, $value, sprintf("not the expected default value attribute %s", $attrid));
42 
43  return $d;
44  }
45  /**
46  * @dataProvider dataPhpfunc
47  */
48  public function testPhpfunc($attrid, $expectedvalue)
49  {
50  static $d = null;
51  if ($d === null) {
52  $d = createDoc(self::$dbaccess, $this->famName);
53  $this->assertTrue(is_object($d) , sprintf("cannot create %s document", $this->famName));
54  }
55  /**
56  * @var \NormalAttribute $oa
57  */
58  $oa = $d->getAttribute($attrid);
59  $this->assertNotEmpty($oa, sprintf("attribute %s not found in %s family", $attrid, $this->famName));
60  $value = $oa->phpfunc;
61  $this->assertEquals($expectedvalue, $value, sprintf("not the expected default value attribute %s", $attrid));
62 
63  return $d;
64  }
65 
66  public function dataOption()
67  {
68  return array(
69  array(
70  "TST_TITLE",
71  "etitle",
72  "test"
73  ) ,
74  array(
75  "TST_NUMBER1",
76  "etitle",
77  '"number"'
78  ) ,
79  array(
80  "TST_NUMBER2",
81  "etitle",
82  'A\\B'
83  ) ,
84  array(
85  "TST_NUMBER3",
86  "etitle",
87  'C\\\\D'
88  ) ,
89  array(
90  "TST_NUMBER4",
91  "quote",
92  'test"'
93  ) ,
94  array(
95  "TST_NUMBER4",
96  "other",
97  '\\"test\\"'
98  ) ,
99  array(
100  "TST_TEXT4",
101  "jsonconf",
102  '{"addPlugins": ["docattr"],"doclink": {"famId": "DIR", "filter" : "title=\\\\\'Comptes\\\\\'"}}'
103  )
104  );
105  }
106 
107  public function dataPhpfunc()
108  {
109  return array(
110  array(
111  "TST_NUMBER1",
112  "::isOne()",
113  ) ,
114  array(
115  "TST_NUMBER2",
116  '::oneMore("3")'
117  ) ,
118  array(
119  "TST_TEXT3",
120  '::commaConcat(TST_TEXT1, TST_TEXT2)'
121  )
122  );
123  }
124 }
125 ?>
$d
Definition: dav.php:77
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
$dbaccess
Definition: checkVault.php:17
testOption($attrid, $optname, $expectedvalue)
$value
← centre documentaire © anakeen