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 | Intraface_Doctrine_Intranet::singleton(1); |
||
3 | |||
4 | class CurrencyTest extends PHPUnit_Framework_TestCase |
||
5 | { |
||
6 | private $object = null; |
||
0 ignored issues
–
show
|
|||
7 | |||
8 | function setUp() |
||
9 | { |
||
10 | $db = MDB2::singleton(DB_DSN); |
||
11 | $db->query('TRUNCATE currency'); |
||
12 | $db->query('TRUNCATE currency_exchangerate'); |
||
13 | } |
||
14 | |||
15 | /////////////////////////////////////////////////////// |
||
16 | |||
17 | function testConstruct() |
||
18 | { |
||
19 | $object = new Intraface_modules_currency_Currency; |
||
20 | $this->assertTrue(is_object($object)); |
||
21 | } |
||
22 | |||
23 | function testSave() |
||
24 | { |
||
25 | $object = new Intraface_modules_currency_Currency; |
||
26 | $type = new Intraface_modules_currency_Currency_Type; |
||
27 | $object->setType($type->getByIsoCode('EUR')); |
||
28 | try { |
||
29 | $object->save(); |
||
30 | } catch(Exception $e) { |
||
31 | $this->assertTrue(false, $e->getMessage()); |
||
32 | } |
||
33 | } |
||
34 | |||
35 | function testGetType() |
||
36 | { |
||
37 | $object = new Intraface_modules_currency_Currency; |
||
38 | $type = new Intraface_modules_currency_Currency_Type; |
||
39 | $object->setType($type->getByIsoCode('EUR')); |
||
40 | $object->save(); |
||
41 | |||
42 | $object = Doctrine::getTable('Intraface_modules_currency_Currency')->find(1); |
||
43 | $this->assertEquals('Intraface_modules_currency_Currency_Type_Eur', get_class($object->getType())); |
||
44 | } |
||
45 | |||
46 | function testGetProductPriceExchangeRate() |
||
47 | { |
||
48 | $currency = new Intraface_modules_currency_Currency; |
||
49 | $type = new Intraface_modules_currency_Currency_Type; |
||
50 | $currency->setType($type->getByIsoCode('EUR')); |
||
51 | $currency->save(); |
||
52 | |||
53 | $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice; |
||
54 | $rate->setRate(new Ilib_Variable_Float('745,21', 'da_dk')); |
||
55 | $rate->setCurrency($currency); |
||
56 | $rate->save(); |
||
57 | |||
58 | $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice; |
||
59 | $rate->setRate(new Ilib_Variable_Float('745,23', 'da_dk')); |
||
60 | $rate->setCurrency($currency); |
||
61 | $rate->save(); |
||
62 | |||
63 | $gateway = new Intraface_modules_currency_Currency_Gateway(Doctrine_Manager::connection()); |
||
64 | $currency = $gateway->findById(1); |
||
65 | |||
66 | $rate = $currency->getProductPriceExchangeRate(); |
||
67 | $this->assertEquals('745,23', $rate->getRate()->getAsLocal('da_dk')); |
||
68 | } |
||
69 | |||
70 | function testGetProductPriceExchangeRateReturnsNewestWithTwoCurrencies() |
||
71 | { |
||
72 | /** |
||
73 | * Of some strange reason with the following posts in the database it does not |
||
74 | * return the latest exchange rate |
||
75 | */ |
||
76 | |||
77 | # create Euro with exchange rate |
||
78 | $currency_eur = new Intraface_modules_currency_Currency; |
||
79 | $type = new Intraface_modules_currency_Currency_Type; |
||
80 | $currency_eur->setType($type->getByIsoCode('EUR')); |
||
81 | $currency_eur->save(); |
||
82 | |||
83 | $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice; |
||
84 | $rate->setRate(new Ilib_Variable_Float('7,21', 'da_dk')); |
||
85 | $rate->setCurrency($currency_eur); |
||
86 | $rate->save(); |
||
87 | |||
88 | $rate = new Intraface_modules_currency_Currency_ExchangeRate_Payment; |
||
89 | $rate->setRate(new Ilib_Variable_Float('7,20', 'da_dk')); |
||
90 | $rate->setCurrency($currency_eur); |
||
91 | $rate->save(); |
||
92 | |||
93 | |||
94 | # create dollars with exchange rate |
||
95 | $currency_usd = new Intraface_modules_currency_Currency; |
||
96 | $type = new Intraface_modules_currency_Currency_Type; |
||
97 | $currency_usd->setType($type->getByIsoCode('USD')); |
||
98 | $currency_usd->save(); |
||
99 | |||
100 | $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice; |
||
101 | $rate->setRate(new Ilib_Variable_Float('530', 'da_dk')); |
||
102 | $rate->setCurrency($currency_usd); |
||
103 | $rate->save(); |
||
104 | |||
105 | $rate = new Intraface_modules_currency_Currency_ExchangeRate_Payment; |
||
106 | $rate->setRate(new Ilib_Variable_Float('531', 'da_dk')); |
||
107 | $rate->setCurrency($currency_usd); |
||
108 | $rate->save(); |
||
109 | |||
110 | |||
111 | # Adds a new euro exchange rate |
||
112 | $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice; |
||
113 | $rate->setRate(new Ilib_Variable_Float('745,23', 'da_dk')); |
||
114 | $rate->setCurrency($currency_eur); |
||
115 | $rate->save(); |
||
116 | |||
117 | $rate = new Intraface_modules_currency_Currency_ExchangeRate_Payment; |
||
118 | $rate->setRate(new Ilib_Variable_Float('745,24', 'da_dk')); |
||
119 | $rate->setCurrency($currency_eur); |
||
120 | $rate->save(); |
||
121 | |||
122 | $gateway = new Intraface_modules_currency_Currency_Gateway(Doctrine_Manager::connection()); |
||
123 | // $currency = $gateway->findById(1); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
59% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
124 | |||
125 | $currencies = $gateway->findAllWithExchangeRate(); |
||
126 | |||
127 | foreach ($currencies as $currency) { |
||
128 | if ($currency->getType()->getIsoCode() == 'EUR') { |
||
129 | $rate = $currency->getProductPriceExchangeRate(0); |
||
130 | $this->assertEquals('745,23', $rate->getRate()->getAsLocal('da_dk')); |
||
131 | } |
||
132 | } |
||
133 | } |
||
134 | |||
135 | function testGetProductPriceExchangeRateWithId() |
||
136 | { |
||
137 | $currency = new Intraface_modules_currency_Currency; |
||
138 | $type = new Intraface_modules_currency_Currency_Type; |
||
139 | $currency->setType($type->getByIsoCode('EUR')); |
||
140 | $currency->save(); |
||
141 | |||
142 | $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice; |
||
143 | $rate->setRate(new Ilib_Variable_Float('745,21', 'da_dk')); |
||
144 | $rate->setCurrency($currency); |
||
145 | $rate->save(); |
||
146 | |||
147 | $rate = new Intraface_modules_currency_Currency_ExchangeRate_Payment; |
||
148 | $rate->setRate(new Ilib_Variable_Float('745,80', 'da_dk')); |
||
149 | $rate->setCurrency($currency); |
||
150 | $rate->save(); |
||
151 | |||
152 | $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice; |
||
153 | $rate->setRate(new Ilib_Variable_Float('745,23', 'da_dk')); |
||
154 | $rate->setCurrency($currency); |
||
155 | $rate->save(); |
||
156 | |||
157 | $gateway = new Intraface_modules_currency_Currency_Gateway(Doctrine_Manager::connection()); |
||
158 | $currency = $gateway->findById(1); |
||
159 | |||
160 | $this->assertEquals(1, $currency->getProductPriceExchangeRate(1)->getId()); |
||
161 | $this->assertEquals(3, $currency->getProductPriceExchangeRate(3)->getId()); |
||
162 | try { |
||
163 | $currency->getProductPriceExchangeRate(2); |
||
164 | $this->assertTrue(false); |
||
165 | } catch (Intraface_Gateway_Exception $e) { |
||
166 | $this->assertTrue(true); |
||
167 | } |
||
168 | } |
||
169 | } |
||
170 |
This check marks private properties in classes that are never used. Those properties can be removed.