Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_getSortProperties.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package Dcp\PuTEST
5 */
6 
7 namespace Dcp\Pu;
8 
9 require_once 'PU_testcase_dcp_commonfamily.php';
10 
12 {
13  protected static function getCommonImportFile()
14  {
15  return array(
16  "PU_data_dcp_getSortProperties.ods"
17  );
18  }
19  /**
20  * @dataProvider data_getSortProperties
21  * @param $data
22  */
23  public function test_getSortProperties($data)
24  {
25  if (!is_numeric($data['famid'])) {
26  $data['famid'] = getIdFromName(self::$dbaccess, $data['famid']);
27  }
28 
29  $famdoc = new \DocFam(self::$dbaccess, $data['famid']);
30  $properties = $famdoc->getSortProperties();
31  $count = count($properties);
32  $this->assertTrue(($count == $data['expected']['count']) , sprintf("Got '%d' properties while expecting '%d': %s", $count, $data['expected']['count'], print_r($properties, true)));
33 
34  foreach ($data['expected']['check'] as $check) {
35  $found = false;
36  foreach ($properties as $propName => $parameters) {
37  if ($propName == $check['id']) {
38  $found = true;
39  break;
40  }
41  }
42  $this->assertTrue($found, sprintf("Expected property '%s' not found.", $check['id']));
43  $this->assertTrue(($parameters['sort'] == $check['sort']) , sprintf("Property '%s' has sort '%s' while expecting '%s'.", $propName, $parameters['sort'], $check['sort']));
44  }
45  }
46  /**
47  * @return array
48  */
49  public function data_getSortProperties()
50  {
51  return array(
52  array(
53  array(
54  'famid' => 'TST_GETSORTPROPERTIES_1',
55  'expected' => array(
56  'count' => 4,
57  'check' => array(
58  array(
59  'id' => 'title',
60  'sort' => 'desc'
61  ) ,
62  array(
63  'id' => 'initid',
64  'sort' => 'desc'
65  ) ,
66  array(
67  'id' => 'revdate',
68  'sort' => 'desc'
69  ) ,
70  array(
71  'id' => 'state',
72  'sort' => 'asc'
73  )
74  )
75  )
76  )
77  ) ,
78  array(
79  array(
80  'famid' => 'TST_GETSORTPROPERTIES_2',
81  'expected' => array(
82  'count' => 5,
83  'check' => array(
84  array(
85  'id' => 'title',
86  'sort' => 'asc'
87  ) ,
88  array(
89  'id' => 'initid',
90  'sort' => 'desc'
91  ) ,
92  array(
93  'id' => 'revdate',
94  'sort' => 'desc'
95  ) ,
96  array(
97  'id' => 'state',
98  'sort' => 'asc'
99  ) ,
100  array(
101  'id' => 'owner',
102  'sort' => 'asc'
103  )
104  )
105  )
106  )
107  )
108  );
109  }
110 }
$dbaccess
Definition: checkVault.php:17
getIdFromName($dbaccess, $name)
$data
← centre documentaire © anakeen