Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_getDocAnchor.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 require_once 'Lib.Main.php';
15 
17 {
18  public $famName = "TST_TITLE";
19  /**
20  * import TST_TITLE family
21  * @static
22  * @return string
23  */
24  protected static function getCommonImportFile()
25  {
26  return "PU_data_dcp_getdocanchor.ods";
27  }
28  /**
29  * @dataProvider data_getDocAnchorMail
30  */
31  public function test_getDocAnchorMail($data)
32  {
33  $action = self::getAction();
34 
35  foreach ($data['params'] as $param) {
36  \ApplicationParameterManager::setCommonParameterValue($param['app'], $param['name'], $param['value']);
37  }
39 
40  $doc = new_Doc(self::$dbaccess, $data['doc']);
41  $this->assertTrue(is_object($doc) , sprintf("Could not get document with id '%s'.", $data['doc']));
42 
43  $data['expected_href'] = str_replace('%ID%', $doc->id, $data['expected_href']);
44 
45  $anchor = $doc->getDocAnchor($doc->id, 'mail');
46  $this->assertTrue(preg_match('/href=([\'"])(?P<href>.*?)\1/', $anchor, $m) === 1, sprintf("Could not find href='...' in anchor '%s'.", $anchor));
47  $href = $m['href'];
48  $this->assertTrue($href == $data['expected_href'], sprintf("Unexpected href '%s' (expecting '%s') in anchor '%s'.", $href, $data['expected_href'], $anchor));
49  }
50 
51  public function data_getDocAnchorMail()
52  {
53  return array(
54  array(
55  array(
56  "doc" => "TST_GETDOCANCHOR_1",
57  "params" => array(
58  array(
59  "app" => "CORE",
60  "name" => "CORE_MAILACTION",
61  "value" => ""
62  ) ,
63  array(
64  "app" => "CORE",
65  "name" => "CORE_URLINDEX",
66  "value" => "http://www1.example.net/"
67  )
68  ) ,
69  "expected_href" => "http://www1.example.net/?app=FDL&amp;action=OPENDOC&amp;mode=view&amp;id=%ID%&amp;latest=Y"
70  )
71  ) ,
72  array(
73  array(
74  "doc" => "TST_GETDOCANCHOR_1",
75  "params" => array(
76  array(
77  "app" => "CORE",
78  "name" => "CORE_MAILACTION",
79  "value" => "http://www2.example.net/?app=FOO&action=BAR"
80  ) ,
81  array(
82  "app" => "CORE",
83  "name" => "CORE_URLINDEX",
84  "value" => ""
85  )
86  ) ,
87  "expected_href" => "http://www2.example.net/?app=FOO&amp;action=BAR&amp;id=%ID%&amp;latest=Y"
88  )
89  )
90  );
91  }
92 }
global $action
initMainVolatileParam(Application &$core, Session &$session=null)
Definition: Lib.Main.php:244
static setCommonParameterValue($application, $parameterName, $value)
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
$param
Definition: import_size.php:31
$data
← centre documentaire © anakeen