]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/Smarty/plugins/FunctionSugarLinkTest.php
Added unit tests.
[Github/sugarcrm.git] / tests / include / Smarty / plugins / FunctionSugarLinkTest.php
1 <?php
2 require_once 'include/Smarty/plugins/function.sugar_link.php';
3 require_once 'include/Sugar_Smarty.php';
4
5 class FunctionSugarLinkTest extends Sugar_PHPUnit_Framework_TestCase
6 {
7     public function setUp()
8     {
9         $this->_smarty = new Sugar_Smarty;
10     }
11     
12     public function testReturnModuleLinkOnly()
13     {
14         $string = 'my string';
15         
16         $output = smarty_function_sugar_link(
17             array('module'=>'Dog','link_only'=>'1'),
18             $this->_smarty);
19         
20         $this->assertContains("index.php?module=Dog&action=index",$output);
21     }
22     
23     public function testReturnModuleLinkWithAction()
24     {
25         $output = smarty_function_sugar_link(
26             array('module'=>'Dog','action'=>'cat','link_only'=>'1'),
27             $this->_smarty);
28         
29         $this->assertContains("index.php?module=Dog&action=cat",$output);
30     }
31     
32     public function testReturnModuleLinkWithActionAndExtraParams()
33     {
34         $output = smarty_function_sugar_link(
35             array('module'=>'Dog','action'=>'cat','extraparams'=>'foo=bar','link_only'=>'1'),
36             $this->_smarty);
37         
38         $this->assertContains("index.php?module=Dog&action=cat&foo=bar",$output);
39     }
40     
41     /**
42      * @group bug33909
43      */
44     public function testReturnLinkWhenPassingData()
45     {
46         $data = array(
47             '63edeacd-6ba5-b658-5e2a-4af9a5d682be',
48             'http://localhost',
49             'all',
50             'iFrames',
51             'Foo',
52             );
53
54         
55         $output = smarty_function_sugar_link(
56             array('module'=>'Dog','data'=>$data,'link_only'=>'1'),
57             $this->_smarty);
58         
59         $this->assertContains("index.php?module=iFrames&action=index&record=63edeacd-6ba5-b658-5e2a-4af9a5d682be&tab=true",$output);
60     }
61     
62     public function testCreatingFullLink()
63     {
64         $output = smarty_function_sugar_link(
65             array(
66                 'module'=>'Dog',
67                 'action'=>'cat',
68                 'id'=>'foo1',
69                 'class'=>'foo4',
70                 'style'=>'color:red;',
71                 'title'=>'foo2',
72                 'accesskey'=>'B',
73                 'options'=>'scope="row"',
74                 'label'=>'foo3',
75                 ),
76             $this->_smarty);
77         
78         $this->assertContains(
79             '<a href="index.php?module=Dog&action=cat" id="foo1" class="foo4" style="color:red;" scope="row">foo3</a>',$output);
80
81     }
82 }