This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Test - Dict class |
||
4 | * |
||
5 | * @package fwolflib |
||
6 | * @subpackage class.test |
||
7 | * @copyright Copyright 2011, Fwolf |
||
8 | * @author Fwolf <[email protected]> |
||
9 | * @since 2011-07-15 |
||
10 | */ |
||
11 | |||
12 | |||
13 | // Define like this, so test can run both under eclipse and web alone. |
||
14 | // {{{ |
||
15 | if (! defined('SIMPLE_TEST')) { |
||
16 | define('SIMPLE_TEST', 'simpletest/'); |
||
17 | require_once(SIMPLE_TEST . 'autorun.php'); |
||
18 | } |
||
19 | // Then set output encoding |
||
20 | //header('Content-Type: text/html; charset=utf-8'); |
||
21 | // }}} |
||
22 | |||
23 | // Require library define file which need test |
||
24 | require_once(dirname(__FILE__) . '/fwolflib.php'); |
||
25 | require_once(FWOLFLIB . 'class/adodb.php'); |
||
26 | require_once(FWOLFLIB . 'class/dict.php'); |
||
27 | require_once(FWOLFLIB . 'func/ecl.php'); |
||
28 | require_once(FWOLFLIB . 'func/request.php'); |
||
29 | |||
30 | |||
31 | class TestDict extends UnitTestCase { |
||
32 | |||
33 | /** |
||
34 | * Db object |
||
35 | * @var object |
||
36 | */ |
||
37 | protected $oDb = null; |
||
38 | |||
39 | /** |
||
40 | * Dict object |
||
41 | * @var object |
||
42 | */ |
||
43 | protected $oDict = null; |
||
44 | |||
45 | |||
46 | /** |
||
47 | * Constructor |
||
48 | */ |
||
49 | public function __construct () { |
||
50 | $this->oDict = new DictTest(); |
||
51 | } // end of func __construct |
||
52 | |||
53 | |||
54 | function TestDictSet () { |
||
0 ignored issues
–
show
|
|||
55 | //var_dump($this->oDict->aData); |
||
56 | $this->assertEqual(3, count($this->oDict->aData)); |
||
57 | |||
58 | //Ecl($this->oDict->LogGet(1)); |
||
59 | } // end of func TestDictSet |
||
60 | |||
61 | |||
62 | function TestDictGet () { |
||
0 ignored issues
–
show
|
|||
63 | $this->assertEqual('a', $this->oDict->Get(123)); |
||
64 | $this->assertEqual(2, $this->oDict->Get('bac')); |
||
65 | $this->assertEqual(array(123 => 'a', 321 => 'c') |
||
66 | , $this->oDict->Get(array(123, 321))); |
||
67 | |||
68 | $this->assertEqual(array('bac' |
||
69 | => array('code' => 'bac', 'title' => 2)) |
||
70 | , $this->oDict->GetList('!is_numeric("{code}")')); |
||
71 | $this->assertEqual(array(123 => array('code' => 123, 'title' => 'a') |
||
72 | , 321 => array('code' => 321, 'title' => 'c')) |
||
73 | , $this->oDict->GetList('"2" == substr("{code}", 1, 1)')); |
||
74 | |||
75 | // GetList with assign cols |
||
76 | $this->assertEqual(array(321 => 'c') |
||
77 | , $this->oDict->GetList('"c" == "{title}"', 'title')); |
||
78 | } // end of func TestDictGet |
||
79 | |||
80 | |||
81 | /* |
||
82 | function TestDictGetSql () { |
||
83 | $ar_db = array( |
||
84 | 'type' => 'mysqli', |
||
85 | 'host' => 'localhost', |
||
86 | 'user' => 't-2008-zbb', |
||
87 | 'pass' => '', |
||
88 | 'name' => 't-2008-zbb', |
||
89 | 'lang' => 'utf-8', |
||
90 | ); |
||
91 | $this->oDb = new Adodb($ar_db); |
||
92 | $this->oDb->Connect(); |
||
93 | Ecl($this->oDict->GetSql($this->oDb)); |
||
94 | } // end of func TestDictGetSql |
||
95 | */ |
||
96 | |||
97 | |||
98 | } // end of class TestDict |
||
99 | |||
100 | |||
101 | class DictTest extends Dict { |
||
0 ignored issues
–
show
The class
Dict has been deprecated with message: Use Fwlib\Db\CodeDictionary
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. ![]() |
|||
102 | public function Init () { |
||
103 | parent::Init(); |
||
104 | |||
105 | $this->Set(array( |
||
106 | array(123, 'a'), |
||
107 | array('bac', 2), |
||
108 | ))->Set(array(321, 'c')); |
||
109 | |||
110 | return $this; |
||
111 | } // end of func Init |
||
112 | |||
113 | |||
114 | public function SetStruct () { |
||
115 | parent::SetStruct(); |
||
116 | |||
117 | $this->SetCfg('dict-cols-pk', 'code'); |
||
0 ignored issues
–
show
'dict-cols-pk' is of type string , but the function expects a array .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
118 | } // end of func SetStruct |
||
119 | |||
120 | |||
121 | } // end of class DictTest |
||
122 | |||
123 | |||
124 | // Change output charset in this way. |
||
125 | // {{{ |
||
126 | $s_url = GetSelfUrl(false); |
||
0 ignored issues
–
show
The function
GetSelfUrl() has been deprecated with message: Use Fwlib\Util\HttpUtil::getSelfUrl()
This function has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead. ![]() |
|||
127 | $s_url = substr($s_url, strrpos($s_url, '/') + 1); |
||
128 | if ('dict.test.php' == $s_url) { |
||
129 | $test = new TestDict(); |
||
130 | $test->run(new HtmlReporter('utf-8')); |
||
131 | } |
||
132 | // }}} |
||
133 | ?> |
||
0 ignored issues
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. ![]() |
|||
134 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.